From e4b2356c07d31fbeeabb13b2fb47db703b473080 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 4 May 2005 20:11:35 +0000 Subject: 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. --- src/mesa/drivers/dri/mach64/mach64_context.c | 8 ++-- src/mesa/drivers/dri/mach64/mach64_dd.c | 3 +- src/mesa/drivers/dri/mach64/mach64_ioctl.c | 12 ++--- src/mesa/drivers/dri/mach64/mach64_lock.c | 2 +- src/mesa/drivers/dri/mach64/mach64_screen.c | 50 ++++++++++++++++++++ src/mesa/drivers/dri/mach64/mach64_span.c | 71 +++++++++++++++++++++++++--- src/mesa/drivers/dri/mach64/mach64_span.h | 5 ++ src/mesa/drivers/dri/mach64/mach64_state.c | 10 ++-- 8 files changed, 138 insertions(+), 23 deletions(-) (limited to 'src/mesa/drivers/dri/mach64') diff --git a/src/mesa/drivers/dri/mach64/mach64_context.c b/src/mesa/drivers/dri/mach64/mach64_context.c index 1978c5d615..8f508fa911 100644 --- a/src/mesa/drivers/dri/mach64/mach64_context.c +++ b/src/mesa/drivers/dri/mach64/mach64_context.c @@ -306,14 +306,14 @@ mach64MakeCurrent( __DRIcontextPrivate *driContextPriv, mach64CalcViewport( newMach64Ctx->glCtx ); } - _mesa_make_current2( newMach64Ctx->glCtx, - (GLframebuffer *) driDrawPriv->driverPrivate, - (GLframebuffer *) driReadPriv->driverPrivate ); + _mesa_make_current( newMach64Ctx->glCtx, + (GLframebuffer *) driDrawPriv->driverPrivate, + (GLframebuffer *) driReadPriv->driverPrivate ); newMach64Ctx->new_state |= MACH64_NEW_CLIP; } else { - _mesa_make_current( 0, 0 ); + _mesa_make_current( NULL, NULL, NULL ); } return GL_TRUE; diff --git a/src/mesa/drivers/dri/mach64/mach64_dd.c b/src/mesa/drivers/dri/mach64/mach64_dd.c index f1248bd8b7..c0bb8629fa 100644 --- a/src/mesa/drivers/dri/mach64/mach64_dd.c +++ b/src/mesa/drivers/dri/mach64/mach64_dd.c @@ -37,6 +37,7 @@ #include "context.h" #include "utils.h" +#include "framebuffer.h" #define DRIVER_DATE "20030502" @@ -126,7 +127,7 @@ static void mach64DDFinish( GLcontext *ctx ) void mach64InitDriverFuncs( struct dd_function_table *functions ) { functions->GetBufferSize = mach64DDGetBufferSize; - functions->ResizeBuffers = _swrast_alloc_buffers; + functions->ResizeBuffers = _mesa_resize_framebuffer; functions->GetString = mach64DDGetString; functions->Finish = mach64DDFinish; functions->Flush = mach64DDFlush; diff --git a/src/mesa/drivers/dri/mach64/mach64_ioctl.c b/src/mesa/drivers/dri/mach64/mach64_ioctl.c index 752aa6ef4a..1889dc2b93 100644 --- a/src/mesa/drivers/dri/mach64/mach64_ioctl.c +++ b/src/mesa/drivers/dri/mach64/mach64_ioctl.c @@ -683,19 +683,19 @@ static void mach64DDClear( GLcontext *ctx, GLbitfield mask, GLboolean all, mmesa->new_state = save_state & ~(MACH64_NEW_MASKS | MACH64_NEW_CLIP); } - if ( mask & DD_FRONT_LEFT_BIT ) { + if ( mask & BUFFER_BIT_FRONT_LEFT ) { flags |= MACH64_FRONT; - mask &= ~DD_FRONT_LEFT_BIT; + mask &= ~BUFFER_BIT_FRONT_LEFT; } - if ( mask & DD_BACK_LEFT_BIT ) { + if ( mask & BUFFER_BIT_BACK_LEFT ) { flags |= MACH64_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 |= MACH64_DEPTH; - mask &= ~DD_DEPTH_BIT; + mask &= ~BUFFER_BIT_DEPTH; } if ( mask ) diff --git a/src/mesa/drivers/dri/mach64/mach64_lock.c b/src/mesa/drivers/dri/mach64/mach64_lock.c index ea926944ed..3d41d71b37 100644 --- a/src/mesa/drivers/dri/mach64/mach64_lock.c +++ b/src/mesa/drivers/dri/mach64/mach64_lock.c @@ -69,7 +69,7 @@ void mach64GetLock( mach64ContextPtr mmesa, GLuint flags ) if ( mmesa->lastStamp != dPriv->lastStamp ) { mmesa->lastStamp = dPriv->lastStamp; - if (mmesa->glCtx->Color._DrawDestMask[0] == DD_BACK_LEFT_BIT) + if (mmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT) mach64SetCliprects( mmesa->glCtx, GL_BACK_LEFT ); else mach64SetCliprects( mmesa->glCtx, GL_FRONT_LEFT ); diff --git a/src/mesa/drivers/dri/mach64/mach64_screen.c b/src/mesa/drivers/dri/mach64/mach64_screen.c index c5806adc3d..471ae1648e 100644 --- a/src/mesa/drivers/dri/mach64/mach64_screen.c +++ b/src/mesa/drivers/dri/mach64/mach64_screen.c @@ -33,9 +33,12 @@ #include "mach64_ioctl.h" #include "mach64_tris.h" #include "mach64_vb.h" +#include "mach64_span.h" #include "context.h" #include "imports.h" +#include "framebuffer.h" +#include "renderbuffer.h" #include "utils.h" #include "vblank.h" @@ -355,6 +358,7 @@ mach64DestroyScreen( __DRIscreenPrivate *driScreen ) driScreen->private = NULL; } + /* Create and initialize the Mesa and driver specific pixmap buffer * data. */ @@ -364,16 +368,62 @@ mach64CreateBuffer( __DRIscreenPrivate *driScrnPriv, const __GLcontextModes *mesaVis, GLboolean isPixmap ) { + mach64ScreenPtr screen = (mach64ScreenPtr) 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); + mach64SetSpanFunctions(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); + mach64SetSpanFunctions(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); + mach64SetSpanFunctions(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); + mach64SetSpanFunctions(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/mach64/mach64_span.c b/src/mesa/drivers/dri/mach64/mach64_span.c index 3e553a9094..12849eebe0 100644 --- a/src/mesa/drivers/dri/mach64/mach64_span.c +++ b/src/mesa/drivers/dri/mach64/mach64_span.c @@ -200,15 +200,15 @@ static void mach64DDSetBuffer( GLcontext *ctx, mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); switch ( bufferBit ) { - case DD_FRONT_LEFT_BIT: + case BUFFER_BIT_FRONT_LEFT: if (MACH64_DEBUG & DEBUG_VERBOSE_MSG) - fprintf(stderr,"%s: DD_FRONT_LEFT_BIT\n", __FUNCTION__); + fprintf(stderr,"%s: BUFFER_BIT_FRONT_LEFT\n", __FUNCTION__); mmesa->drawOffset = mmesa->readOffset = mmesa->mach64Screen->frontOffset; mmesa->drawPitch = mmesa->readPitch = mmesa->mach64Screen->frontPitch; break; - case DD_BACK_LEFT_BIT: + case BUFFER_BIT_BACK_LEFT: if (MACH64_DEBUG & DEBUG_VERBOSE_MSG) - fprintf(stderr,"%s: DD_BACK_LEFT_BIT\n", __FUNCTION__); + fprintf(stderr,"%s: BUFFER_BIT_BACK_LEFT\n", __FUNCTION__); mmesa->drawOffset = mmesa->readOffset = mmesa->mach64Screen->backOffset; mmesa->drawPitch = mmesa->readPitch = mmesa->mach64Screen->backPitch; break; @@ -220,12 +220,14 @@ static void mach64DDSetBuffer( GLcontext *ctx, void mach64DDInitSpanFuncs( GLcontext *ctx ) { +#if 0 mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); +#endif struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx); swdd->SetBuffer = mach64DDSetBuffer; - +#if 0 switch ( mmesa->mach64Screen->cpp ) { case 2: swdd->WriteRGBASpan = mach64WriteRGBASpan_RGB565; @@ -251,13 +253,15 @@ void mach64DDInitSpanFuncs( GLcontext *ctx ) default: break; } +#endif /* Depth buffer is always 16 bit */ +#if 0 swdd->ReadDepthSpan = mach64ReadDepthSpan_16; swdd->WriteDepthSpan = mach64WriteDepthSpan_16; swdd->ReadDepthPixels = mach64ReadDepthPixels_16; swdd->WriteDepthPixels = mach64WriteDepthPixels_16; - +#endif /* No hardware stencil buffer */ swdd->ReadStencilSpan = NULL; swdd->WriteStencilSpan = NULL; @@ -272,3 +276,58 @@ void mach64DDInitSpanFuncs( GLcontext *ctx ) swdd->ReadCI32Span = NULL; swdd->ReadCI32Pixels = NULL; } + + +/** + * Plug in the Get/Put routines for the given driRenderbuffer. + */ +void +mach64SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis) +{ + if (drb->Base.InternalFormat == GL_RGBA) { + if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) { + drb->Base.GetRow = mach64ReadRGBASpan_RGB565; + drb->Base.GetValues = mach64ReadRGBAPixels_RGB565; + drb->Base.PutRow = mach64WriteRGBASpan_RGB565; + drb->Base.PutRowRGB = mach64WriteRGBSpan_RGB565; + drb->Base.PutMonoRow = mach64WriteMonoRGBASpan_RGB565; + drb->Base.PutValues = mach64WriteRGBAPixels_RGB565; + drb->Base.PutMonoValues = mach64WriteMonoRGBAPixels_RGB565; + } + else { + drb->Base.GetRow = mach64ReadRGBASpan_ARGB8888; + drb->Base.GetValues = mach64ReadRGBAPixels_ARGB8888; + drb->Base.PutRow = mach64WriteRGBASpan_ARGB8888; + drb->Base.PutRowRGB = mach64WriteRGBSpan_ARGB8888; + drb->Base.PutMonoRow = mach64WriteMonoRGBASpan_ARGB8888; + drb->Base.PutValues = mach64WriteRGBAPixels_ARGB8888; + drb->Base.PutMonoValues = mach64WriteMonoRGBAPixels_ARGB8888; + } + } + else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) { + drb->Base.GetRow = mach64ReadDepthSpan_16; + drb->Base.GetValues = mach64ReadDepthPixels_16; + drb->Base.PutRow = mach64WriteDepthSpan_16; + drb->Base.PutMonoRow = mach64WriteMonoDepthSpan_16; + drb->Base.PutValues = mach64WriteDepthPixels_16; + drb->Base.PutMonoValues = NULL; + } + else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) { + /* never */ + drb->Base.GetRow = NULL; + drb->Base.GetValues = NULL; + drb->Base.PutRow = NULL; + drb->Base.PutMonoRow = NULL; + drb->Base.PutValues = NULL; + drb->Base.PutMonoValues = NULL; + } + else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) { + /* never */ + 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/mach64/mach64_span.h b/src/mesa/drivers/dri/mach64/mach64_span.h index b83ac7c721..0f4c766477 100644 --- a/src/mesa/drivers/dri/mach64/mach64_span.h +++ b/src/mesa/drivers/dri/mach64/mach64_span.h @@ -31,6 +31,11 @@ #ifndef __MACH64_SPAN_H__ #define __MACH64_SPAN_H__ +#include "drirenderbuffer.h" + extern void mach64DDInitSpanFuncs( GLcontext *ctx ); +extern void +mach64SetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis); + #endif diff --git a/src/mesa/drivers/dri/mach64/mach64_state.c b/src/mesa/drivers/dri/mach64/mach64_state.c index ea55124d91..d9b5725a63 100644 --- a/src/mesa/drivers/dri/mach64/mach64_state.c +++ b/src/mesa/drivers/dri/mach64/mach64_state.c @@ -732,18 +732,18 @@ static void mach64DDDrawBuffer( GLcontext *ctx, GLenum mode ) /* * _DrawDestMask is easier to cope with than . */ - switch ( ctx->Color._DrawDestMask[0] ) { - case DD_FRONT_LEFT_BIT: + switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) { + case BUFFER_BIT_FRONT_LEFT: FALLBACK( mmesa, MACH64_FALLBACK_DRAW_BUFFER, GL_FALSE ); mach64SetCliprects( ctx, GL_FRONT_LEFT ); if (MACH64_DEBUG & DEBUG_VERBOSE_MSG) - fprintf(stderr,"%s: DD_FRONT_LEFT_BIT\n", __FUNCTION__); + fprintf(stderr,"%s: BUFFER_BIT_FRONT_LEFT\n", __FUNCTION__); break; - case DD_BACK_LEFT_BIT: + case BUFFER_BIT_BACK_LEFT: FALLBACK( mmesa, MACH64_FALLBACK_DRAW_BUFFER, GL_FALSE ); mach64SetCliprects( ctx, GL_BACK_LEFT ); if (MACH64_DEBUG & DEBUG_VERBOSE_MSG) - fprintf(stderr,"%s: DD_BACK_LEFT_BIT\n", __FUNCTION__); + fprintf(stderr,"%s: BUFFER_BIT_BACK_LEFT\n", __FUNCTION__); break; default: /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ -- cgit v1.2.3