diff options
author | Brian Paul <[email protected]> | 2005-05-04 20:11:35 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2005-05-04 20:11:35 +0000 |
commit | e4b2356c07d31fbeeabb13b2fb47db703b473080 (patch) | |
tree | d8b7f1c7c9e7c84d84349485f942dd205dd4c16d /src/mesa/drivers/dri/r128 | |
parent | ebef61f5c0950572f9c6a81b08f447957461675c (diff) |
Major check-in of changes for GL_EXT_framebuffer_object extension.
Main driver impacts:
- new code for creating the Mesa GLframebuffer
- new span/pixel read/write code
Some drivers not yet updated/tested.
Diffstat (limited to 'src/mesa/drivers/dri/r128')
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_context.c | 8 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_dd.c | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_ioctl.c | 16 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_lock.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_screen.c | 49 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_span.c | 53 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_span.h | 5 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_state.c | 8 |
8 files changed, 124 insertions, 20 deletions
diff --git a/src/mesa/drivers/dri/r128/r128_context.c b/src/mesa/drivers/dri/r128/r128_context.c index 2f417d9097f..587cd0496b6 100644 --- a/src/mesa/drivers/dri/r128/r128_context.c +++ b/src/mesa/drivers/dri/r128/r128_context.c @@ -337,13 +337,13 @@ r128MakeCurrent( __DRIcontextPrivate *driContextPriv, driDrawableInitVBlank( driDrawPriv, newR128Ctx->vblank_flags ); newR128Ctx->driDrawable = driDrawPriv; - _mesa_make_current2( newR128Ctx->glCtx, - (GLframebuffer *) driDrawPriv->driverPrivate, - (GLframebuffer *) driReadPriv->driverPrivate ); + _mesa_make_current( newR128Ctx->glCtx, + (GLframebuffer *) driDrawPriv->driverPrivate, + (GLframebuffer *) driReadPriv->driverPrivate ); newR128Ctx->new_state |= R128_NEW_WINDOW | R128_NEW_CLIP; } else { - _mesa_make_current( 0, 0 ); + _mesa_make_current( NULL, NULL, NULL ); } return GL_TRUE; diff --git a/src/mesa/drivers/dri/r128/r128_dd.c b/src/mesa/drivers/dri/r128/r128_dd.c index 22b68467ac2..59480b25d8f 100644 --- a/src/mesa/drivers/dri/r128/r128_dd.c +++ b/src/mesa/drivers/dri/r128/r128_dd.c @@ -40,6 +40,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "swrast/swrast.h" #include "context.h" +#include "framebuffer.h" #include "utils.h" @@ -140,7 +141,7 @@ static void r128Finish( GLcontext *ctx ) void r128InitDriverFuncs( struct dd_function_table *functions ) { functions->GetBufferSize = r128GetBufferSize; - functions->ResizeBuffers = _swrast_alloc_buffers; + functions->ResizeBuffers = _mesa_resize_framebuffer; functions->GetString = r128GetString; functions->Finish = r128Finish; functions->Flush = r128Flush; diff --git a/src/mesa/drivers/dri/r128/r128_ioctl.c b/src/mesa/drivers/dri/r128/r128_ioctl.c index 2ae0f6fa6b8..fc017329ca2 100644 --- a/src/mesa/drivers/dri/r128/r128_ioctl.c +++ b/src/mesa/drivers/dri/r128/r128_ioctl.c @@ -429,25 +429,25 @@ static void r128Clear( GLcontext *ctx, GLbitfield mask, GLboolean all, rmesa->new_state = save_state & ~R128_NEW_MASKS; } - if ( mask & DD_FRONT_LEFT_BIT ) { + if ( mask & BUFFER_BIT_FRONT_LEFT ) { flags |= R128_FRONT; - mask &= ~DD_FRONT_LEFT_BIT; + mask &= ~BUFFER_BIT_FRONT_LEFT; } - if ( mask & DD_BACK_LEFT_BIT ) { + if ( mask & BUFFER_BIT_BACK_LEFT ) { flags |= R128_BACK; - 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 |= R128_DEPTH; - mask &= ~DD_DEPTH_BIT; + mask &= ~BUFFER_BIT_DEPTH; } #if 0 /* FIXME: Add stencil support */ - if ( mask & DD_STENCIL_BIT ) { + if ( mask & BUFFER_BIT_STENCIL ) { flags |= DRM_R128_DEPTH_BUFFER; - mask &= ~DD_STENCIL_BIT; + mask &= ~BUFFER_BIT_STENCIL; } #endif diff --git a/src/mesa/drivers/dri/r128/r128_lock.c b/src/mesa/drivers/dri/r128/r128_lock.c index f4b43d56c10..ea4ccfb2ec9 100644 --- a/src/mesa/drivers/dri/r128/r128_lock.c +++ b/src/mesa/drivers/dri/r128/r128_lock.c @@ -52,7 +52,7 @@ r128UpdatePageFlipping( r128ContextPtr rmesa ) rmesa->doPageFlip = rmesa->sarea->pfAllowPageFlip; - use_back = (rmesa->glCtx->Color._DrawDestMask[0] == DD_BACK_LEFT_BIT); + use_back = (rmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT); use_back ^= (rmesa->sarea->pfCurrentPage == 1); if ( R128_DEBUG & DEBUG_VERBOSE_API ) diff --git a/src/mesa/drivers/dri/r128/r128_screen.c b/src/mesa/drivers/dri/r128/r128_screen.c index 6bef391e962..bd0585b7734 100644 --- a/src/mesa/drivers/dri/r128/r128_screen.c +++ b/src/mesa/drivers/dri/r128/r128_screen.c @@ -37,10 +37,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_context.h" #include "r128_ioctl.h" +#include "r128_span.h" #include "r128_tris.h" #include "context.h" #include "imports.h" +#include "framebuffer.h" +#include "renderbuffer.h" #include "utils.h" #include "vblank.h" @@ -260,16 +263,62 @@ r128CreateBuffer( __DRIscreenPrivate *driScrnPriv, const __GLcontextModes *mesaVis, GLboolean isPixmap ) { + r128ScreenPtr screen = (r128ScreenPtr) driScrnPriv->private; + if (isPixmap) { return GL_FALSE; /* not implemented */ } else { +#if 0 driDrawPriv->driverPrivate = (void *) _mesa_create_framebuffer( mesaVis, GL_FALSE, /* software depth buffer? */ mesaVis->stencilBits > 0, 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); + r128SetSpanFunctions(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); + r128SetSpanFunctions(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); + r128SetSpanFunctions(depthRb, mesaVis); + _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); + } + else if (mesaVis->depthBits == 24) { + driRenderbuffer *depthRb + = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp, + screen->depthOffset, screen->depthPitch); + r128SetSpanFunctions(depthRb, mesaVis); + _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->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; +#endif return (driDrawPriv->driverPrivate != NULL); } } diff --git a/src/mesa/drivers/dri/r128/r128_span.c b/src/mesa/drivers/dri/r128/r128_span.c index 457e371edce..b59706118e4 100644 --- a/src/mesa/drivers/dri/r128/r128_span.c +++ b/src/mesa/drivers/dri/r128/r128_span.c @@ -335,7 +335,7 @@ static void r128DDSetBuffer( GLcontext *ctx, r128ContextPtr rmesa = R128_CONTEXT(ctx); switch ( bufferBit ) { - case DD_FRONT_LEFT_BIT: + case BUFFER_BIT_FRONT_LEFT: if ( rmesa->sarea->pfCurrentPage == 1 ) { rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->backOffset; rmesa->drawPitch = rmesa->readPitch = rmesa->r128Screen->backPitch; @@ -344,7 +344,7 @@ static void r128DDSetBuffer( GLcontext *ctx, rmesa->drawPitch = rmesa->readPitch = rmesa->r128Screen->frontPitch; } break; - case DD_BACK_LEFT_BIT: + case BUFFER_BIT_BACK_LEFT: if ( rmesa->sarea->pfCurrentPage == 1 ) { rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->frontOffset; rmesa->drawPitch = rmesa->readPitch = rmesa->r128Screen->frontPitch; @@ -368,11 +368,15 @@ void r128DDInitSpanFuncs( GLcontext *ctx ) switch ( rmesa->r128Screen->cpp ) { case 2: +#if 0 r128InitPointers_RGB565( swdd ); +#endif break; case 4: +#if 0 r128InitPointers_ARGB8888( swdd ); +#endif break; default: @@ -381,17 +385,21 @@ void r128DDInitSpanFuncs( GLcontext *ctx ) switch ( rmesa->glCtx->Visual.depthBits ) { case 16: +#if 0 swdd->ReadDepthSpan = r128ReadDepthSpan_16; swdd->WriteDepthSpan = r128WriteDepthSpan_16; swdd->ReadDepthPixels = r128ReadDepthPixels_16; swdd->WriteDepthPixels = r128WriteDepthPixels_16; +#endif break; case 24: +#if 0 swdd->ReadDepthSpan = r128ReadDepthSpan_24_8; swdd->WriteDepthSpan = r128WriteDepthSpan_24_8; swdd->ReadDepthPixels = r128ReadDepthPixels_24_8; swdd->WriteDepthPixels = r128WriteDepthPixels_24_8; +#endif break; default: @@ -406,3 +414,44 @@ void r128DDInitSpanFuncs( GLcontext *ctx ) swdd->ReadCI32Span = NULL; swdd->ReadCI32Pixels = NULL; } + + +/** + * Plug in the Get/Put routines for the given driRenderbuffer. + */ +void +r128SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis) +{ + if (drb->Base.InternalFormat == GL_RGBA) { + if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) { + r128InitPointers_RGB565(&drb->Base); + } + else { + r128InitPointers_ARGB8888(&drb->Base); + } + } + else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) { + drb->Base.GetRow = r128ReadDepthSpan_16; + drb->Base.GetValues = r128ReadDepthPixels_16; + drb->Base.PutRow = r128WriteDepthSpan_16; + drb->Base.PutMonoRow = r128WriteMonoDepthSpan_16; + drb->Base.PutValues = r128WriteDepthPixels_16; + drb->Base.PutMonoValues = NULL; + } + else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) { + drb->Base.GetRow = r128ReadDepthSpan_24_8; + drb->Base.GetValues = r128ReadDepthPixels_24_8; + drb->Base.PutRow = r128WriteDepthSpan_24_8; + drb->Base.PutMonoRow = r128WriteMonoDepthSpan_24_8; + drb->Base.PutValues = r128WriteDepthPixels_24_8; + drb->Base.PutMonoValues = NULL; + } + else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) { + drb->Base.GetRow = NULL; + drb->Base.GetValues = NULL; + drb->Base.PutRow = NULL; + drb->Base.PutMonoRow = NULL; + drb->Base.PutValues = NULL; + drb->Base.PutMonoValues = NULL; + } +} diff --git a/src/mesa/drivers/dri/r128/r128_span.h b/src/mesa/drivers/dri/r128/r128_span.h index 03de567b32e..fd7c2d1394a 100644 --- a/src/mesa/drivers/dri/r128/r128_span.h +++ b/src/mesa/drivers/dri/r128/r128_span.h @@ -36,6 +36,11 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef __R128_SPAN_H__ #define __R128_SPAN_H__ +#include "drirenderbuffer.h" + extern void r128DDInitSpanFuncs( GLcontext *ctx ); +extern void +r128SetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis); + #endif diff --git a/src/mesa/drivers/dri/r128/r128_state.c b/src/mesa/drivers/dri/r128/r128_state.c index 320865c67b4..29f490da89d 100644 --- a/src/mesa/drivers/dri/r128/r128_state.c +++ b/src/mesa/drivers/dri/r128/r128_state.c @@ -714,13 +714,13 @@ static void r128DDDrawBuffer( GLcontext *ctx, GLenum mode ) FLUSH_BATCH( rmesa ); /* - * _DrawDestMask is easier to cope with than <mode>. + * _ColorDrawBufferMask 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: FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_FALSE ); break; - case DD_BACK_LEFT_BIT: + case BUFFER_BIT_BACK_LEFT: FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_FALSE ); break; default: |