diff options
Diffstat (limited to 'src/mesa/drivers/dri/mga')
-rw-r--r-- | src/mesa/drivers/dri/mga/mga_xmesa.c | 82 | ||||
-rw-r--r-- | src/mesa/drivers/dri/mga/mga_xmesa.h | 11 | ||||
-rw-r--r-- | src/mesa/drivers/dri/mga/mgadd.c | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/mga/mgaioctl.c | 16 | ||||
-rw-r--r-- | src/mesa/drivers/dri/mga/mgaspan.c | 59 | ||||
-rw-r--r-- | src/mesa/drivers/dri/mga/mgaspan.h | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/mga/mgastate.c | 6 |
7 files changed, 163 insertions, 20 deletions
diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c index 9a3b331e8c3..6312997ce64 100644 --- a/src/mesa/drivers/dri/mga/mga_xmesa.c +++ b/src/mesa/drivers/dri/mga/mga_xmesa.c @@ -34,6 +34,8 @@ #include "matrix.h" #include "simple_list.h" #include "imports.h" +#include "framebuffer.h" +#include "renderbuffer.h" #include "swrast/swrast.h" #include "swrast_setup/swrast_setup.h" @@ -55,7 +57,6 @@ #include "mga_xmesa.h" #include "mga_dri.h" - #include "utils.h" #include "vblank.h" @@ -721,6 +722,8 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv, const __GLcontextModes *mesaVis, GLboolean isPixmap ) { + mgaScreenPrivate *screen = (mgaScreenPrivate *) driScrnPriv->private; + if (isPixmap) { return GL_FALSE; /* not implemented */ } @@ -728,12 +731,81 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv, GLboolean swStencil = (mesaVis->stencilBits > 0 && mesaVis->depthBits != 24); +#if 0 driDrawPriv->driverPrivate = (void *) _mesa_create_framebuffer(mesaVis, GL_FALSE, /* software depth buffer? */ swStencil, mesaVis->accumRedBits > 0, mesaVis->alphaBits > 0 ); +#else + struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis); + + { + driRenderbuffer *frontRb + = driNewRenderbuffer(GL_RGBA, screen->cpp, + screen->frontOffset, screen->frontPitch); + mgaSetSpanFunctions(frontRb, mesaVis); + _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base); + } + + if (mesaVis->doubleBufferMode) { + driRenderbuffer *backRb + = driNewRenderbuffer(GL_RGBA, screen->cpp, + screen->backOffset, screen->backPitch); + mgaSetSpanFunctions(backRb, mesaVis); + _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base); + } + + if (mesaVis->depthBits == 16) { + driRenderbuffer *depthRb + = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp, + screen->depthOffset, screen->depthPitch); + mgaSetSpanFunctions(depthRb, mesaVis); + _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); + } + else if (mesaVis->depthBits == 24) { + /* XXX is this right? */ + if (mesaVis->stencilBits) { + driRenderbuffer *depthRb + = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp, + screen->depthOffset, screen->depthPitch); + mgaSetSpanFunctions(depthRb, mesaVis); + _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); + } + else { + driRenderbuffer *depthRb + = driNewRenderbuffer(GL_DEPTH_COMPONENT32, screen->cpp, + screen->depthOffset, screen->depthPitch); + mgaSetSpanFunctions(depthRb, mesaVis); + _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); + } + } + else if (mesaVis->depthBits == 32) { + driRenderbuffer *depthRb + = driNewRenderbuffer(GL_DEPTH_COMPONENT32, screen->cpp, + screen->depthOffset, screen->depthPitch); + mgaSetSpanFunctions(depthRb, mesaVis); + _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); + } + + if (mesaVis->stencilBits > 0 && !swStencil) { + driRenderbuffer *stencilRb + = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp, + screen->depthOffset, screen->depthPitch); + mgaSetSpanFunctions(stencilRb, mesaVis); + _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base); + } + + _mesa_add_soft_renderbuffers(fb, + GL_FALSE, /* color */ + GL_FALSE, /* depth */ + swStencil, + mesaVis->accumRedBits > 0, + GL_FALSE, /* alpha */ + GL_FALSE /* aux */); + driDrawPriv->driverPrivate = (void *) fb; +#endif return (driDrawPriv->driverPrivate != NULL); } @@ -799,12 +871,12 @@ mgaMakeCurrent(__DRIcontextPrivate *driContextPriv, mmesa->driReadable = driReadPriv; - _mesa_make_current2(mmesa->glCtx, - (GLframebuffer *) driDrawPriv->driverPrivate, - (GLframebuffer *) driReadPriv->driverPrivate); + _mesa_make_current(mmesa->glCtx, + (GLframebuffer *) driDrawPriv->driverPrivate, + (GLframebuffer *) driReadPriv->driverPrivate); } else { - _mesa_make_current(NULL, NULL); + _mesa_make_current(NULL, NULL, NULL); } return GL_TRUE; diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.h b/src/mesa/drivers/dri/mga/mga_xmesa.h index f78f806c771..51cc1295808 100644 --- a/src/mesa/drivers/dri/mga/mga_xmesa.h +++ b/src/mesa/drivers/dri/mga/mga_xmesa.h @@ -83,6 +83,17 @@ typedef struct mga_screen_private_s { } mgaScreenPrivate; +/** + * mgaRenderbuffer, derived from Mesa's gl_renderbuffer + */ +typedef struct { + struct gl_renderbuffer Base; + /* XXX per-window info should go here */ + int foo, bar; +} mgaRenderbuffer; + + + #include "mgacontext.h" extern void mgaGetLock( mgaContextPtr mmesa, GLuint flags ); diff --git a/src/mesa/drivers/dri/mga/mgadd.c b/src/mesa/drivers/dri/mga/mgadd.c index e8436f23846..7310641efa3 100644 --- a/src/mesa/drivers/dri/mga/mgadd.c +++ b/src/mesa/drivers/dri/mga/mgadd.c @@ -28,6 +28,7 @@ #include "mtypes.h" +#include "framebuffer.h" #include "mm.h" #include "mgacontext.h" @@ -92,6 +93,6 @@ static void mgaBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height) void mgaInitDriverFuncs( struct dd_function_table *functions ) { functions->GetBufferSize = mgaBufferSize; - functions->ResizeBuffers = _swrast_alloc_buffers; + functions->ResizeBuffers = _mesa_resize_framebuffer; functions->GetString = mgaGetString; } diff --git a/src/mesa/drivers/dri/mga/mgaioctl.c b/src/mesa/drivers/dri/mga/mgaioctl.c index 097fcd6cbd1..29c06dcbbc4 100644 --- a/src/mesa/drivers/dri/mga/mgaioctl.c +++ b/src/mesa/drivers/dri/mga/mgaioctl.c @@ -175,30 +175,30 @@ mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all, FLUSH_BATCH( mmesa ); - if ( mask & DD_FRONT_LEFT_BIT ) { + if ( mask & BUFFER_BIT_FRONT_LEFT ) { flags |= MGA_FRONT; color_mask = mmesa->setup.plnwt; - mask &= ~DD_FRONT_LEFT_BIT; + mask &= ~BUFFER_BIT_FRONT_LEFT; } - if ( mask & DD_BACK_LEFT_BIT ) { + if ( mask & BUFFER_BIT_BACK_LEFT ) { flags |= MGA_BACK; color_mask = mmesa->setup.plnwt; - mask &= ~DD_BACK_LEFT_BIT; + mask &= ~BUFFER_BIT_BACK_LEFT; } - if ( (mask & DD_DEPTH_BIT) && ctx->Depth.Mask ) { + if ( (mask & BUFFER_BIT_DEPTH) && ctx->Depth.Mask ) { flags |= MGA_DEPTH; clear_depth = (mmesa->ClearDepth & mmesa->depth_clear_mask); depth_mask |= mmesa->depth_clear_mask; - mask &= ~DD_DEPTH_BIT; + mask &= ~BUFFER_BIT_DEPTH; } - if ( (mask & DD_STENCIL_BIT) && mmesa->hw_stencil ) { + if ( (mask & BUFFER_BIT_STENCIL) && mmesa->hw_stencil ) { flags |= MGA_DEPTH; clear_depth |= (ctx->Stencil.Clear & mmesa->stencil_clear_mask); depth_mask |= mmesa->stencil_clear_mask; - mask &= ~DD_STENCIL_BIT; + mask &= ~BUFFER_BIT_STENCIL; } if ( flags ) { diff --git a/src/mesa/drivers/dri/mga/mgaspan.c b/src/mesa/drivers/dri/mga/mgaspan.c index 4b2c5cd6829..4279dfd95bc 100644 --- a/src/mesa/drivers/dri/mga/mgaspan.c +++ b/src/mesa/drivers/dri/mga/mgaspan.c @@ -204,9 +204,9 @@ static void mgaDDSetBuffer(GLcontext *ctx, GLframebuffer *buffer, mgaContextPtr mmesa = MGA_CONTEXT(ctx); unsigned int offset; - assert((bufferBit == DD_FRONT_LEFT_BIT) || (bufferBit == DD_BACK_LEFT_BIT)); + assert((bufferBit == BUFFER_BIT_FRONT_LEFT) || (bufferBit == BUFFER_BIT_BACK_LEFT)); - offset = (bufferBit == DD_FRONT_LEFT_BIT) + offset = (bufferBit == BUFFER_BIT_FRONT_LEFT) ? mmesa->mgaScreen->frontOffset : mmesa->mgaScreen->backOffset; @@ -237,15 +237,17 @@ void mgaDDInitSpanFuncs( GLcontext *ctx ) switch (mmesa->mgaScreen->cpp) { case 2: +#if 0 mgaInitPointers_565( swdd ); - swdd->ReadDepthSpan = mgaReadDepthSpan_16; swdd->WriteDepthSpan = mgaWriteDepthSpan_16; swdd->ReadDepthPixels = mgaReadDepthPixels_16; swdd->WriteDepthPixels = mgaWriteDepthPixels_16; +#endif break; case 4: +#if 0 mgaInitPointers_8888( swdd ); if (!mmesa->hw_stencil) { @@ -264,6 +266,57 @@ void mgaDDInitSpanFuncs( GLcontext *ctx ) swdd->ReadStencilPixels = mgaReadStencilPixels_24_8; swdd->WriteStencilPixels = mgaWriteStencilPixels_24_8; } +#endif break; } } + + + +/** + * Plug in the Get/Put routines for the given driRenderbuffer. + */ +void +mgaSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis) +{ + if (drb->Base.InternalFormat == GL_RGBA) { + if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) { + mgaInitPointers_565(&drb->Base); + } + else { + mgaInitPointers_8888(&drb->Base); + } + } + else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) { + drb->Base.GetRow = mgaReadDepthSpan_16; + drb->Base.GetValues = mgaReadDepthPixels_16; + drb->Base.PutRow = mgaWriteDepthSpan_16; + drb->Base.PutMonoRow = mgaWriteMonoDepthSpan_16; + drb->Base.PutValues = mgaWriteDepthPixels_16; + drb->Base.PutMonoValues = NULL; + } + else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) { + drb->Base.GetRow = mgaReadDepthSpan_24_8; + drb->Base.GetValues = mgaReadDepthPixels_24_8; + drb->Base.PutRow = mgaWriteDepthSpan_24_8; + drb->Base.PutMonoRow = mgaWriteMonoDepthSpan_24_8; + drb->Base.PutValues = mgaWriteDepthPixels_24_8; + drb->Base.PutMonoValues = NULL; + } + else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT32) { + drb->Base.GetRow = mgaReadDepthSpan_32; + drb->Base.GetValues = mgaReadDepthPixels_32; + drb->Base.PutRow = mgaWriteDepthSpan_32; + drb->Base.PutMonoRow = mgaWriteMonoDepthSpan_32; + drb->Base.PutValues = mgaWriteDepthPixels_32; + drb->Base.PutMonoValues = NULL; + } + else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) { + drb->Base.GetRow = mgaReadStencilSpan_24_8; + drb->Base.GetValues = mgaReadStencilPixels_24_8; + drb->Base.PutRow = mgaWriteStencilSpan_24_8; + drb->Base.PutMonoRow = mgaWriteMonoStencilSpan_24_8; + drb->Base.PutValues = mgaWriteStencilPixels_24_8; + drb->Base.PutMonoValues = NULL; + } +} diff --git a/src/mesa/drivers/dri/mga/mgaspan.h b/src/mesa/drivers/dri/mga/mgaspan.h index 80583daca2d..f133a51c083 100644 --- a/src/mesa/drivers/dri/mga/mgaspan.h +++ b/src/mesa/drivers/dri/mga/mgaspan.h @@ -29,6 +29,12 @@ #ifndef _MGA_SPAN_H #define _MGA_SPAN_H +#include "drirenderbuffer.h" + extern void mgaDDInitSpanFuncs( GLcontext *ctx ); +extern void +mgaSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis); + + #endif diff --git a/src/mesa/drivers/dri/mga/mgastate.c b/src/mesa/drivers/dri/mga/mgastate.c index 69cc0f33a70..72d5c9fb082 100644 --- a/src/mesa/drivers/dri/mga/mgastate.c +++ b/src/mesa/drivers/dri/mga/mgastate.c @@ -825,15 +825,15 @@ static void mgaDDDrawBuffer(GLcontext *ctx, GLenum mode ) /* * _DrawDestMask is easier to cope with than <mode>. */ - switch ( ctx->Color._DrawDestMask[0] ) { - case DD_FRONT_LEFT_BIT: + switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) { + case BUFFER_BIT_FRONT_LEFT: mmesa->setup.dstorg = mmesa->mgaScreen->frontOffset; mmesa->dirty |= MGA_UPLOAD_CONTEXT; mmesa->draw_buffer = MGA_FRONT; mgaXMesaSetFrontClipRects( mmesa ); FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_FALSE ); break; - case DD_BACK_LEFT_BIT: + case BUFFER_BIT_BACK_LEFT: mmesa->setup.dstorg = mmesa->mgaScreen->backOffset; mmesa->draw_buffer = MGA_BACK; mmesa->dirty |= MGA_UPLOAD_CONTEXT; |