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/i830/i830_context.c | 17 +++--- src/mesa/drivers/dri/i830/i830_ioctl.c | 28 +++++----- src/mesa/drivers/dri/i830/i830_screen.c | 74 +++++++++++++++++++++++++- src/mesa/drivers/dri/i830/i830_span.c | 91 ++++++++++++++++++++++++++++++-- src/mesa/drivers/dri/i830/i830_span.h | 5 ++ src/mesa/drivers/dri/i830/i830_state.c | 8 +-- 6 files changed, 190 insertions(+), 33 deletions(-) (limited to 'src/mesa/drivers/dri/i830') diff --git a/src/mesa/drivers/dri/i830/i830_context.c b/src/mesa/drivers/dri/i830/i830_context.c index 082476f211..66c25ac0e6 100644 --- a/src/mesa/drivers/dri/i830/i830_context.c +++ b/src/mesa/drivers/dri/i830/i830_context.c @@ -42,6 +42,7 @@ #include "matrix.h" #include "simple_list.h" #include "extensions.h" +#include "framebuffer.h" #include "imports.h" #include "swrast/swrast.h" @@ -305,7 +306,7 @@ GLboolean i830CreateContext( const __GLcontextModes *mesaVis, ctx->Const.PointSizeGranularity = 1.0; ctx->Driver.GetBufferSize = i830BufferSize; - ctx->Driver.ResizeBuffers = _swrast_alloc_buffers; + ctx->Driver.ResizeBuffers = _mesa_resize_framebuffer; ctx->Driver.GetString = i830DDGetString; /* Who owns who? */ @@ -476,11 +477,11 @@ void i830XMesaSetBackClipRects( i830ContextPtr imesa ) static void i830XMesaWindowMoved( i830ContextPtr imesa ) { - switch (imesa->glCtx->Color._DrawDestMask[0]) { - case DD_FRONT_LEFT_BIT: + switch (imesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) { + case BUFFER_BIT_FRONT_LEFT: i830XMesaSetFrontClipRects( imesa ); break; - case DD_BACK_LEFT_BIT: + case BUFFER_BIT_BACK_LEFT: i830XMesaSetBackClipRects( imesa ); break; default: @@ -527,11 +528,11 @@ GLboolean i830MakeCurrent(__DRIcontextPrivate *driContextPriv, imesa->driReadable = driReadPriv; - _mesa_make_current2(imesa->glCtx, - (GLframebuffer *) driDrawPriv->driverPrivate, - (GLframebuffer *) driReadPriv->driverPrivate); + _mesa_make_current(imesa->glCtx, + (GLframebuffer *) driDrawPriv->driverPrivate, + (GLframebuffer *) driReadPriv->driverPrivate); } else { - _mesa_make_current(0,0); + _mesa_make_current(NULL, NULL, NULL); } return GL_TRUE; diff --git a/src/mesa/drivers/dri/i830/i830_ioctl.c b/src/mesa/drivers/dri/i830/i830_ioctl.c index cad48db9df..cd0c143dfc 100644 --- a/src/mesa/drivers/dri/i830/i830_ioctl.c +++ b/src/mesa/drivers/dri/i830/i830_ioctl.c @@ -186,7 +186,7 @@ static void i830ClearWithTris(GLcontext *ctx, GLbitfield mask, old_vertex_prim = imesa->hw_primitive; imesa->hw_primitive = PRIM3D_TRIFAN; - if(mask & DD_FRONT_LEFT_BIT) { + if(mask & BUFFER_BIT_FRONT_LEFT) { GLuint tmp = sarea->ContextState[I830_CTXREG_ENABLES_2]; sarea->dirty |= (I830_UPLOAD_CTX | I830_UPLOAD_BUFFERS | @@ -248,7 +248,7 @@ static void i830ClearWithTris(GLcontext *ctx, GLbitfield mask, i830FlushPrimsLocked( imesa ); } - if(mask & DD_BACK_LEFT_BIT) { + if(mask & BUFFER_BIT_BACK_LEFT) { GLuint tmp = sarea->ContextState[I830_CTXREG_ENABLES_2]; sarea->dirty |= (I830_UPLOAD_CTX | I830_UPLOAD_BUFFERS | @@ -311,7 +311,7 @@ static void i830ClearWithTris(GLcontext *ctx, GLbitfield mask, i830FlushPrimsLocked( imesa ); } - if(mask & DD_STENCIL_BIT) { + if(mask & BUFFER_BIT_STENCIL) { GLuint s_mask = ctx->Stencil.WriteMask[0]; sarea->dirty |= (I830_UPLOAD_CTX | I830_UPLOAD_BUFFERS | @@ -433,40 +433,40 @@ static void i830Clear(GLcontext *ctx, GLbitfield mask, GLboolean all, I830_FIREVERTICES( imesa ); - if (mask & DD_FRONT_LEFT_BIT) { + if (mask & BUFFER_BIT_FRONT_LEFT) { if(colorMask == ~0) { clear.flags |= I830_FRONT; } else { - tri_mask |= DD_FRONT_LEFT_BIT; + tri_mask |= BUFFER_BIT_FRONT_LEFT; } - mask &= ~DD_FRONT_LEFT_BIT; + mask &= ~BUFFER_BIT_FRONT_LEFT; } - if (mask & DD_BACK_LEFT_BIT) { + if (mask & BUFFER_BIT_BACK_LEFT) { if(colorMask == ~0) { clear.flags |= I830_BACK; } else { - tri_mask |= DD_BACK_LEFT_BIT; + tri_mask |= BUFFER_BIT_BACK_LEFT; } - mask &= ~DD_BACK_LEFT_BIT; + mask &= ~BUFFER_BIT_BACK_LEFT; } - if (mask & DD_DEPTH_BIT) { + if (mask & BUFFER_BIT_DEPTH) { clear.flags |= I830_DEPTH; clear.clear_depthmask = imesa->depth_clear_mask; clear.clear_depth = (GLuint)(ctx->Depth.Clear * imesa->ClearDepth); - mask &= ~DD_DEPTH_BIT; + mask &= ~BUFFER_BIT_DEPTH; } - if((mask & DD_STENCIL_BIT) && imesa->hw_stencil) { + if((mask & BUFFER_BIT_STENCIL) && imesa->hw_stencil) { if (ctx->Stencil.WriteMask[0] != 0xff) { - tri_mask |= DD_STENCIL_BIT; + tri_mask |= BUFFER_BIT_STENCIL; } else { clear.flags |= I830_DEPTH; clear.clear_depthmask |= imesa->stencil_clear_mask; clear.clear_depth |= (ctx->Stencil.Clear & 0xff) << 24; } - mask &= ~DD_STENCIL_BIT; + mask &= ~BUFFER_BIT_STENCIL; } /* First check for clears that need to happen with triangles */ diff --git a/src/mesa/drivers/dri/i830/i830_screen.c b/src/mesa/drivers/dri/i830/i830_screen.c index 47a2ef64ac..82883d07f2 100644 --- a/src/mesa/drivers/dri/i830/i830_screen.c +++ b/src/mesa/drivers/dri/i830/i830_screen.c @@ -40,6 +40,8 @@ #include "context.h" #include "matrix.h" #include "simple_list.h" +#include "framebuffer.h" +#include "renderbuffer.h" #include "i830_screen.h" #include "i830_dri.h" @@ -54,6 +56,7 @@ #include "utils.h" #include "xmlpool.h" +#include "drirenderbuffer.h" PUBLIC const char __driConfigOptions[] = DRI_CONF_BEGIN @@ -310,27 +313,94 @@ static void i830DestroyScreen(__DRIscreenPrivate *sPriv) sPriv->private = NULL; } + static GLboolean i830CreateBuffer(__DRIscreenPrivate *driScrnPriv, __DRIdrawablePrivate *driDrawPriv, const __GLcontextModes *mesaVis, GLboolean isPixmap ) { + i830ScreenPrivate *screen = (i830ScreenPrivate *) driScrnPriv->private; + if (isPixmap) { return GL_FALSE; /* not implemented */ - } else { + } + else { #if 0 GLboolean swStencil = (mesaVis->stencilBits > 0 && mesaVis->depthBits != 24); #else GLboolean swStencil = mesaVis->stencilBits > 0; #endif + +#if 0 driDrawPriv->driverPrivate = (void *) _mesa_create_framebuffer(mesaVis, GL_FALSE, /* software depth buffer? */ swStencil, mesaVis->accumRedBits > 0, GL_FALSE /* s/w alpha planes */); - +#else + struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis); + + { + driRenderbuffer *frontRb + = driNewRenderbuffer(GL_RGBA, screen->cpp, + /*screen->frontOffset*/0, screen->backPitch); + i830SetSpanFunctions(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); + i830SetSpanFunctions(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->backPitch); + i830SetSpanFunctions(depthRb, mesaVis); + _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); + } + else if (mesaVis->depthBits == 24) { + if (mesaVis->stencilBits == 8) { + driRenderbuffer *depthRb + = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp, + screen->depthOffset, screen->backPitch); + i830SetSpanFunctions(depthRb, mesaVis); + _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); + } + else { + /* not really 32-bit Z, but use GL_DEPTH_COMPONENT32 anyway */ + driRenderbuffer *depthRb + = driNewRenderbuffer(GL_DEPTH_COMPONENT32, screen->cpp, + screen->depthOffset, screen->backPitch); + i830SetSpanFunctions(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->backPitch); + i830SetSpanFunctions(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); } } diff --git a/src/mesa/drivers/dri/i830/i830_span.c b/src/mesa/drivers/dri/i830/i830_span.c index 9076b34423..a17ec9b6ac 100644 --- a/src/mesa/drivers/dri/i830/i830_span.c +++ b/src/mesa/drivers/dri/i830/i830_span.c @@ -275,10 +275,10 @@ static void i830SetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer, imesa->mesa_drawable = (colorBuffer == imesa->driDrawable->driverPrivate) ? imesa->driDrawable : imesa->driReadable; - if (bufferBit == DD_FRONT_LEFT_BIT) { + if (bufferBit == BUFFER_BIT_FRONT_LEFT) { imesa->drawMap = (char *)imesa->driScreen->pFB; imesa->readMap = (char *)imesa->driScreen->pFB; - } else if (bufferBit == DD_BACK_LEFT_BIT) { + } else if (bufferBit == BUFFER_BIT_BACK_LEFT) { imesa->drawMap = imesa->i830Screen->back.map; imesa->readMap = imesa->i830Screen->back.map; } else { @@ -316,6 +316,7 @@ void i830DDInitSpanFuncs( GLcontext *ctx ) switch (i830Screen->fbFormat) { case DV_PF_555: +#if 0 swdd->WriteRGBASpan = i830WriteRGBASpan_555; swdd->WriteRGBSpan = i830WriteRGBSpan_555; swdd->WriteMonoRGBASpan = i830WriteMonoRGBASpan_555; @@ -323,14 +324,15 @@ void i830DDInitSpanFuncs( GLcontext *ctx ) swdd->WriteMonoRGBAPixels = i830WriteMonoRGBAPixels_555; swdd->ReadRGBASpan = i830ReadRGBASpan_555; swdd->ReadRGBAPixels = i830ReadRGBAPixels_555; - swdd->ReadDepthSpan = i830ReadDepthSpan_16; swdd->WriteDepthSpan = i830WriteDepthSpan_16; swdd->ReadDepthPixels = i830ReadDepthPixels_16; swdd->WriteDepthPixels = i830WriteDepthPixels_16; +#endif break; case DV_PF_565: +#if 0 swdd->WriteRGBASpan = i830WriteRGBASpan_565; swdd->WriteRGBSpan = i830WriteRGBSpan_565; swdd->WriteMonoRGBASpan = i830WriteMonoRGBASpan_565; @@ -338,14 +340,15 @@ void i830DDInitSpanFuncs( GLcontext *ctx ) swdd->WriteMonoRGBAPixels = i830WriteMonoRGBAPixels_565; swdd->ReadRGBASpan = i830ReadRGBASpan_565; swdd->ReadRGBAPixels = i830ReadRGBAPixels_565; - swdd->ReadDepthSpan = i830ReadDepthSpan_16; swdd->WriteDepthSpan = i830WriteDepthSpan_16; swdd->ReadDepthPixels = i830ReadDepthPixels_16; swdd->WriteDepthPixels = i830WriteDepthPixels_16; +#endif break; case DV_PF_8888: +#if 0 swdd->WriteRGBASpan = i830WriteRGBASpan_8888; swdd->WriteRGBSpan = i830WriteRGBSpan_8888; swdd->WriteMonoRGBASpan = i830WriteMonoRGBASpan_8888; @@ -353,22 +356,26 @@ void i830DDInitSpanFuncs( GLcontext *ctx ) swdd->WriteMonoRGBAPixels = i830WriteMonoRGBAPixels_8888; swdd->ReadRGBASpan = i830ReadRGBASpan_8888; swdd->ReadRGBAPixels = i830ReadRGBAPixels_8888; +#endif if(imesa->hw_stencil) { +#if 0 swdd->ReadDepthSpan = i830ReadDepthSpan_24_8; swdd->WriteDepthSpan = i830WriteDepthSpan_24_8; swdd->ReadDepthPixels = i830ReadDepthPixels_24_8; swdd->WriteDepthPixels = i830WriteDepthPixels_24_8; - swdd->WriteStencilSpan = i830WriteStencilSpan_24_8; swdd->ReadStencilSpan = i830ReadStencilSpan_24_8; swdd->WriteStencilPixels = i830WriteStencilPixels_24_8; swdd->ReadStencilPixels = i830ReadStencilPixels_24_8; +#endif } else { +#if 0 swdd->ReadDepthSpan = i830ReadDepthSpan_24; swdd->WriteDepthSpan = i830WriteDepthSpan_24; swdd->ReadDepthPixels = i830ReadDepthPixels_24; swdd->WriteDepthPixels = i830WriteDepthPixels_24; +#endif } break; } @@ -376,3 +383,77 @@ void i830DDInitSpanFuncs( GLcontext *ctx ) swdd->SpanRenderStart = i830SpanRenderStart; swdd->SpanRenderFinish = i830SpanRenderFinish; } + + +/** + * Plug in the Get/Put routines for the given driRenderbuffer. + */ +void +i830SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis) +{ + if (drb->Base.InternalFormat == GL_RGBA) { + if (vis->redBits == 5 && vis->greenBits == 5 && vis->blueBits == 5) { + drb->Base.GetRow = i830ReadRGBASpan_555; + drb->Base.GetValues = i830ReadRGBAPixels_555; + drb->Base.PutRow = i830WriteRGBASpan_555; + drb->Base.PutRowRGB = i830WriteRGBSpan_555; + drb->Base.PutMonoRow = i830WriteMonoRGBASpan_555; + drb->Base.PutValues = i830WriteRGBAPixels_555; + drb->Base.PutMonoValues = i830WriteMonoRGBAPixels_555; + } + else if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) { + drb->Base.GetRow = i830ReadRGBASpan_565; + drb->Base.GetValues = i830ReadRGBAPixels_565; + drb->Base.PutRow = i830WriteRGBASpan_565; + drb->Base.PutRowRGB = i830WriteRGBSpan_565; + drb->Base.PutMonoRow = i830WriteMonoRGBASpan_565; + drb->Base.PutValues = i830WriteRGBAPixels_565; + drb->Base.PutMonoValues = i830WriteMonoRGBAPixels_565; + } + else { + assert(vis->redBits == 8); + assert(vis->greenBits == 8); + assert(vis->blueBits == 8); + drb->Base.GetRow = i830ReadRGBASpan_8888; + drb->Base.GetValues = i830ReadRGBAPixels_8888; + drb->Base.PutRow = i830WriteRGBASpan_8888; + drb->Base.PutRowRGB = i830WriteRGBSpan_8888; + drb->Base.PutMonoRow = i830WriteMonoRGBASpan_8888; + drb->Base.PutValues = i830WriteRGBAPixels_8888; + drb->Base.PutMonoValues = i830WriteMonoRGBAPixels_8888; + } + } + else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) { + drb->Base.GetRow = i830ReadDepthSpan_16; + drb->Base.GetValues = i830ReadDepthPixels_16; + drb->Base.PutRow = i830WriteDepthSpan_16; + drb->Base.PutMonoRow = i830WriteMonoDepthSpan_16; + drb->Base.PutValues = i830WriteDepthPixels_16; + drb->Base.PutMonoValues = NULL; + } + else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) { + drb->Base.GetRow = i830ReadDepthSpan_24_8; + drb->Base.GetValues = i830ReadDepthPixels_24_8; + drb->Base.PutRow = i830WriteDepthSpan_24_8; + drb->Base.PutMonoRow = i830WriteMonoDepthSpan_24_8; + drb->Base.PutValues = i830WriteDepthPixels_24_8; + drb->Base.PutMonoValues = NULL; + } + else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT32) { + /* not _really_ 32-bit Z */ + drb->Base.GetRow = i830ReadDepthSpan_24; + drb->Base.GetValues = i830ReadDepthPixels_24; + drb->Base.PutRow = i830WriteDepthSpan_24; + drb->Base.PutMonoRow = i830WriteMonoDepthSpan_24; + drb->Base.PutValues = i830WriteDepthPixels_24; + drb->Base.PutMonoValues = NULL; + } + else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) { + drb->Base.GetRow = i830ReadStencilSpan_24_8; + drb->Base.GetValues = i830ReadStencilPixels_24_8; + drb->Base.PutRow = i830WriteStencilSpan_24_8; + drb->Base.PutMonoRow = i830WriteMonoStencilSpan_24_8; + drb->Base.PutValues = i830WriteStencilPixels_24_8; + drb->Base.PutMonoValues = NULL; + } +} diff --git a/src/mesa/drivers/dri/i830/i830_span.h b/src/mesa/drivers/dri/i830/i830_span.h index 0135468ffa..4b83419718 100644 --- a/src/mesa/drivers/dri/i830/i830_span.h +++ b/src/mesa/drivers/dri/i830/i830_span.h @@ -38,9 +38,14 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef _I830_SPAN_H #define _I830_SPAN_H +#include "drirenderbuffer.h" + extern void i830DDInitSpanFuncs( GLcontext *ctx ); extern void i830SpanRenderFinish( GLcontext *ctx ); extern void i830SpanRenderStart( GLcontext *ctx ); +extern void +i830SetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis); + #endif diff --git a/src/mesa/drivers/dri/i830/i830_state.c b/src/mesa/drivers/dri/i830/i830_state.c index f8979c7018..6153485449 100644 --- a/src/mesa/drivers/dri/i830/i830_state.c +++ b/src/mesa/drivers/dri/i830/i830_state.c @@ -802,17 +802,17 @@ static void i830DrawBuffer(GLcontext *ctx, GLenum mode ) i830ContextPtr imesa = I830_CONTEXT(ctx); /* - * _DrawDestMask is easier to cope with than . + * _ColorDrawBufferMask 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: I830_FIREVERTICES(imesa); I830_STATECHANGE(imesa, I830_UPLOAD_BUFFERS); imesa->BufferSetup[I830_DESTREG_CBUFADDR] = imesa->i830Screen->fbOffset; i830XMesaSetFrontClipRects( imesa ); FALLBACK( imesa, I830_FALLBACK_DRAW_BUFFER, GL_FALSE ); break; - case DD_BACK_LEFT_BIT: + case BUFFER_BIT_BACK_LEFT: I830_FIREVERTICES(imesa); I830_STATECHANGE(imesa, I830_UPLOAD_BUFFERS); imesa->BufferSetup[I830_DESTREG_CBUFADDR] = -- cgit v1.2.3