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.
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;
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;
void
sisFreeBackbuffer( sisContextPtr smesa )
{
- sisFreeFB( smesa, smesa->bbFree );
- smesa->backbuffer = NULL;
+ sisFreeFB(smesa, smesa->back.handle);
+ smesa->back.map = NULL;
+ smesa->back.offset = 0;
}
}
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);
}
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;
#include "matrix.h"
#include "extensions.h"
#include "utils.h"
+#include "framebuffer.h"
#include "drivers/common/driverfuncs.h"
}
}
+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,
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);
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 */
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;
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 );
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
unsigned char *IOBase;
unsigned char *FbBase;
unsigned int displayWidth;
- unsigned int frontOffset;
- unsigned int frontPitch;
/* HW RGBA layout */
unsigned int redMask, greenMask, blueMask, alphaMask;
/* 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
*/
*(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)
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 );
#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"
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;
sisInitDriverFuncs( struct dd_function_table *functions )
{
functions->GetBufferSize = sisGetBufferSize;
- functions->ResizeBuffers = _mesa_resize_framebuffer;
functions->GetString = sisGetString;
functions->Finish = sisFinish;
functions->Flush = sisFlush;
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;
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);
}
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;
unsigned int AGPCmdBufSize;
int deviceID;
- int irqEnabled;
int cpp;
unsigned int screenX, screenY;
#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
/* 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"
/* 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"
/* 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"
* 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);
}
}
extern void sisDDInitSpanFuncs( GLcontext *ctx );
extern void
-sisSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+sisSetSpanFunctions(struct sis_renderbuffer *srb, const GLvisual *vis);
#endif
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 */
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;
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;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.ResizeBuffers = sisReAllocateBuffers;
/* Swrast hooks for imaging extensions:
*/
ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
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 |