summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2005-10-19 00:53:05 +0000
committerEric Anholt <[email protected]>2005-10-19 00:53:05 +0000
commitdeadd47aab68d4914d70b19fa08f834623f2e0a7 (patch)
tree5f951bc349cff8655995dcfee24372c489647f68 /src
parentbf3f0bcf802af20b2d95890ad4dcc56c98289b10 (diff)
Bug #4615: Fix the SiS driver for the renderbuffer changes. Previously, all
drirenderbuffers pointed at screen offset 0 and NULL. Instead, set up the front buffer at startup but leave the others for later, since sis allocates them on demand rather than using the static method of the other non-sis-descendent drivers. Some basic apps work, but fallbacks may be broken still.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/sis/sis_alloc.c87
-rw-r--r--src/mesa/drivers/dri/sis/sis_clear.c6
-rw-r--r--src/mesa/drivers/dri/sis/sis_context.c24
-rw-r--r--src/mesa/drivers/dri/sis/sis_context.h39
-rw-r--r--src/mesa/drivers/dri/sis/sis_dd.c137
-rw-r--r--src/mesa/drivers/dri/sis/sis_screen.c76
-rw-r--r--src/mesa/drivers/dri/sis/sis_screen.h1
-rw-r--r--src/mesa/drivers/dri/sis/sis_span.c58
-rw-r--r--src/mesa/drivers/dri/sis/sis_span.h2
-rw-r--r--src/mesa/drivers/dri/sis/sis_state.c15
-rw-r--r--src/mesa/drivers/dri/sis/sis_texstate.c4
11 files changed, 252 insertions, 197 deletions
diff --git a/src/mesa/drivers/dri/sis/sis_alloc.c b/src/mesa/drivers/dri/sis/sis_alloc.c
index b808daae3d2..99342153657 100644
--- a/src/mesa/drivers/dri/sis/sis_alloc.c
+++ b/src/mesa/drivers/dri/sis/sis_alloc.c
@@ -136,45 +136,42 @@ sisFreeAGP( sisContextPtr smesa, void *handle )
void
sisAllocZStencilBuffer( sisContextPtr smesa )
{
- GLuint z_depth;
- GLuint totalBytes;
- int width2;
-
- GLubyte *addr;
-
- z_depth = ( smesa->glCtx->Visual.depthBits +
+ int cpp = ( smesa->glCtx->Visual.depthBits +
smesa->glCtx->Visual.stencilBits ) / 8;
+ unsigned char *addr;
- width2 = ALIGNMENT( smesa->width * z_depth, 4 );
+ smesa->depth.bpp = cpp * 8;
+ smesa->depth.pitch = ALIGNMENT(smesa->driDrawable->w * cpp, 4);
+ smesa->depth.size = smesa->depth.pitch * smesa->driDrawable->h;
+ smesa->depth.size += Z_BUFFER_HW_PLUS;
- totalBytes = smesa->height * width2 + Z_BUFFER_HW_PLUS;
-
- addr = sisAllocFB( smesa, totalBytes, &smesa->zbFree );
+ addr = sisAllocFB(smesa, smesa->depth.size, &smesa->depth.handle);
if (addr == NULL)
sis_fatal_error("Failure to allocate Z buffer.\n");
+ addr = (char *)ALIGNMENT((unsigned long)addr, Z_BUFFER_HW_ALIGNMENT);
- if (SIS_VERBOSE & VERBOSE_SIS_BUFFER) {
- fprintf(stderr, "sis_alloc_z_stencil_buffer: addr=%p\n", addr);
- }
+ smesa->depth.map = addr;
+ smesa->depth.offset = addr - smesa->FbBase;
- addr = (GLubyte *)ALIGNMENT( (unsigned long)addr, Z_BUFFER_HW_ALIGNMENT );
-
- smesa->depthbuffer = (void *) addr;
- smesa->depthPitch = width2;
- smesa->depthOffset = (unsigned long)addr - (unsigned long)smesa->FbBase;
+ /* stencil buffer is same as depth buffer */
+ smesa->stencil.size = smesa->depth.size;
+ smesa->stencil.offset = smesa->depth.offset;
+ smesa->stencil.handle = smesa->depth.handle;
+ smesa->stencil.pitch = smesa->depth.pitch;
+ smesa->stencil.bpp = smesa->depth.bpp;
+ smesa->stencil.map = smesa->depth.map;
/* set pZClearPacket */
memset( &smesa->zClearPacket, 0, sizeof(ENGPACKET) );
- smesa->zClearPacket.dwSrcPitch = (z_depth == 2) ? 0x80000000 : 0xf0000000;
- smesa->zClearPacket.dwDestBaseAddr = (unsigned long)(addr -
- (unsigned long)smesa->FbBase);
- smesa->zClearPacket.wDestPitch = width2;
+ smesa->zClearPacket.dwSrcPitch = (cpp == 2) ? 0x80000000 : 0xf0000000;
+ smesa->zClearPacket.dwDestBaseAddr = smesa->depth.offset;
+ smesa->zClearPacket.wDestPitch = smesa->depth.pitch;
smesa->zClearPacket.stdwDestPos.wY = 0;
smesa->zClearPacket.stdwDestPos.wX = 0;
smesa->zClearPacket.wDestHeight = smesa->virtualY;
- smesa->zClearPacket.stdwDim.wWidth = (GLshort)width2 / z_depth;
+ smesa->zClearPacket.stdwDim.wWidth = smesa->depth.pitch / cpp;
smesa->zClearPacket.stdwDim.wHeight = (GLshort)smesa->height;
smesa->zClearPacket.stdwCmd.cRop = 0xf0;
@@ -188,43 +185,40 @@ sisAllocZStencilBuffer( sisContextPtr smesa )
void
sisFreeZStencilBuffer( sisContextPtr smesa )
{
- sisFreeFB( smesa, smesa->zbFree );
- smesa->zbFree = NULL;
- smesa->depthbuffer = NULL;
+ sisFreeFB(smesa, smesa->depth.handle);
+ smesa->depth.map = NULL;
+ smesa->depth.offset = 0;
}
void
sisAllocBackbuffer( sisContextPtr smesa )
{
- GLuint depth = smesa->bytesPerPixel;
- GLuint size, width2;
-
- char *addr;
+ int cpp = smesa->bytesPerPixel;
+ unsigned char *addr;
- width2 = (depth == 2) ? ALIGNMENT (smesa->width, 2) : smesa->width;
- size = width2 * smesa->height * depth + DRAW_BUFFER_HW_PLUS;
+ smesa->back.bpp = smesa->bytesPerPixel * 8;
+ smesa->back.pitch = ALIGNMENT(smesa->driDrawable->w * cpp, 4);
+ smesa->back.size = smesa->back.pitch * smesa->driDrawable->h;
+ smesa->back.size += DRAW_BUFFER_HW_PLUS;
- /* Fixme: unique context alloc/free back-buffer? */
- addr = sisAllocFB( smesa, size, &smesa->bbFree );
+ addr = sisAllocFB(smesa, smesa->back.size, &smesa->back.handle);
if (addr == NULL)
sis_fatal_error("Failure to allocate back buffer.\n");
+ addr = (char *)ALIGNMENT((unsigned long)addr, DRAW_BUFFER_HW_ALIGNMENT);
- addr = (char *)ALIGNMENT( (unsigned long)addr, DRAW_BUFFER_HW_ALIGNMENT );
-
- smesa->backbuffer = addr;
- smesa->backOffset = (unsigned long)(addr - (unsigned long)smesa->FbBase);
- smesa->backPitch = width2 * depth;
+ smesa->back.map = addr;
+ smesa->back.offset = addr - smesa->FbBase;
memset ( &smesa->cbClearPacket, 0, sizeof(ENGPACKET) );
- smesa->cbClearPacket.dwSrcPitch = (depth == 2) ? 0x80000000 : 0xf0000000;
- smesa->cbClearPacket.dwDestBaseAddr = smesa->backOffset;
- smesa->cbClearPacket.wDestPitch = smesa->backPitch;
+ smesa->cbClearPacket.dwSrcPitch = (cpp == 2) ? 0x80000000 : 0xf0000000;
+ smesa->cbClearPacket.dwDestBaseAddr = smesa->back.offset;
+ smesa->cbClearPacket.wDestPitch = smesa->back.pitch;
smesa->cbClearPacket.stdwDestPos.wY = 0;
smesa->cbClearPacket.stdwDestPos.wX = 0;
smesa->cbClearPacket.wDestHeight = smesa->virtualY;
- smesa->cbClearPacket.stdwDim.wWidth = (GLshort) width2;
+ smesa->cbClearPacket.stdwDim.wWidth = (GLshort) smesa->back.pitch / cpp;
smesa->cbClearPacket.stdwDim.wHeight = (GLshort) smesa->height;
smesa->cbClearPacket.stdwCmd.cRop = 0xf0;
@@ -238,6 +232,7 @@ sisAllocBackbuffer( sisContextPtr smesa )
void
sisFreeBackbuffer( sisContextPtr smesa )
{
- sisFreeFB( smesa, smesa->bbFree );
- smesa->backbuffer = NULL;
+ sisFreeFB(smesa, smesa->back.handle);
+ smesa->back.map = NULL;
+ smesa->back.offset = 0;
}
diff --git a/src/mesa/drivers/dri/sis/sis_clear.c b/src/mesa/drivers/dri/sis/sis_clear.c
index ef4b561ca58..e170faac399 100644
--- a/src/mesa/drivers/dri/sis/sis_clear.c
+++ b/src/mesa/drivers/dri/sis/sis_clear.c
@@ -144,7 +144,7 @@ sisDDClear( GLcontext * ctx, GLbitfield mask, GLboolean all,
}
if (mask & (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)) {
- if (smesa->depthbuffer != NULL)
+ if (smesa->depth.offset != NULL)
sis_clear_z_stencil_buffer( ctx, mask, x1, y1, width1, height1 );
mask &= ~(BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL);
}
@@ -393,8 +393,8 @@ sis_clear_color_buffer( GLcontext *ctx, GLenum mask, GLint x, GLint y,
memset( &stEngPacket, 0, sizeof (ENGPACKET) );
stEngPacket.dwSrcPitch = (depth == 2) ? 0x80000000 : 0xc0000000;
- stEngPacket.dwDestBaseAddr = smesa->frontOffset;
- stEngPacket.wDestPitch = smesa->frontPitch;
+ stEngPacket.dwDestBaseAddr = smesa->front.offset;
+ stEngPacket.wDestPitch = smesa->front.pitch;
/* TODO: set maximum value? */
stEngPacket.wDestHeight = smesa->virtualY;
stEngPacket.stdwCmd.cRop = 0xf0;
diff --git a/src/mesa/drivers/dri/sis/sis_context.c b/src/mesa/drivers/dri/sis/sis_context.c
index cfb7700afa2..6f307a25992 100644
--- a/src/mesa/drivers/dri/sis/sis_context.c
+++ b/src/mesa/drivers/dri/sis/sis_context.c
@@ -47,6 +47,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "matrix.h"
#include "extensions.h"
#include "utils.h"
+#include "framebuffer.h"
#include "drivers/common/driverfuncs.h"
@@ -105,6 +106,16 @@ WaitingFor3dIdle(sisContextPtr smesa, int wLen)
}
}
+void sisReAllocateBuffers(GLcontext *ctx, GLframebuffer *drawbuffer,
+ GLuint width, GLuint height)
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ sisUpdateBufferSize(smesa);
+
+ _mesa_resize_framebuffer(ctx, drawbuffer, width, height);
+}
+
GLboolean
sisCreateContext( const __GLcontextModes *glVisual,
__DRIcontextPrivate *driContextPriv,
@@ -156,11 +167,10 @@ sisCreateContext( const __GLcontextModes *glVisual,
smesa->bytesPerPixel = sisScreen->cpp;
smesa->IOBase = sisScreen->mmio.map;
smesa->Chipset = sisScreen->deviceID;
- smesa->irqEnabled = sisScreen->irqEnabled;
smesa->FbBase = sPriv->pFB;
smesa->displayWidth = sPriv->fbWidth;
- smesa->frontPitch = sPriv->fbStride;
+ smesa->front.pitch = sPriv->fbStride;
smesa->sarea = (SISSAREAPriv *)((char *)sPriv->pSAREA +
sisScreen->sarea_priv_offset);
@@ -187,7 +197,7 @@ sisCreateContext( const __GLcontextModes *glVisual,
smesa->colorFormat = DST_FORMAT_RGB_565;
break;
default:
- sis_fatal_error("Bad bytesPerPixel.\n");
+ sis_fatal_error("Bad bytesPerPixel %d.\n", smesa->bytesPerPixel);
}
/* Parse configuration files */
@@ -303,6 +313,7 @@ sisMakeCurrent( __DRIcontextPrivate *driContextPriv,
GET_CURRENT_CONTEXT(ctx);
sisContextPtr oldSisCtx = ctx ? SIS_CONTEXT(ctx) : NULL;
sisContextPtr newSisCtx = (sisContextPtr) driContextPriv->driverPrivate;
+ struct gl_framebuffer *drawBuffer, *readBuffer;
if ( newSisCtx != oldSisCtx) {
newSisCtx->GlobalFlag = GFLAG_ALL;
@@ -310,9 +321,10 @@ sisMakeCurrent( __DRIcontextPrivate *driContextPriv,
newSisCtx->driDrawable = driDrawPriv;
- _mesa_make_current( newSisCtx->glCtx,
- (GLframebuffer *) driDrawPriv->driverPrivate,
- (GLframebuffer *) driReadPriv->driverPrivate );
+ drawBuffer = (GLframebuffer *)driDrawPriv->driverPrivate;
+ readBuffer = (GLframebuffer *)driReadPriv->driverPrivate;
+
+ _mesa_make_current( newSisCtx->glCtx, drawBuffer, readBuffer );
sisUpdateBufferSize( newSisCtx );
sisUpdateClipping( newSisCtx->glCtx );
diff --git a/src/mesa/drivers/dri/sis/sis_context.h b/src/mesa/drivers/dri/sis/sis_context.h
index fee8f6ead11..5ef1895362d 100644
--- a/src/mesa/drivers/dri/sis/sis_context.h
+++ b/src/mesa/drivers/dri/sis/sis_context.h
@@ -231,6 +231,19 @@ typedef void (*sis_line_func)( sisContextPtr,
typedef void (*sis_point_func)( sisContextPtr,
sisVertex * );
+/**
+ * Derived from gl_renderbuffer.
+ */
+struct sis_renderbuffer {
+ struct gl_renderbuffer Base; /* must be first! */
+ drmSize size;
+ GLuint offset;
+ void *handle;
+ GLuint pitch;
+ GLuint bpp;
+ char *map;
+};
+
/* Device dependent context state */
struct sis_context
@@ -264,8 +277,6 @@ struct sis_context
unsigned char *IOBase;
unsigned char *FbBase;
unsigned int displayWidth;
- unsigned int frontOffset;
- unsigned int frontPitch;
/* HW RGBA layout */
unsigned int redMask, greenMask, blueMask, alphaMask;
@@ -333,18 +344,12 @@ struct sis_context
/* Front/back/depth buffer info */
GLuint width, height; /* size of buffers */
GLint bottom; /* used for FLIP macro */
- GLvoid *backbuffer;
- unsigned int backOffset;
- unsigned int backPitch;
- GLvoid *depthbuffer;
- unsigned int depthOffset;
- unsigned int depthPitch;
- void *zbFree, *bbFree; /* Cookies for freeing buffers */
ENGPACKET zClearPacket, cbClearPacket;
-
- /* Drawable, cliprect and scissor information
- */
- GLint drawOffset, drawPitch;
+ /* XXX These don't belong here. They should be per-drawable state. */
+ struct sis_renderbuffer front;
+ struct sis_renderbuffer back;
+ struct sis_renderbuffer depth;
+ struct sis_renderbuffer stencil; /* mirrors depth */
/* Mirrors of some DRI state
*/
@@ -394,9 +399,10 @@ struct sis_context
*(volatile GLuint *)(smesa->IOBase + 0x8b60) = 0xffffffff; \
}
-#define sis_fatal_error(msg) \
+#define sis_fatal_error(...) \
do { \
- fprintf(stderr, "[%s:%d]: %s", __FILE__, __LINE__, msg); \
+ fprintf(stderr, "[%s:%d]:", __FILE__, __LINE__); \
+ fprintf(stderr, __VA_ARGS__); \
exit(-1); \
} while (0)
@@ -422,6 +428,9 @@ extern GLboolean sisCreateContext( const __GLcontextModes *glVisual,
void *sharedContextPrivate );
extern void sisDestroyContext( __DRIcontextPrivate * );
+void sisReAllocateBuffers(GLcontext *ctx, GLframebuffer *drawbuffer,
+ GLuint width, GLuint height);
+
extern GLboolean sisMakeCurrent( __DRIcontextPrivate *driContextPriv,
__DRIdrawablePrivate *driDrawPriv,
__DRIdrawablePrivate *driReadPriv );
diff --git a/src/mesa/drivers/dri/sis/sis_dd.c b/src/mesa/drivers/dri/sis/sis_dd.c
index 4e64c17b3d3..e144a936f26 100644
--- a/src/mesa/drivers/dri/sis/sis_dd.c
+++ b/src/mesa/drivers/dri/sis/sis_dd.c
@@ -37,11 +37,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "sis_dd.h"
#include "sis_lock.h"
#include "sis_alloc.h"
+#include "sis_span.h"
#include "sis_state.h"
#include "sis_tris.h"
#include "swrast/swrast.h"
#include "framebuffer.h"
+#include "renderbuffer.h"
#include "utils.h"
@@ -111,53 +113,139 @@ sisFinish( GLcontext *ctx )
UNLOCK_HARDWARE();
}
+static void
+sisDeleteRenderbuffer(struct gl_renderbuffer *rb)
+{
+ /* Don't free() since we're contained in sis_context struct. */
+}
+
+static GLboolean
+sisRenderbufferStorage(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ rb->Width = width;
+ rb->Height = height;
+ rb->InternalFormat = internalFormat;
+ return GL_TRUE;
+}
+
+static void
+sisInitRenderbuffer(struct gl_renderbuffer *rb, GLenum format)
+{
+ const GLuint name = 0;
+
+ _mesa_init_renderbuffer(rb, name);
+
+ /* Make sure we're using a null-valued GetPointer routine */
+ assert(rb->GetPointer(NULL, rb, 0, 0) == NULL);
+
+ rb->InternalFormat = format;
+
+ if (format == GL_RGBA) {
+ /* Color */
+ rb->_BaseFormat = GL_RGBA;
+ rb->DataType = GL_UNSIGNED_BYTE;
+ }
+ else if (format == GL_DEPTH_COMPONENT16) {
+ /* Depth */
+ rb->_BaseFormat = GL_DEPTH_COMPONENT;
+ /* we always Get/Put 32-bit Z values */
+ rb->DataType = GL_UNSIGNED_INT;
+ }
+ else if (format == GL_DEPTH_COMPONENT24) {
+ /* Depth */
+ rb->_BaseFormat = GL_DEPTH_COMPONENT;
+ /* we always Get/Put 32-bit Z values */
+ rb->DataType = GL_UNSIGNED_INT;
+ }
+ else {
+ /* Stencil */
+ ASSERT(format == GL_STENCIL_INDEX8);
+ rb->_BaseFormat = GL_STENCIL_INDEX;
+ rb->DataType = GL_UNSIGNED_BYTE;
+ }
+
+ rb->Delete = sisDeleteRenderbuffer;
+ rb->AllocStorage = sisRenderbufferStorage;
+}
+
void
-sisUpdateBufferSize( sisContextPtr smesa )
+sisUpdateBufferSize(sisContextPtr smesa)
{
__GLSiSHardware *current = &smesa->current;
__GLSiSHardware *prev = &smesa->prev;
- GLuint z_depth;
+ struct gl_framebuffer *fb = smesa->glCtx->DrawBuffer;
- /* XXX Should get the base offset of the frontbuffer from the X Server */
- smesa->frontOffset = smesa->driDrawable->x * smesa->bytesPerPixel +
- smesa->driDrawable->y * smesa->frontPitch;
+ if (!smesa->front.Base.InternalFormat) {
+ /* do one-time init for the renderbuffers */
+ sisInitRenderbuffer(&smesa->front.Base, GL_RGBA);
+ sisSetSpanFunctions(&smesa->front, &fb->Visual);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &smesa->front.Base);
+
+ if (fb->Visual.doubleBufferMode) {
+ sisInitRenderbuffer(&smesa->back.Base, GL_RGBA);
+ sisSetSpanFunctions(&smesa->back, &fb->Visual);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &smesa->back.Base);
+ }
+
+ if (smesa->glCtx->Visual.depthBits > 0) {
+ sisInitRenderbuffer(&smesa->depth.Base,
+ (smesa->glCtx->Visual.depthBits == 16
+ ? GL_DEPTH_COMPONENT16 : GL_DEPTH_COMPONENT24));
+ sisSetSpanFunctions(&smesa->depth, &fb->Visual);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &smesa->depth.Base);
+ }
+
+ if (smesa->glCtx->Visual.stencilBits > 0) {
+ sisInitRenderbuffer(&smesa->stencil.Base, GL_STENCIL_INDEX8_EXT);
+ sisSetSpanFunctions(&smesa->stencil, &fb->Visual);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &smesa->stencil.Base);
+ }
+ }
+
+ /* Make sure initialization did what we think it should */
+ assert(smesa->front.Base.InternalFormat);
+ assert(smesa->front.Base.AllocStorage);
+ if (fb->Visual.doubleBufferMode) {
+ assert(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer);
+ assert(smesa->front.Base.AllocStorage);
+ }
+ if (fb->Visual.depthBits) {
+ assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer);
+ assert(smesa->depth.Base.AllocStorage);
+ }
if ( smesa->width == smesa->driDrawable->w &&
- smesa->height == smesa->driDrawable->h )
+ smesa->height == smesa->driDrawable->h )
{
return;
}
+ smesa->front.bpp = smesa->bytesPerPixel * 8;
+ /* Front pitch set on context create */
+ smesa->front.size = smesa->front.pitch * smesa->driDrawable->h;
+ /* XXX Should get the base offset of the frontbuffer from the X Server */
+ smesa->front.offset = smesa->driDrawable->x * smesa->bytesPerPixel +
+ smesa->driDrawable->y * smesa->front.pitch;
+ smesa->front.map = (char *) smesa->driScreen->pFB;
+
smesa->width = smesa->driDrawable->w;
smesa->height = smesa->driDrawable->h;
smesa->bottom = smesa->height - 1;
- if ( smesa->backbuffer )
+ if (smesa->back.offset)
sisFreeBackbuffer( smesa );
- if ( smesa->depthbuffer )
+ if (smesa->depth.offset)
sisFreeZStencilBuffer( smesa );
-
+
if ( smesa->glCtx->Visual.depthBits > 0 )
sisAllocZStencilBuffer( smesa );
if ( smesa->glCtx->Visual.doubleBufferMode )
sisAllocBackbuffer( smesa );
- switch (smesa->zFormat)
- {
- case SiS_ZFORMAT_Z16:
- z_depth = 2;
- break;
- case SiS_ZFORMAT_Z32:
- case SiS_ZFORMAT_S8Z24:
- z_depth = 4;
- break;
- default:
- sis_fatal_error("Bad Z format\n");
- }
-
current->hwZ &= ~MASK_ZBufferPitch;
- current->hwZ |= smesa->width * z_depth >> 2;
- current->hwOffsetZ = smesa->depthOffset >> 2;
+ current->hwZ |= smesa->depth.pitch >> 2;
+ current->hwOffsetZ = smesa->depth.offset >> 2;
if ((current->hwOffsetZ != prev->hwOffsetZ) || (current->hwZ != prev->hwZ)) {
prev->hwOffsetZ = current->hwOffsetZ;
@@ -174,7 +262,6 @@ void
sisInitDriverFuncs( struct dd_function_table *functions )
{
functions->GetBufferSize = sisGetBufferSize;
- functions->ResizeBuffers = _mesa_resize_framebuffer;
functions->GetString = sisGetString;
functions->Finish = sisFinish;
functions->Flush = sisFlush;
diff --git a/src/mesa/drivers/dri/sis/sis_screen.c b/src/mesa/drivers/dri/sis/sis_screen.c
index 3e6fe5a4df2..362c8696e3a 100644
--- a/src/mesa/drivers/dri/sis/sis_screen.c
+++ b/src/mesa/drivers/dri/sis/sis_screen.c
@@ -143,7 +143,6 @@ sisCreateScreen( __DRIscreenPrivate *sPriv )
sisScreen->screenX = sisDRIPriv->width;
sisScreen->screenY = sisDRIPriv->height;
sisScreen->cpp = sisDRIPriv->bytesPerPixel;
- sisScreen->irqEnabled = sisDRIPriv->bytesPerPixel;
sisScreen->deviceID = sisDRIPriv->deviceID;
sisScreen->AGPCmdBufOffset = sisDRIPriv->AGPCmdBufOffset;
sisScreen->AGPCmdBufSize = sisDRIPriv->AGPCmdBufSize;
@@ -206,70 +205,21 @@ sisCreateBuffer( __DRIscreenPrivate *driScrnPriv,
GLboolean isPixmap )
{
sisScreenPtr screen = (sisScreenPtr) driScrnPriv->private;
+ struct gl_framebuffer *fb;
if (isPixmap)
return GL_FALSE; /* not implemented */
- {
- struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
-
- /* XXX double-check the Offset/Pitch parameters! */
- {
- driRenderbuffer *frontRb
- = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp,
- 0, driScrnPriv->fbStride, driDrawPriv);
- sisSetSpanFunctions(frontRb, mesaVis);
- _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
- }
-
- if (mesaVis->doubleBufferMode) {
- driRenderbuffer *backRb
- = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp,
- 0, driScrnPriv->fbStride, driDrawPriv);
- sisSetSpanFunctions(backRb, mesaVis);
- _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
- }
+ fb = _mesa_create_framebuffer(mesaVis);
- if (mesaVis->depthBits == 16) {
- driRenderbuffer *depthRb
- = driNewRenderbuffer(GL_DEPTH_COMPONENT16, NULL, screen->cpp,
- 0, driScrnPriv->fbStride, driDrawPriv);
- sisSetSpanFunctions(depthRb, mesaVis);
- _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
- }
- else if (mesaVis->depthBits == 24) {
- driRenderbuffer *depthRb
- = driNewRenderbuffer(GL_DEPTH_COMPONENT24, NULL, screen->cpp,
- 0, driScrnPriv->fbStride, driDrawPriv);
- sisSetSpanFunctions(depthRb, mesaVis);
- _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
- }
- else if (mesaVis->depthBits == 32) {
- driRenderbuffer *depthRb
- = driNewRenderbuffer(GL_DEPTH_COMPONENT32, NULL, screen->cpp,
- 0, driScrnPriv->fbStride, driDrawPriv);
- sisSetSpanFunctions(depthRb, mesaVis);
- _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
- }
-
- /* no h/w stencil?
- if (mesaVis->stencilBits > 0) {
- driRenderbuffer *stencilRb
- = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT);
- sisSetSpanFunctions(stencilRb, mesaVis);
- _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
- }
- */
-
- _mesa_add_soft_renderbuffers(fb,
- GL_FALSE, /* color */
- GL_FALSE, /* depth */
- mesaVis->stencilBits > 0,
- mesaVis->accumRedBits > 0,
- GL_FALSE, /* alpha */
- GL_FALSE /* aux */);
- driDrawPriv->driverPrivate = (void *) fb;
- }
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
return (driDrawPriv->driverPrivate != NULL);
}
@@ -312,11 +262,11 @@ static void sisCopyBuffer( __DRIdrawablePrivate *dPriv )
LOCK_HARDWARE();
- stEngPacket.dwSrcBaseAddr = smesa->backOffset;
- stEngPacket.dwSrcPitch = smesa->backPitch |
+ stEngPacket.dwSrcBaseAddr = smesa->back.offset;
+ stEngPacket.dwSrcPitch = smesa->back.pitch |
((smesa->bytesPerPixel == 2) ? 0x80000000 : 0xc0000000);
stEngPacket.dwDestBaseAddr = 0;
- stEngPacket.wDestPitch = smesa->frontPitch;
+ stEngPacket.wDestPitch = smesa->front.pitch;
/* TODO: set maximum value? */
stEngPacket.wDestHeight = smesa->virtualY;
diff --git a/src/mesa/drivers/dri/sis/sis_screen.h b/src/mesa/drivers/dri/sis/sis_screen.h
index 068c0410da4..c3e9ef48764 100644
--- a/src/mesa/drivers/dri/sis/sis_screen.h
+++ b/src/mesa/drivers/dri/sis/sis_screen.h
@@ -46,7 +46,6 @@ typedef struct {
unsigned int AGPCmdBufSize;
int deviceID;
- int irqEnabled;
int cpp;
unsigned int screenX, screenY;
diff --git a/src/mesa/drivers/dri/sis/sis_span.c b/src/mesa/drivers/dri/sis/sis_span.c
index bdefaf10189..ea6db6781d4 100644
--- a/src/mesa/drivers/dri/sis/sis_span.c
+++ b/src/mesa/drivers/dri/sis/sis_span.c
@@ -44,16 +44,18 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define LOCAL_VARS \
sisContextPtr smesa = SIS_CONTEXT(ctx); \
__DRIdrawablePrivate *dPriv = smesa->driDrawable; \
- driRenderbuffer *drb = (driRenderbuffer *) rb; \
- GLuint pitch = drb->pitch; \
- char *buf = (char *)(smesa->FbBase + drb->offset); \
+ struct sis_renderbuffer *srb = (struct sis_renderbuffer *) rb; \
+ GLuint pitch = srb->pitch; \
+ char *buf = srb->map; \
GLuint p; \
- (void) buf; (void) p
+ (void) buf; (void) p;
+
#define LOCAL_DEPTH_VARS \
sisContextPtr smesa = SIS_CONTEXT(ctx); \
__DRIdrawablePrivate *dPriv = smesa->driDrawable; \
- char *buf = smesa->depthbuffer; \
+ struct sis_renderbuffer *srb = (struct sis_renderbuffer *) rb; \
+ char *buf = srb->map;
#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
@@ -84,10 +86,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* 16 bit depthbuffer functions.
*/
#define WRITE_DEPTH( _x, _y, d ) \
- *(GLushort *)(buf + (_x)*2 + (_y)*smesa->depthPitch) = d;
+ *(GLushort *)(buf + (_x)*2 + (_y)*srb->pitch) = d;
#define READ_DEPTH( d, _x, _y ) \
- d = *(GLushort *)(buf + (_x)*2 + (_y)*smesa->depthPitch);
+ d = *(GLushort *)(buf + (_x)*2 + (_y)*srb->pitch);
#define TAG(x) sis##x##_z16
#include "depthtmp.h"
@@ -96,10 +98,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* 32 bit depthbuffer functions.
*/
#define WRITE_DEPTH( _x, _y, d ) \
- *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) = d;
+ *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) = d;
#define READ_DEPTH( d, _x, _y ) \
- d = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch);
+ d = *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch);
#define TAG(x) sis##x##_z32
#include "depthtmp.h"
@@ -108,28 +110,28 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* 8/24 bit interleaved depth/stencil functions
*/
#define WRITE_DEPTH( _x, _y, d ) { \
- GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch); \
+ GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch); \
tmp &= 0xff000000; \
tmp |= (d & 0x00ffffff); \
- *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) = tmp; \
+ *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) = tmp; \
}
-#define READ_DEPTH( d, _x, _y ) { \
- d = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) & 0x00ffffff; \
+#define READ_DEPTH( d, _x, _y ) { \
+ d = *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) & 0x00ffffff; \
}
#define TAG(x) sis##x##_z24_s8
#include "depthtmp.h"
#define WRITE_STENCIL( _x, _y, d ) { \
- GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch); \
+ GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depth.pitch); \
tmp &= 0x00ffffff; \
tmp |= (d << 24); \
- *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) = tmp; \
+ *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) = tmp; \
}
#define READ_STENCIL( d, _x, _y ) \
- d = (*(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) & 0xff000000) >> 24;
+ d = (*(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) & 0xff000000) >> 24;
#define TAG(x) sis##x##_z24_s8
#include "stenciltmp.h"
@@ -167,26 +169,26 @@ sisDDInitSpanFuncs( GLcontext *ctx )
* Plug in the Get/Put routines for the given driRenderbuffer.
*/
void
-sisSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+sisSetSpanFunctions(struct sis_renderbuffer *srb, const GLvisual *vis)
{
- if (drb->Base.InternalFormat == GL_RGBA) {
+ if (srb->Base.InternalFormat == GL_RGBA) {
if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
- sisInitPointers_RGB565( &drb->Base );
+ sisInitPointers_RGB565( &srb->Base );
}
else {
- sisInitPointers_ARGB8888( &drb->Base );
+ sisInitPointers_ARGB8888( &srb->Base );
}
}
- else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
- sisInitDepthPointers_z16(&drb->Base);
+ else if (srb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ sisInitDepthPointers_z16(&srb->Base);
}
- else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
- sisInitDepthPointers_z24_s8(&drb->Base);
+ else if (srb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ sisInitDepthPointers_z24_s8(&srb->Base);
}
- else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
- sisInitDepthPointers_z32(&drb->Base);
+ else if (srb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
+ sisInitDepthPointers_z32(&srb->Base);
}
- else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
- sisInitStencilPointers_z24_s8(&drb->Base);
+ else if (srb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ sisInitStencilPointers_z24_s8(&srb->Base);
}
}
diff --git a/src/mesa/drivers/dri/sis/sis_span.h b/src/mesa/drivers/dri/sis/sis_span.h
index 7c73bc6d3ad..4b0add2ac2b 100644
--- a/src/mesa/drivers/dri/sis/sis_span.h
+++ b/src/mesa/drivers/dri/sis/sis_span.h
@@ -41,6 +41,6 @@ extern void sisSpanRenderFinish( GLcontext *ctx );
extern void sisDDInitSpanFuncs( GLcontext *ctx );
extern void
-sisSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+sisSetSpanFunctions(struct sis_renderbuffer *srb, const GLvisual *vis);
#endif
diff --git a/src/mesa/drivers/dri/sis/sis_state.c b/src/mesa/drivers/dri/sis/sis_state.c
index 8349c42d297..01688c2fda5 100644
--- a/src/mesa/drivers/dri/sis/sis_state.c
+++ b/src/mesa/drivers/dri/sis/sis_state.c
@@ -521,19 +521,21 @@ void sisDDDrawBuffer( GLcontext *ctx, GLenum mode )
sisContextPtr smesa = SIS_CONTEXT(ctx);
__GLSiSHardware *prev = &smesa->prev;
__GLSiSHardware *current = &smesa->current;
- int pitch;
/*
* _DrawDestMask is easier to cope with than <mode>.
*/
+ current->hwDstSet &= ~MASK_DstBufferPitch;
switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
case BUFFER_BIT_FRONT_LEFT:
FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE );
- pitch = smesa->frontPitch;
+ current->hwOffsetDest = smesa->front.offset >> 1;
+ current->hwDstSet |= smesa->front.pitch >> 2;
break;
case BUFFER_BIT_BACK_LEFT:
FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE );
- pitch = smesa->backPitch;
+ current->hwOffsetDest = smesa->back.offset >> 1;
+ current->hwDstSet |= smesa->back.pitch >> 2;
break;
default:
/* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
@@ -541,10 +543,6 @@ void sisDDDrawBuffer( GLcontext *ctx, GLenum mode )
return;
}
- current->hwOffsetDest = (smesa->drawOffset) >> 1;
- current->hwDstSet &= ~MASK_DstBufferPitch;
- current->hwDstSet |= pitch >> 2;
-
if (current->hwDstSet != prev->hwDstSet) {
prev->hwDstSet = current->hwDstSet;
smesa->GlobalFlag |= GFLAG_DESTSETTING;
@@ -598,7 +596,7 @@ sisDDEnable( GLcontext * ctx, GLenum cap, GLboolean state )
current->hwCapEnable &= ~MASK_CullEnable;
break;
case GL_DEPTH_TEST:
- if (state && smesa->depthbuffer)
+ if (state && smesa->depth.offset != 0)
current->hwCapEnable |= MASK_ZTestEnable;
else
current->hwCapEnable &= ~MASK_ZTestEnable;
@@ -840,6 +838,7 @@ void sisDDInitStateFuncs( GLcontext *ctx )
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.ResizeBuffers = sisReAllocateBuffers;
/* Swrast hooks for imaging extensions:
*/
ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
diff --git a/src/mesa/drivers/dri/sis/sis_texstate.c b/src/mesa/drivers/dri/sis/sis_texstate.c
index a18ad06bd48..b5da62cd7c5 100644
--- a/src/mesa/drivers/dri/sis/sis_texstate.c
+++ b/src/mesa/drivers/dri/sis/sis_texstate.c
@@ -122,8 +122,10 @@ sis_set_texture_env0( GLcontext *ctx, struct gl_texture_object *texObj,
break;
case GL_BLEND:
+#if 1 /* XXX Blending broken */
FALLBACK(smesa, SIS_FALLBACK_TEXENV0, 1);
-#if 0 /* XXX Blending broken */
+#else
+ FALLBACK(smesa, SIS_FALLBACK_TEXENV0, 0);
current->hwTexEnvColor =
((GLint) (texture_unit->EnvColor[3])) << 24 |
((GLint) (texture_unit->EnvColor[0])) << 16 |