diff options
Diffstat (limited to 'src/mesa')
33 files changed, 495 insertions, 606 deletions
diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c index c9bc898dcbf..5855f04f3e7 100644 --- a/src/mesa/drivers/dos/dmesa.c +++ b/src/mesa/drivers/dos/dmesa.c @@ -512,8 +512,7 @@ static void clear (GLcontext *ctx, GLbitfield mask, GLboolean all, /*
* Set the current reading buffer.
*/
-static void set_read_buffer (GLcontext *ctx, GLframebuffer *buffer,
- GLenum mode)
+static void set_buffer (GLcontext *ctx, GLframebuffer *buffer, GLenum mode)
{
/*
DMesaContext c = (DMesaContext)ctx->DriverCtx;
@@ -524,18 +523,6 @@ static void set_read_buffer (GLcontext *ctx, GLframebuffer *buffer, /*
- * Set the destination/draw buffer.
- */
-static void set_draw_buffer (GLcontext *ctx, GLenum mode)
-{
- /*
- XXX this has to be fixed
- */
-}
-
-
-
-/*
* Return the width and height of the current buffer.
* If anything special has to been done when the buffer/window is
* resized, do it now.
@@ -640,6 +627,7 @@ void dmesa_init_pointers (GLcontext *ctx) ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.DrawBuffer = _swrast_DrawBuffer;
/* Software texture functions:
*/
@@ -671,7 +659,6 @@ void dmesa_init_pointers (GLcontext *ctx) /* Statechange callbacks:
*/
- ctx->Driver.SetDrawBuffer = set_draw_buffer;
ctx->Driver.ClearColor = clear_color;
/* Initialize the TNL driver interface:
@@ -699,7 +686,7 @@ static void dmesa_update_state (GLcontext *ctx, GLuint new_state) _ac_InvalidateState(ctx, new_state);
_tnl_InvalidateState(ctx, new_state);
- swdd->SetReadBuffer = set_read_buffer;
+ swdd->SetBuffer = set_buffer;
/* RGB(A) span/pixel functions */
swdd->WriteRGBASpan = write_rgba_span;
diff --git a/src/mesa/drivers/ggi/ggimesa.c b/src/mesa/drivers/ggi/ggimesa.c index 97ab159558a..86de850e915 100644 --- a/src/mesa/drivers/ggi/ggimesa.c +++ b/src/mesa/drivers/ggi/ggimesa.c @@ -143,50 +143,30 @@ static void gl_ggiClear(GLcontext *ctx, GLbitfield mask, GLboolean all, } -/* Set the buffer used for drawing */ -static void gl_ggiSetDrawBuffer(GLcontext *ctx, GLenum mode) -{ - ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; - - printf("set draw %d\n", mode); - GGIMESADPRINT_CORE("gl_ggiSetDrawBuffer() called\n"); - - if (mode == GL_FRONT_LEFT) - { - ggiSetWriteFrame(ggi_ctx->ggi_visual, - ggiGetDisplayFrame(ggi_ctx->ggi_visual)); - } - else if (mode == GL_BACK_LEFT) - { - ggiSetWriteFrame(ggi_ctx->ggi_visual, - ggiGetDisplayFrame(ggi_ctx->ggi_visual)?0 : 1); - } - else - { - /* nothing since we don't have any point/line/triangle functions. */ - } -} - /* Set the buffer used for reading */ /* XXX support for separate read/draw buffers hasn't been tested */ -static GLboolean gl_ggiSetReadBuffer(GLcontext *ctx, GLframebuffer *buffer, GLenum mode) +static GLboolean gl_ggiSetBuffer(GLcontext *ctx, GLframebuffer *buffer, GLenum mode) { ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; printf("set read %d\n", mode); - GGIMESADPRINT_CORE("gl_ggiSetReadBuffer() called\n"); + GGIMESADPRINT_CORE("gl_ggiSetBuffer() called\n"); if (mode == GL_FRONT_LEFT) { ggiSetReadFrame(ggi_ctx->ggi_visual, ggiGetDisplayFrame(ggi_ctx->ggi_visual)); + ggiSetWriteFrame(ggi_ctx->ggi_visual, + ggiGetDisplayFrame(ggi_ctx->ggi_visual)); return GL_TRUE; } else if (mode == GL_BACK_LEFT) { ggiSetReadFrame(ggi_ctx->ggi_visual, ggiGetDisplayFrame(ggi_ctx->ggi_visual)?0 : 1); + ggiSetWriteFrame(ggi_ctx->ggi_visual, + ggiGetDisplayFrame(ggi_ctx->ggi_visual)?0 : 1); return GL_TRUE; } else @@ -249,6 +229,7 @@ static void gl_ggiSetupPointers(GLcontext *ctx) ctx->Driver.CopyPixels = _swrast_CopyPixels; ctx->Driver.DrawPixels = _swrast_DrawPixels; ctx->Driver.ReadPixels = _swrast_ReadPixels; + ctx->Driver.DrawBuffer = _swrast_DrawBuffer; /* Software texturing */ ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format; @@ -277,7 +258,6 @@ static void gl_ggiSetupPointers(GLcontext *ctx) ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D; /* State change callbacks */ - ctx->Driver.SetDrawBuffer = gl_ggiSetDrawBuffer; ctx->Driver.ClearIndex = gl_ggiSetClearIndex; ctx->Driver.ClearColor = gl_ggiSetClearColor; ctx->Driver.IndexMask = gl_ggiIndexMask; diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c index 2fb1a2ada4c..9b7cd306b2c 100644 --- a/src/mesa/drivers/glide/fxdd.c +++ b/src/mesa/drivers/glide/fxdd.c @@ -1,4 +1,4 @@ -/* $Id: fxdd.c,v 1.88 2002/06/15 03:03:10 brianp Exp $ */ +/* $Id: fxdd.c,v 1.89 2002/07/09 01:22:51 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -288,6 +288,9 @@ fxDDSetDrawBuffer(GLcontext * ctx, GLenum mode) /* we'll need a software fallback */ /* XXX not implemented */ } + + /* update s/w fallback state */ + _swrast_DrawBuffer(ctx, mode); } @@ -991,7 +994,7 @@ fxSetupDDPointers(GLcontext * ctx) ctx->Driver.ClearIndex = NULL; ctx->Driver.ClearColor = fxDDClearColor; ctx->Driver.Clear = fxDDClear; - ctx->Driver.SetDrawBuffer = fxDDSetDrawBuffer; + ctx->Driver.DrawBuffer = fxDDSetDrawBuffer; ctx->Driver.GetBufferSize = fxDDBufferSize; ctx->Driver.Accum = _swrast_Accum; ctx->Driver.Bitmap = fxDDDrawBitmap; diff --git a/src/mesa/drivers/glide/fxddspan.c b/src/mesa/drivers/glide/fxddspan.c index 1ee7873efaf..98aabc5c0d1 100644 --- a/src/mesa/drivers/glide/fxddspan.c +++ b/src/mesa/drivers/glide/fxddspan.c @@ -1,4 +1,4 @@ -/* $Id: fxddspan.c,v 1.19 2001/09/23 16:50:01 brianp Exp $ */ +/* $Id: fxddspan.c,v 1.20 2002/07/09 01:22:51 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -536,7 +536,7 @@ fxDDReadDepthPixels(GLcontext * ctx, GLuint n, /* Set the buffer used for reading */ /* XXX support for separate read/draw buffers hasn't been tested */ static void -fxDDSetReadBuffer(GLcontext * ctx, GLframebuffer * buffer, GLenum mode) +fxDDSetBuffer(GLcontext * ctx, GLframebuffer * buffer, GLenum mode) { fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx; (void) buffer; @@ -565,7 +565,7 @@ fxSetupDDSpanPointers(GLcontext * ctx) { struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx ); - swdd->SetReadBuffer = fxDDSetReadBuffer; + swdd->SetBuffer = fxDDSetBuffer; swdd->WriteRGBASpan = fxDDWriteRGBASpan; swdd->WriteRGBSpan = fxDDWriteRGBSpan; diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index 20847f62861..8a80ab75971 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -1,4 +1,4 @@ -/* $Id: osmesa.c,v 1.85 2002/06/30 16:07:18 brianp Exp $ */ +/* $Id: osmesa.c,v 1.86 2002/07/09 01:22:51 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -721,14 +721,7 @@ do { \ -static void set_draw_buffer( GLcontext *ctx, GLenum mode ) -{ - (void) ctx; - (void) mode; -} - - -static void set_read_buffer( GLcontext *ctx, GLframebuffer *buffer, GLenum mode ) +static void set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLenum mode ) { /* separate read buffer not supported */ ASSERT(buffer == ctx->DrawBuffer); @@ -1887,7 +1880,6 @@ static void smooth_rgba_z_triangle( GLcontext *ctx, const SWvertex *v2 ) { const OSMesaContext osmesa = OSMESA_CONTEXT(ctx); - #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 @@ -1903,7 +1895,7 @@ static void smooth_rgba_z_triangle( GLcontext *ctx, FixedToChan(span->alpha)); \ zRow[i] = z; \ } \ - span->red += span->redStep; \ + span->red += span->redStep; \ span->green += span->greenStep; \ span->blue += span->blueStep; \ span->alpha += span->alphaStep; \ @@ -2080,7 +2072,6 @@ static void osmesa_update_state( GLcontext *ctx, GLuint new_state ) ctx->Driver.GetString = get_string; ctx->Driver.UpdateState = osmesa_update_state; - ctx->Driver.SetDrawBuffer = set_draw_buffer; ctx->Driver.ResizeBuffers = _swrast_alloc_buffers; ctx->Driver.GetBufferSize = buffer_size; @@ -2090,6 +2081,7 @@ static void osmesa_update_state( GLcontext *ctx, GLuint new_state ) ctx->Driver.CopyPixels = _swrast_CopyPixels; ctx->Driver.DrawPixels = _swrast_DrawPixels; ctx->Driver.ReadPixels = _swrast_ReadPixels; + ctx->Driver.DrawBuffer = _swrast_DrawBuffer; ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format; ctx->Driver.TexImage1D = _mesa_store_teximage1d; @@ -2114,6 +2106,8 @@ static void osmesa_update_state( GLcontext *ctx, GLuint new_state ) ctx->Driver.CompressedTextureSize = _mesa_compressed_texture_size; ctx->Driver.GetCompressedTexImage = _mesa_get_compressed_teximage; + swdd->SetBuffer = set_buffer; + /* RGB(A) span/pixel functions */ if (osmesa->format == OSMESA_RGB) { swdd->WriteRGBASpan = write_rgba_span_RGB; @@ -2171,8 +2165,6 @@ static void osmesa_update_state( GLcontext *ctx, GLuint new_state ) swdd->ReadCI32Span = read_index_span; swdd->ReadCI32Pixels = read_index_pixels; - swdd->SetReadBuffer = set_read_buffer; - tnl->Driver.RunPipeline = _tnl_run_pipeline; _swrast_InvalidateState( ctx, new_state ); diff --git a/src/mesa/drivers/svga/svgamesa.c b/src/mesa/drivers/svga/svgamesa.c index 5d2e3d55a23..270455ee691 100644 --- a/src/mesa/drivers/svga/svgamesa.c +++ b/src/mesa/drivers/svga/svgamesa.c @@ -1,4 +1,4 @@ -/* $Id: svgamesa.c,v 1.19 2002/06/15 02:38:17 brianp Exp $ */ +/* $Id: svgamesa.c,v 1.20 2002/07/09 01:22:51 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -217,34 +217,9 @@ static void get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *heigh *height = SVGAMesa->height = vga_getydim(); } -static void set_draw_buffer( GLcontext *ctx, GLenum buffer ) -{ - if (buffer == GL_FRONT_LEFT) { - SVGABuffer.DrawBuffer = SVGABuffer.FrontBuffer; -#if 0 - /* vga_waitretrace(); */ - void * tmpptr; - copy_buffer(SVGABuffer.FrontBuffer); - tmpptr=SVGABuffer.BackBuffer; - SVGABuffer.BackBuffer=SVGABuffer.FrontBuffer; - SVGABuffer.FrontBuffer=tmpptr; -#endif - } - else if (buffer == GL_BACK_LEFT) { - SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer; -#if 0 - /* vga_waitretrace(); */ - copy_buffer(SVGABuffer.BackBuffer); -#endif - } - else { - /* nothing since we don't have any point/line/triangle functions. */ - } -} - -static void set_read_buffer( GLcontext *ctx, GLframebuffer *colorBuffer, - GLenum buffer ) +static void set_buffer( GLcontext *ctx, GLframebuffer *colorBuffer, + GLenum buffer ) { /* We can ignore colorBuffer since we don't support a MakeCurrentRead() * function. @@ -253,6 +228,7 @@ static void set_read_buffer( GLcontext *ctx, GLframebuffer *colorBuffer, if (buffer == GL_FRONT_LEFT) { SVGABuffer.ReadBuffer = SVGABuffer.FrontBuffer; + SVGABuffer.DrawBuffer = SVGABuffer.FrontBuffer; #if 0 void * tmpptr; /* vga_waitretrace(); */ @@ -264,6 +240,7 @@ static void set_read_buffer( GLcontext *ctx, GLframebuffer *colorBuffer, } else if (buffer == GL_BACK_LEFT) { SVGABuffer.ReadBuffer = SVGABuffer.BackBuffer; + SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer; #if 0 /* vga_waitretrace(); */ copy_buffer(SVGABuffer.BackBuffer); @@ -285,7 +262,6 @@ static void svgamesa_update_state( GLcontext *ctx, GLuint new_state ) ctx->Driver.UpdateState = svgamesa_update_state; ctx->Driver.GetBufferSize = get_buffer_size; - ctx->Driver.SetDrawBuffer = set_draw_buffer; ctx->Driver.ResizeBuffers = _swrast_alloc_buffers; /* Software rasterizer pixel paths: @@ -295,10 +271,11 @@ static void svgamesa_update_state( GLcontext *ctx, GLuint new_state ) ctx->Driver.CopyPixels = _swrast_CopyPixels; ctx->Driver.DrawPixels = _swrast_DrawPixels; ctx->Driver.ReadPixels = _swrast_ReadPixels; + ctx->Driver.DrawBuffer = _swrast_DrawBuffer; /* Fill in the swrast driver interface: */ - swdd->SetReadBuffer = set_read_buffer; + swdd->SetBuffer = set_buffer; switch (SVGABuffer.Depth) { case 8: ctx->Driver.ClearIndex = __clear_index8; diff --git a/src/mesa/drivers/windows/wmesa.c b/src/mesa/drivers/windows/wmesa.c index 09fa23737f9..35a670096aa 100644 --- a/src/mesa/drivers/windows/wmesa.c +++ b/src/mesa/drivers/windows/wmesa.c @@ -1,4 +1,4 @@ -/* $Id: wmesa.c,v 1.31 2002/06/15 03:03:10 brianp Exp $ */ +/* $Id: wmesa.c,v 1.32 2002/07/09 01:22:51 brianp Exp $ */ /* * Windows (Win32) device driver for Mesa 3.4 @@ -569,20 +569,12 @@ static void enable( GLcontext* ctx, GLenum pname, GLboolean enable ) } } -static void set_draw_buffer( GLcontext* ctx, GLenum mode ) -{ - /* XXX doing nothing for now */ - /* if front buffer, fine */ - /* if back buffer, fine */ - /* else, check swrast->_RasterMask & MULTI_DRAW_BIT, if true, */ - /* use a swrast fallback function */ -} -static void set_read_buffer(GLcontext *ctx, GLframebuffer *colorBuffer, - GLenum buffer ) +static void set_buffer(GLcontext *ctx, GLframebuffer *colorBuffer, + GLenum buffer ) { - /* XXX todo */ + /* XXX todo - examine buffer and set read/write pointers */ return; } @@ -1027,7 +1019,6 @@ static void SetFunctionPointers(GLcontext *ctx) struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx ); ctx->Driver.GetString = get_string; ctx->Driver.UpdateState = wmesa_update_state; - ctx->Driver.SetDrawBuffer = set_draw_buffer; ctx->Driver.ResizeBuffers = _swrast_alloc_buffers; ctx->Driver.GetBufferSize = buffer_size; @@ -1043,6 +1034,7 @@ static void SetFunctionPointers(GLcontext *ctx) ctx->Driver.CopyPixels = _swrast_CopyPixels; ctx->Driver.DrawPixels = _swrast_DrawPixels; ctx->Driver.ReadPixels = _swrast_ReadPixels; + ctx->Driver.DrawBuffer = _swrast_DrawBuffer; ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format; ctx->Driver.TexImage1D = _mesa_store_teximage1d; @@ -1068,7 +1060,7 @@ static void SetFunctionPointers(GLcontext *ctx) ctx->Driver.GetCompressedTexImage = _mesa_get_compressed_teximage; - swdd->SetReadBuffer = set_read_buffer; + swdd->SetBuffer = set_buffer; /* Pixel/span writing functions: */ @@ -1106,7 +1098,6 @@ static void wmesa_update_state( GLcontext *ctx, GLuint new_state ) #if 0 ctx->Driver.GetString = get_string; ctx->Driver.UpdateState = wmesa_update_state; - ctx->Driver.SetDrawBuffer = set_draw_buffer; ctx->Driver.ResizeBuffers = _swrast_alloc_buffers; ctx->Driver.GetBufferSize = buffer_size; @@ -1145,10 +1136,8 @@ static void wmesa_update_state( GLcontext *ctx, GLuint new_state ) ctx->Driver.BaseCompressedTexFormat = _mesa_base_compressed_texformat; ctx->Driver.CompressedTextureSize = _mesa_compressed_texture_size; ctx->Driver.GetCompressedTexImage = _mesa_get_compressed_teximage; - - - swdd->SetReadBuffer = set_read_buffer; - + + swdd->SetBuffer = set_buffer; /* Pixel/span writing functions: */ swdd->WriteRGBASpan = write_rgba_span; diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index 1ef83c12cfe..4d74281bf92 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -1,4 +1,4 @@ -/* $Id: xm_api.c,v 1.39 2002/06/17 23:38:14 brianp Exp $ */ +/* $Id: xm_api.c,v 1.40 2002/07/09 01:22:51 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1654,6 +1654,8 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) } c->xm_visual = v; + c->xm_draw_buffer = NULL; /* set later by XMesaMakeCurrent */ + c->xm_read_buffer = NULL; /* set later by XMesaMakeCurrent */ c->xm_buffer = NULL; /* set later by XMesaMakeCurrent */ c->display = v->display; c->pixelformat = v->dithered_pf; /* Dithering is enabled by default */ @@ -1682,8 +1684,8 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) void XMesaDestroyContext( XMesaContext c ) { #ifdef FX - if (c->xm_buffer && c->xm_buffer->FXctx) - fxMesaDestroyContext(c->xm_buffer->FXctx); + if (c->xm_draw_buffer && c->xm_buffer->FXctx) + fxMesaDestroyContext(c->xm_draw_buffer->FXctx); #endif if (c->gl_ctx) { _swsetup_DestroyContext( c->gl_ctx ); @@ -2045,24 +2047,24 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, if (drawBuffer->FXctx) { fxMesaMakeCurrent(drawBuffer->FXctx); - c->xm_buffer = drawBuffer; + c->xm_draw_buffer = drawBuffer; c->xm_read_buffer = readBuffer; - c->use_read_buffer = (drawBuffer != readBuffer); + c->xm_buffer = drawBuffer; return GL_TRUE; } #endif if (c->gl_ctx == _mesa_get_current_context() - && c->xm_buffer == drawBuffer + && c->xm_draw_buffer == drawBuffer && c->xm_read_buffer == readBuffer - && c->xm_buffer->wasCurrent) { + && c->xm_draw_buffer->wasCurrent) { /* same context and buffer, do nothing */ return GL_TRUE; } - c->xm_buffer = drawBuffer; + c->xm_draw_buffer = drawBuffer; c->xm_read_buffer = readBuffer; - c->use_read_buffer = (drawBuffer != readBuffer); + c->xm_buffer = drawBuffer; _mesa_make_current2(c->gl_ctx, &drawBuffer->mesa_buffer, @@ -2086,11 +2088,11 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, c->clearcolor[2], c->clearcolor[3], c->xm_visual->undithered_pf); - XMesaSetForeground(c->display, c->xm_buffer->cleargc, c->clearpixel); + XMesaSetForeground(c->display, c->xm_draw_buffer->cleargc, c->clearpixel); } /* Solution to Stephane Rehel's problem with glXReleaseBuffersMESA(): */ - c->xm_buffer->wasCurrent = GL_TRUE; + c->xm_draw_buffer->wasCurrent = GL_TRUE; } else { /* Detach */ @@ -2128,7 +2130,7 @@ XMesaBuffer XMesaGetCurrentBuffer( void ) GET_CURRENT_CONTEXT(ctx); if (ctx) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - return xmesa->xm_buffer; + return xmesa->xm_draw_buffer; } else { return 0; @@ -2142,7 +2144,7 @@ XMesaBuffer XMesaGetCurrentReadBuffer( void ) GET_CURRENT_CONTEXT(ctx); if (ctx) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - return xmesa->xm_buffer; + return xmesa->xm_read_buffer; } else { return 0; @@ -2154,7 +2156,7 @@ GLboolean XMesaForceCurrent(XMesaContext c) { if (c) { if (c->gl_ctx != _mesa_get_current_context()) { - _mesa_make_current(c->gl_ctx, &c->xm_buffer->mesa_buffer); + _mesa_make_current(c->gl_ctx, &c->xm_draw_buffer->mesa_buffer); } } else { @@ -2193,15 +2195,15 @@ GLboolean XMesaSetFXmode( GLint mode ) if (ctx) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; if (mode == XMESA_FX_WINDOW) { - if (xmesa->xm_buffer->FXisHackUsable) { + if (xmesa->xm_draw_buffer->FXisHackUsable) { FX_grSstControl(GR_CONTROL_DEACTIVATE); - xmesa->xm_buffer->FXwindowHack = GL_TRUE; + xmesa->xm_draw_buffer->FXwindowHack = GL_TRUE; return GL_TRUE; } } else if (mode == XMESA_FX_FULLSCREEN) { FX_grSstControl(GR_CONTROL_ACTIVATE); - xmesa->xm_buffer->FXwindowHack = GL_FALSE; + xmesa->xm_draw_buffer->FXwindowHack = GL_FALSE; return GL_TRUE; } else { @@ -2232,7 +2234,7 @@ static void FXgetImage( XMesaBuffer b ) unsigned int bw, depth, width, height; XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - assert(xmesa->xm_buffer->FXctx); + assert(xmesa->xm_draw_buffer->FXctx); #ifdef XFree86Server x = b->frontbuffer->x; @@ -2245,8 +2247,8 @@ static void FXgetImage( XMesaBuffer b ) &root, &xpos, &ypos, &width, &height, &bw, &depth); #endif if (b->width != width || b->height != height) { - b->width = MIN2((int)width, xmesa->xm_buffer->FXctx->width); - b->height = MIN2((int)height, xmesa->xm_buffer->FXctx->height); + b->width = MIN2((int)width, xmesa->xm_draw_buffer->FXctx->width); + b->height = MIN2((int)height, xmesa->xm_draw_buffer->FXctx->height); if (b->width & 1) b->width--; /* prevent odd width */ xmesa_alloc_back_buffer( b ); @@ -2256,7 +2258,7 @@ static void FXgetImage( XMesaBuffer b ) if (xmesa->xm_visual->undithered_pf==PF_5R6G5B) { /* Special case: 16bpp RGB */ grLfbReadRegion( GR_BUFFER_FRONTBUFFER, /* src buffer */ - 0, xmesa->xm_buffer->FXctx->height - b->height, /*pos*/ + 0, xmesa->xm_draw_buffer->FXctx->height - b->height, /*pos*/ b->width, b->height, /* size */ b->width * sizeof(GLushort), /* stride */ b->backimage->data); /* dest buffer */ @@ -2265,13 +2267,13 @@ static void FXgetImage( XMesaBuffer b ) && GET_VISUAL_DEPTH(xmesa->xm_visual)==8) { /* Special case: 8bpp RGB */ for (y=0;y<b->height;y++) { - GLubyte *ptr = (GLubyte*) xmesa->xm_buffer->backimage->data - + xmesa->xm_buffer->backimage->bytes_per_line * y; + GLubyte *ptr = (GLubyte*) xmesa->xm_draw_buffer->backimage->data + + xmesa->xm_draw_buffer->backimage->bytes_per_line * y; XDITHER_SETUP(y); /* read row from 3Dfx frame buffer */ grLfbReadRegion( GR_BUFFER_FRONTBUFFER, - 0, xmesa->xm_buffer->FXctx->height-(b->height-y), + 0, xmesa->xm_draw_buffer->FXctx->height-(b->height-y), b->width, 1, 0, pixbuf ); @@ -2290,7 +2292,7 @@ static void FXgetImage( XMesaBuffer b ) for (y=0;y<b->height;y++) { /* read row from 3Dfx frame buffer */ grLfbReadRegion( GR_BUFFER_FRONTBUFFER, - 0, xmesa->xm_buffer->FXctx->height-(b->height-y), + 0, xmesa->xm_draw_buffer->FXctx->height-(b->height-y), b->width, 1, 0, pixbuf ); diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index c10afede922..8aa10ae8057 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -1,4 +1,4 @@ -/* $Id: xm_dd.c,v 1.33 2002/06/19 21:49:37 brianp Exp $ */ +/* $Id: xm_dd.c,v 1.34 2002/07/09 01:22:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -116,74 +116,51 @@ flush( GLcontext *ctx ) } -static void -set_draw_buffer( GLcontext *ctx, GLenum mode ) -{ - const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - if (mode == GL_FRONT_LEFT) { - /* write to front buffer */ - xmesa->xm_buffer->buffer = xmesa->xm_buffer->frontbuffer; - xmesa_update_span_funcs(ctx); - } - else if (mode==GL_BACK_LEFT && xmesa->xm_buffer->db_state) { - /* write to back buffer */ - if (xmesa->xm_buffer->backpixmap) { - xmesa->xm_buffer->buffer = - (XMesaDrawable)xmesa->xm_buffer->backpixmap; - } - else if (xmesa->xm_buffer->backimage) { - xmesa->xm_buffer->buffer = None; - } - else { - /* just in case there wasn't enough memory for back buffer */ - xmesa->xm_buffer->buffer = xmesa->xm_buffer->frontbuffer; - } - xmesa_update_span_funcs(ctx); - } - else { - /* the swrast->_RasterMask MULTI_DRAW_BIT will be set and - * we'll fall back to swrast to draw points/lines/triangles. - */ - } -} - -void -xmesa_set_read_buffer( GLcontext *ctx, GLframebuffer *buffer, GLenum mode ) +/* + * This chooses the color buffer for reading and writing spans, points, + * lines, and triangles. + */ +static void +set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLenum mode ) { - XMesaBuffer target; + /* We can make this cast since the XMesaBuffer wraps GLframebuffer. + * GLframebuffer is the first member in a XMesaBuffer struct. + */ + XMesaBuffer target = (XMesaBuffer) buffer; const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - if (buffer == ctx->DrawBuffer) { - target = xmesa->xm_buffer; - xmesa->use_read_buffer = GL_FALSE; - } - else { - ASSERT(buffer == ctx->ReadBuffer); - target = xmesa->xm_read_buffer; - xmesa->use_read_buffer = GL_TRUE; - } + /* This assignment tells the span/point/line/triangle functions + * which XMesaBuffer to use. + */ + xmesa->xm_buffer = target; + /* + * Now determine front vs back color buffer. + */ if (mode == GL_FRONT_LEFT) { target->buffer = target->frontbuffer; - xmesa_update_span_funcs(ctx); } - else if (mode==GL_BACK_LEFT && xmesa->xm_read_buffer->db_state) { + else if (mode == GL_BACK_LEFT) { + ASSERT(target->db_state); if (target->backpixmap) { - target->buffer = (XMesaDrawable)xmesa->xm_buffer->backpixmap; + /* back buffer is a pixmape */ + target->buffer = target->backpixmap; } else if (target->backimage) { + /* back buffer is an XImage */ target->buffer = None; } else { - /* just in case there wasn't enough memory for back buffer */ + /* No back buffer!!!! Must be out of memory, use front buffer */ target->buffer = target->frontbuffer; } - xmesa_update_span_funcs(ctx); } else { - _mesa_problem(ctx, "invalid buffer in set_read_buffer() in xmesa2.c"); + _mesa_problem(ctx, "invalid buffer in set_buffer() in xmesa2.c"); + return; } + xmesa_update_span_funcs(ctx); } @@ -193,7 +170,7 @@ clear_index( GLcontext *ctx, GLuint index ) { const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; xmesa->clearpixel = (unsigned long) index; - XMesaSetForeground( xmesa->display, xmesa->xm_buffer->cleargc, + XMesaSetForeground( xmesa->display, xmesa->xm_draw_buffer->cleargc, (unsigned long) index ); } @@ -210,7 +187,7 @@ clear_color( GLcontext *ctx, const GLchan color[4] ) color[2], color[3], xmesa->xm_visual->undithered_pf ); _glthread_LOCK_MUTEX(_xmesa_lock); - XMesaSetForeground( xmesa->display, xmesa->xm_buffer->cleargc, + XMesaSetForeground( xmesa->display, xmesa->xm_draw_buffer->cleargc, xmesa->clearpixel ); _glthread_UNLOCK_MUTEX(_xmesa_lock); } @@ -222,7 +199,7 @@ static void index_mask( GLcontext *ctx, GLuint mask ) { const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - if (xmesa->xm_buffer->buffer != XIMAGE) { + if (xmesa->xm_draw_buffer->buffer != XIMAGE) { unsigned long m; if (mask==0xffffffff) { m = ((unsigned long)~0L); @@ -230,7 +207,7 @@ index_mask( GLcontext *ctx, GLuint mask ) else { m = (unsigned long) mask; } - XMesaSetPlaneMask( xmesa->display, xmesa->xm_buffer->cleargc, m ); + XMesaSetPlaneMask( xmesa->display, xmesa->xm_draw_buffer->cleargc, m ); } } @@ -255,7 +232,7 @@ color_mask(GLcontext *ctx, if (gmask) m |= GET_GREENMASK(xmesa->xm_visual); if (bmask) m |= GET_BLUEMASK(xmesa->xm_visual); } - XMesaSetPlaneMask( xmesa->display, xmesa->xm_buffer->cleargc, m ); + XMesaSetPlaneMask( xmesa->display, xmesa->xm_draw_buffer->cleargc, m ); } } @@ -272,16 +249,16 @@ clear_front_pixmap( GLcontext *ctx, GLboolean all, { const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; if (all) { - XMesaFillRectangle( xmesa->display, xmesa->xm_buffer->frontbuffer, - xmesa->xm_buffer->cleargc, + XMesaFillRectangle( xmesa->display, xmesa->xm_draw_buffer->frontbuffer, + xmesa->xm_draw_buffer->cleargc, 0, 0, - xmesa->xm_buffer->width+1, - xmesa->xm_buffer->height+1 ); + xmesa->xm_draw_buffer->width+1, + xmesa->xm_draw_buffer->height+1 ); } else { - XMesaFillRectangle( xmesa->display, xmesa->xm_buffer->frontbuffer, - xmesa->xm_buffer->cleargc, - x, xmesa->xm_buffer->height - y - height, + XMesaFillRectangle( xmesa->display, xmesa->xm_draw_buffer->frontbuffer, + xmesa->xm_draw_buffer->cleargc, + x, xmesa->xm_draw_buffer->height - y - height, width, height ); } } @@ -293,16 +270,16 @@ clear_back_pixmap( GLcontext *ctx, GLboolean all, { const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; if (all) { - XMesaFillRectangle( xmesa->display, xmesa->xm_buffer->backpixmap, - xmesa->xm_buffer->cleargc, + XMesaFillRectangle( xmesa->display, xmesa->xm_draw_buffer->backpixmap, + xmesa->xm_draw_buffer->cleargc, 0, 0, - xmesa->xm_buffer->width+1, - xmesa->xm_buffer->height+1 ); + xmesa->xm_draw_buffer->width+1, + xmesa->xm_draw_buffer->height+1 ); } else { - XMesaFillRectangle( xmesa->display, xmesa->xm_buffer->backpixmap, - xmesa->xm_buffer->cleargc, - x, xmesa->xm_buffer->height - y - height, + XMesaFillRectangle( xmesa->display, xmesa->xm_draw_buffer->backpixmap, + xmesa->xm_draw_buffer->cleargc, + x, xmesa->xm_draw_buffer->height - y - height, width, height ); } } @@ -314,14 +291,14 @@ clear_8bit_ximage( GLcontext *ctx, GLboolean all, { const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; if (all) { - size_t n = xmesa->xm_buffer->backimage->bytes_per_line - * xmesa->xm_buffer->backimage->height; - MEMSET( xmesa->xm_buffer->backimage->data, xmesa->clearpixel, n ); + size_t n = xmesa->xm_draw_buffer->backimage->bytes_per_line + * xmesa->xm_draw_buffer->backimage->height; + MEMSET( xmesa->xm_draw_buffer->backimage->data, xmesa->clearpixel, n ); } else { GLint i; for (i=0;i<height;i++) { - GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y+i ); + GLubyte *ptr = PIXELADDR1( xmesa->xm_draw_buffer, x, y+i ); MEMSET( ptr, xmesa->clearpixel, width ); } } @@ -334,9 +311,9 @@ clear_HPCR_ximage( GLcontext *ctx, GLboolean all, { const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; if (all) { - GLint i, c16 = (xmesa->xm_buffer->backimage->bytes_per_line>>4)<<4; - GLubyte *ptr = (GLubyte *)xmesa->xm_buffer->backimage->data; - for (i=0; i<xmesa->xm_buffer->backimage->height; i++) { + GLint i, c16 = (xmesa->xm_draw_buffer->backimage->bytes_per_line>>4)<<4; + GLubyte *ptr = (GLubyte *)xmesa->xm_draw_buffer->backimage->data; + for (i=0; i<xmesa->xm_draw_buffer->backimage->height; i++) { GLint j; GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0]; if (i&1) { @@ -361,7 +338,7 @@ clear_HPCR_ximage( GLcontext *ctx, GLboolean all, ptr[15] = sptr[15]; ptr += 16; } - for (; j<xmesa->xm_buffer->backimage->bytes_per_line; j++) { + for (; j<xmesa->xm_draw_buffer->backimage->bytes_per_line; j++) { *ptr = sptr[j&15]; ptr++; } @@ -370,7 +347,7 @@ clear_HPCR_ximage( GLcontext *ctx, GLboolean all, else { GLint i; for (i=y; i<y+height; i++) { - GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, i ); + GLubyte *ptr = PIXELADDR1( xmesa->xm_draw_buffer, x, i ); int j; GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0]; if (i&1) { @@ -396,31 +373,31 @@ clear_16bit_ximage( GLcontext *ctx, GLboolean all, } if (all) { register GLuint n; - register GLuint *ptr4 = (GLuint *) xmesa->xm_buffer->backimage->data; + register GLuint *ptr4 = (GLuint *) xmesa->xm_draw_buffer->backimage->data; if ((pixel & 0xff) == ((pixel >> 8) & 0xff)) { /* low and high bytes are equal so use memset() */ - n = xmesa->xm_buffer->backimage->bytes_per_line - * xmesa->xm_buffer->height; + n = xmesa->xm_draw_buffer->backimage->bytes_per_line + * xmesa->xm_draw_buffer->height; MEMSET( ptr4, pixel & 0xff, n ); } else { pixel = pixel | (pixel<<16); - n = xmesa->xm_buffer->backimage->bytes_per_line - * xmesa->xm_buffer->height / 4; + n = xmesa->xm_draw_buffer->backimage->bytes_per_line + * xmesa->xm_draw_buffer->height / 4; do { *ptr4++ = pixel; n--; } while (n!=0); - if ((xmesa->xm_buffer->backimage->bytes_per_line * - xmesa->xm_buffer->height) & 0x2) + if ((xmesa->xm_draw_buffer->backimage->bytes_per_line * + xmesa->xm_draw_buffer->height) & 0x2) *(GLushort *)ptr4 = pixel & 0xffff; } } else { register int i, j; for (j=0;j<height;j++) { - register GLushort *ptr2 = PIXELADDR2( xmesa->xm_buffer, x, y+j ); + register GLushort *ptr2 = PIXELADDR2( xmesa->xm_draw_buffer, x, y+j ); for (i=0;i<width;i++) { *ptr2++ = pixel; } @@ -449,21 +426,21 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all, if (all) { if (r==g && g==b) { /* same value for all three components (gray) */ - const GLint w3 = xmesa->xm_buffer->width * 3; - const GLint h = xmesa->xm_buffer->height; + const GLint w3 = xmesa->xm_draw_buffer->width * 3; + const GLint h = xmesa->xm_draw_buffer->height; GLint i; for (i = 0; i < h; i++) { - bgr_t *ptr3 = PIXELADDR3(xmesa->xm_buffer, 0, i); + bgr_t *ptr3 = PIXELADDR3(xmesa->xm_draw_buffer, 0, i); MEMSET(ptr3, r, w3); } } else { /* the usual case */ - const GLint w = xmesa->xm_buffer->width; - const GLint h = xmesa->xm_buffer->height; + const GLint w = xmesa->xm_draw_buffer->width; + const GLint h = xmesa->xm_draw_buffer->height; GLint i, j; for (i = 0; i < h; i++) { - bgr_t *ptr3 = PIXELADDR3(xmesa->xm_buffer, 0, i); + bgr_t *ptr3 = PIXELADDR3(xmesa->xm_draw_buffer, 0, i); for (j = 0; j < w; j++) { ptr3->r = r; ptr3->g = g; @@ -547,7 +524,7 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all, /* same value for all three components (gray) */ GLint j; for (j=0;j<height;j++) { - bgr_t *ptr3 = PIXELADDR3( xmesa->xm_buffer, x, y+j ); + bgr_t *ptr3 = PIXELADDR3( xmesa->xm_draw_buffer, x, y+j ); MEMSET(ptr3, r, 3 * width); } } @@ -555,7 +532,7 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all, /* non-gray clear color */ GLint i, j; for (j = 0; j < height; j++) { - bgr_t *ptr3 = PIXELADDR3( xmesa->xm_buffer, x, y+j ); + bgr_t *ptr3 = PIXELADDR3( xmesa->xm_draw_buffer, x, y+j ); for (i = 0; i < width; i++) { ptr3->r = r; ptr3->g = g; @@ -570,7 +547,7 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all, pixel4[1] = (clearPixel << 16) | (clearPixel >> 8); pixel4[2] = (clearPixel << 8) | (clearPixel >> 16); for (j=0;j<height;j++) { - bgr_t *ptr3 = PIXELADDR3( xmesa->xm_buffer, x, y+j ); + bgr_t *ptr3 = PIXELADDR3( xmesa->xm_draw_buffer, x, y+j ); register GLuint *ptr4 = (GLuint *)ptr3; register GLuint *p, px; GLuint w = width; @@ -653,8 +630,8 @@ clear_32bit_ximage( GLcontext *ctx, GLboolean all, | ((pixel << 24) & 0xff000000); } if (all) { - register GLint n = xmesa->xm_buffer->width * xmesa->xm_buffer->height; - register GLuint *ptr4 = (GLuint *) xmesa->xm_buffer->backimage->data; + register GLint n = xmesa->xm_draw_buffer->width * xmesa->xm_draw_buffer->height; + register GLuint *ptr4 = (GLuint *) xmesa->xm_draw_buffer->backimage->data; if (pixel==0) { MEMSET( ptr4, pixel, 4*n ); } @@ -668,7 +645,7 @@ clear_32bit_ximage( GLcontext *ctx, GLboolean all, else { register int i, j; for (j=0;j<height;j++) { - register GLuint *ptr4 = PIXELADDR4( xmesa->xm_buffer, x, y+j ); + register GLuint *ptr4 = PIXELADDR4( xmesa->xm_draw_buffer, x, y+j ); for (i=0;i<width;i++) { *ptr4++ = pixel; } @@ -682,11 +659,11 @@ clear_nbit_ximage( GLcontext *ctx, GLboolean all, GLint x, GLint y, GLint width, GLint height ) { const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - XMesaImage *img = xmesa->xm_buffer->backimage; + XMesaImage *img = xmesa->xm_draw_buffer->backimage; if (all) { register int i, j; - width = xmesa->xm_buffer->width; - height = xmesa->xm_buffer->height; + width = xmesa->xm_draw_buffer->width; + height = xmesa->xm_draw_buffer->height; for (j=0;j<height;j++) { for (i=0;i<width;i++) { XMesaPutPixel( img, i, j, xmesa->clearpixel ); @@ -696,7 +673,7 @@ clear_nbit_ximage( GLcontext *ctx, GLboolean all, else { /* TODO: optimize this */ register int i, j; - y = FLIP(xmesa->xm_buffer, y); + y = FLIP(xmesa->xm_draw_buffer, y); for (j=0;j<height;j++) { for (i=0;i<width;i++) { XMesaPutPixel( img, x+i, y-j, xmesa->clearpixel ); @@ -715,7 +692,7 @@ clear_buffers( GLcontext *ctx, GLbitfield mask, const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask; if ((mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) && - xmesa->xm_buffer->mesa_buffer.UseSoftwareAlphaBuffers && + xmesa->xm_draw_buffer->mesa_buffer.UseSoftwareAlphaBuffers && ctx->Color.ColorMask[ACOMP]) { _mesa_clear_alpha_buffers(ctx); } @@ -723,13 +700,13 @@ clear_buffers( GLcontext *ctx, GLbitfield mask, /* we can't handle color or index masking */ if (*colorMask == 0xffffffff && ctx->Color.IndexMask == 0xffffffff) { if (mask & DD_FRONT_LEFT_BIT) { - ASSERT(xmesa->xm_buffer->front_clear_func); - (*xmesa->xm_buffer->front_clear_func)( ctx, all, x, y, width, height ); + ASSERT(xmesa->xm_draw_buffer->front_clear_func); + (*xmesa->xm_draw_buffer->front_clear_func)( ctx, all, x, y, width, height ); mask &= ~DD_FRONT_LEFT_BIT; } if (mask & DD_BACK_LEFT_BIT) { - ASSERT(xmesa->xm_buffer->back_clear_func); - (*xmesa->xm_buffer->back_clear_func)( ctx, all, x, y, width, height ); + ASSERT(xmesa->xm_draw_buffer->back_clear_func); + (*xmesa->xm_draw_buffer->back_clear_func)( ctx, all, x, y, width, height ); mask &= ~DD_BACK_LEFT_BIT; } } @@ -802,8 +779,8 @@ drawpixels_8R8G8B( GLcontext *ctx, { const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; XMesaDisplay *dpy = xmesa->xm_visual->display; - XMesaDrawable buffer = xmesa->xm_buffer->buffer; - XMesaGC gc = xmesa->xm_buffer->gc; + XMesaDrawable buffer = xmesa->xm_draw_buffer->buffer; + XMesaGC gc = xmesa->xm_draw_buffer->gc; assert(dpy); assert(buffer); assert(gc); @@ -833,7 +810,7 @@ drawpixels_8R8G8B( GLcontext *ctx, ximage.red_mask = 0xff0000; ximage.green_mask = 0x00ff00; ximage.blue_mask = 0x0000ff; - dstY = FLIP(xmesa->xm_buffer,dstY) - height + 1; + dstY = FLIP(xmesa->xm_draw_buffer,dstY) - height + 1; XPutImage(dpy, buffer, gc, &ximage, srcX, srcY, dstX, dstY, w, h); return GL_TRUE; } @@ -899,33 +876,33 @@ void xmesa_update_state( GLcontext *ctx, GLuint new_state ) /* setup pointers to front and back buffer clear functions */ - xmesa->xm_buffer->front_clear_func = clear_front_pixmap; - if (xmesa->xm_buffer->backpixmap != XIMAGE) { - xmesa->xm_buffer->back_clear_func = clear_back_pixmap; + xmesa->xm_draw_buffer->front_clear_func = clear_front_pixmap; + if (xmesa->xm_draw_buffer->backpixmap != XIMAGE) { + xmesa->xm_draw_buffer->back_clear_func = clear_back_pixmap; } else if (sizeof(GLushort)!=2 || sizeof(GLuint)!=4) { - xmesa->xm_buffer->back_clear_func = clear_nbit_ximage; + xmesa->xm_draw_buffer->back_clear_func = clear_nbit_ximage; } else switch (xmesa->xm_visual->BitsPerPixel) { case 8: if (xmesa->xm_visual->hpcr_clear_flag) { - xmesa->xm_buffer->back_clear_func = clear_HPCR_ximage; + xmesa->xm_draw_buffer->back_clear_func = clear_HPCR_ximage; } else { - xmesa->xm_buffer->back_clear_func = clear_8bit_ximage; + xmesa->xm_draw_buffer->back_clear_func = clear_8bit_ximage; } break; case 16: - xmesa->xm_buffer->back_clear_func = clear_16bit_ximage; + xmesa->xm_draw_buffer->back_clear_func = clear_16bit_ximage; break; case 24: - xmesa->xm_buffer->back_clear_func = clear_24bit_ximage; + xmesa->xm_draw_buffer->back_clear_func = clear_24bit_ximage; break; case 32: - xmesa->xm_buffer->back_clear_func = clear_32bit_ximage; + xmesa->xm_draw_buffer->back_clear_func = clear_32bit_ximage; break; default: - xmesa->xm_buffer->back_clear_func = clear_nbit_ximage; + xmesa->xm_draw_buffer->back_clear_func = clear_nbit_ximage; break; } @@ -940,6 +917,7 @@ void xmesa_update_state( GLcontext *ctx, GLuint new_state ) void xmesa_init_pointers( GLcontext *ctx ) { TNLcontext *tnl; + struct swrast_device_driver *dd = _swrast_GetDeviceDriverReference( ctx ); ctx->Driver.GetString = get_string; ctx->Driver.GetBufferSize = get_buffer_size; @@ -955,6 +933,7 @@ void xmesa_init_pointers( GLcontext *ctx ) ctx->Driver.CopyPixels = _swrast_CopyPixels; ctx->Driver.DrawPixels = _swrast_DrawPixels; ctx->Driver.ReadPixels = _swrast_ReadPixels; + ctx->Driver.DrawBuffer = _swrast_DrawBuffer; /* Software texture functions: */ @@ -987,7 +966,6 @@ void xmesa_init_pointers( GLcontext *ctx ) /* Statechange callbacks: */ - ctx->Driver.SetDrawBuffer = set_draw_buffer; ctx->Driver.ClearIndex = clear_index; ctx->Driver.ClearColor = clear_color; ctx->Driver.IndexMask = index_mask; @@ -1000,6 +978,8 @@ void xmesa_init_pointers( GLcontext *ctx ) tnl = TNL_CONTEXT(ctx); tnl->Driver.RunPipeline = _tnl_run_pipeline; + dd->SetBuffer = set_buffer; + /* Install swsetup for tnl->Driver.Render.*: */ _swsetup_Wakeup(ctx); diff --git a/src/mesa/drivers/x11/xm_span.c b/src/mesa/drivers/x11/xm_span.c index cbb138a0b3c..eed8c91a968 100644 --- a/src/mesa/drivers/x11/xm_span.c +++ b/src/mesa/drivers/x11/xm_span.c @@ -1,4 +1,4 @@ -/* $Id: xm_span.c,v 1.14 2002/03/01 04:28:32 brianp Exp $ */ +/* $Id: xm_span.c,v 1.15 2002/07/09 01:22:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -3472,14 +3472,9 @@ static void read_index_span( const GLcontext *ctx, GLuint n, GLint x, GLint y, GLuint index[] ) { const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - XMesaBuffer source; + XMesaBuffer source = xmesa->xm_buffer; GLuint i; - if (xmesa->use_read_buffer) - source = xmesa->xm_read_buffer; - else - source = xmesa->xm_buffer; - y = FLIP(source, y); if (source->buffer) { @@ -3528,12 +3523,7 @@ static void read_color_span( const GLcontext *ctx, GLubyte rgba[][4] ) { const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - XMesaBuffer source; - - if (xmesa->use_read_buffer) - source = xmesa->xm_read_buffer; - else - source = xmesa->xm_buffer; + XMesaBuffer source = xmesa->xm_buffer; if (source->buffer) { /* Read from Pixmap or Window */ @@ -3902,12 +3892,7 @@ static void read_index_pixels( const GLcontext *ctx, { const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; register GLuint i; - XMesaBuffer source; - - if (xmesa->use_read_buffer) - source = xmesa->xm_read_buffer; - else - source = xmesa->xm_buffer; + XMesaBuffer source = xmesa->xm_buffer; if (source->buffer) { for (i=0;i<n;i++) { @@ -3937,15 +3922,8 @@ static void read_color_pixels( const GLcontext *ctx, const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; XMesaDisplay *dpy = xmesa->xm_visual->display; register GLuint i; - XMesaBuffer source; - XMesaDrawable buffer; - - if (xmesa->use_read_buffer) - source = xmesa->xm_read_buffer; - else - source = xmesa->xm_buffer; - - buffer = source->buffer; /* the X drawable */ + XMesaBuffer source = xmesa->xm_buffer; + XMesaDrawable buffer = source->buffer; /* the X drawable */ if (source->buffer) { switch (xmesa->pixelformat) { @@ -4491,6 +4469,4 @@ void xmesa_update_span_funcs( GLcontext *ctx ) dd->ReadRGBASpan = read_color_span; dd->ReadCI32Pixels = read_index_pixels; dd->ReadRGBAPixels = read_color_pixels; - - dd->SetReadBuffer = xmesa_set_read_buffer; } diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index ae90d995733..5e3ef9e8d97 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -1,4 +1,4 @@ -/* $Id: xmesaP.h,v 1.28 2002/05/27 17:06:59 brianp Exp $ */ +/* $Id: xmesaP.h,v 1.29 2002/07/09 01:22:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -120,9 +120,9 @@ struct xmesa_visual { struct xmesa_context { GLcontext *gl_ctx; /* the core library context */ XMesaVisual xm_visual; /* Describes the buffers */ - XMesaBuffer xm_buffer; /* current draw framebuffer */ + XMesaBuffer xm_draw_buffer; /* current draw framebuffer */ XMesaBuffer xm_read_buffer; /* current read framebuffer */ - GLboolean use_read_buffer; /* read from the xm_read_buffer/ */ + XMesaBuffer xm_buffer; /* current span/point/line/triangle buffer */ XMesaDisplay *display; /* == xm_visual->display */ GLboolean swapbytes; /* Host byte order != display byte order? */ @@ -149,6 +149,7 @@ typedef enum { */ struct xmesa_buffer { GLframebuffer mesa_buffer; /* depth, stencil, accum, etc buffers */ + /* This MUST BE FIRST! */ GLboolean wasCurrent; /* was ever the current buffer? */ XMesaVisual xm_visual; /* the X/Mesa visual */ @@ -536,9 +537,6 @@ extern GLboolean XMesaForceCurrent(XMesaContext c); extern GLboolean XMesaLoseCurrent(XMesaContext c); extern void XMesaReset( void ); -extern void xmesa_set_read_buffer( GLcontext *ctx, - GLframebuffer *buffer, GLenum mode ); - extern void xmesa_resize_buffers( GLframebuffer *buffer ); #endif diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index c549e2736c4..04a490ada5d 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -1,4 +1,4 @@ -/* $Id: buffers.c,v 1.36 2002/06/15 02:38:15 brianp Exp $ */ +/* $Id: buffers.c,v 1.37 2002/07/09 01:22:50 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -121,14 +121,14 @@ _mesa_Clear( GLbitfield mask ) /* don't clear depth buffer if depth writing disabled */ if (!ctx->Depth.Mask) - CLEAR_BITS(mask, GL_DEPTH_BUFFER_BIT); + mask &= ~GL_DEPTH_BUFFER_BIT; /* Build bitmask to send to driver Clear function */ ddMask = mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_ACCUM_BUFFER_BIT); if (mask & GL_COLOR_BUFFER_BIT) { - ddMask |= ctx->Color.DrawDestMask; + ddMask |= ctx->Color._DrawDestMask; } ASSERT(ctx->Driver.Clear); @@ -148,6 +148,9 @@ _mesa_DrawBuffer( GLenum mode ) if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(mode)); + /* + * Do error checking and compute the _DrawDestMask bitfield. + */ switch (mode) { case GL_AUX0: case GL_AUX1: @@ -161,16 +164,16 @@ _mesa_DrawBuffer( GLenum mode ) _mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" ); return;} if (ctx->Visual.doubleBufferMode) - ctx->Color.DrawDestMask = FRONT_RIGHT_BIT | BACK_RIGHT_BIT; + ctx->Color._DrawDestMask = FRONT_RIGHT_BIT | BACK_RIGHT_BIT; else - ctx->Color.DrawDestMask = FRONT_RIGHT_BIT; + ctx->Color._DrawDestMask = FRONT_RIGHT_BIT; break; case GL_FRONT_RIGHT: if (!ctx->Visual.stereoMode) { _mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" ); return; } - ctx->Color.DrawDestMask = FRONT_RIGHT_BIT; + ctx->Color._DrawDestMask = FRONT_RIGHT_BIT; break; case GL_BACK_RIGHT: if (!ctx->Visual.stereoMode) { @@ -181,14 +184,14 @@ _mesa_DrawBuffer( GLenum mode ) _mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" ); return; } - ctx->Color.DrawDestMask = BACK_RIGHT_BIT; + ctx->Color._DrawDestMask = BACK_RIGHT_BIT; break; case GL_BACK_LEFT: if (!ctx->Visual.doubleBufferMode) { _mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" ); return; } - ctx->Color.DrawDestMask = BACK_LEFT_BIT; + ctx->Color._DrawDestMask = BACK_LEFT_BIT; break; case GL_FRONT_AND_BACK: if (!ctx->Visual.doubleBufferMode) { @@ -196,10 +199,10 @@ _mesa_DrawBuffer( GLenum mode ) return; } if (ctx->Visual.stereoMode) - ctx->Color.DrawDestMask = FRONT_LEFT_BIT | BACK_LEFT_BIT + ctx->Color._DrawDestMask = FRONT_LEFT_BIT | BACK_LEFT_BIT | FRONT_RIGHT_BIT | BACK_RIGHT_BIT; else - ctx->Color.DrawDestMask = FRONT_LEFT_BIT | BACK_LEFT_BIT; + ctx->Color._DrawDestMask = FRONT_LEFT_BIT | BACK_LEFT_BIT; break; case GL_BACK: if (!ctx->Visual.doubleBufferMode) { @@ -207,74 +210,45 @@ _mesa_DrawBuffer( GLenum mode ) return; } if (ctx->Visual.stereoMode) - ctx->Color.DrawDestMask = BACK_LEFT_BIT | BACK_RIGHT_BIT; + ctx->Color._DrawDestMask = BACK_LEFT_BIT | BACK_RIGHT_BIT; else - ctx->Color.DrawDestMask = BACK_LEFT_BIT; + ctx->Color._DrawDestMask = BACK_LEFT_BIT; break; case GL_LEFT: /* never an error */ if (ctx->Visual.doubleBufferMode) - ctx->Color.DrawDestMask = FRONT_LEFT_BIT | BACK_LEFT_BIT; + ctx->Color._DrawDestMask = FRONT_LEFT_BIT | BACK_LEFT_BIT; else - ctx->Color.DrawDestMask = FRONT_LEFT_BIT; + ctx->Color._DrawDestMask = FRONT_LEFT_BIT; break; case GL_FRONT_LEFT: /* never an error */ - ctx->Color.DrawDestMask = FRONT_LEFT_BIT; + ctx->Color._DrawDestMask = FRONT_LEFT_BIT; break; case GL_FRONT: /* never an error */ if (ctx->Visual.stereoMode) - ctx->Color.DrawDestMask = FRONT_LEFT_BIT | FRONT_RIGHT_BIT; + ctx->Color._DrawDestMask = FRONT_LEFT_BIT | FRONT_RIGHT_BIT; else - ctx->Color.DrawDestMask = FRONT_LEFT_BIT; + ctx->Color._DrawDestMask = FRONT_LEFT_BIT; break; case GL_NONE: /* never an error */ - ctx->Color.DrawDestMask = 0; + ctx->Color._DrawDestMask = 0; break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glDrawBuffer" ); return; } - /* - * Make the dest buffer mode more precise if possible - */ - if (mode == GL_LEFT && !ctx->Visual.doubleBufferMode) - ctx->Color.DriverDrawBuffer = GL_FRONT_LEFT; - else if (mode == GL_RIGHT && !ctx->Visual.doubleBufferMode) - ctx->Color.DriverDrawBuffer = GL_FRONT_RIGHT; - else if (mode == GL_FRONT && !ctx->Visual.stereoMode) - ctx->Color.DriverDrawBuffer = GL_FRONT_LEFT; - else if (mode == GL_BACK && !ctx->Visual.stereoMode) - ctx->Color.DriverDrawBuffer = GL_BACK_LEFT; - else - ctx->Color.DriverDrawBuffer = mode; - - /* - * Set current alpha buffer pointer - */ - if (ctx->DrawBuffer->UseSoftwareAlphaBuffers) { - if (ctx->Color.DriverDrawBuffer == GL_FRONT_LEFT) - ctx->DrawBuffer->Alpha = ctx->DrawBuffer->FrontLeftAlpha; - else if (ctx->Color.DriverDrawBuffer == GL_BACK_LEFT) - ctx->DrawBuffer->Alpha = ctx->DrawBuffer->BackLeftAlpha; - else if (ctx->Color.DriverDrawBuffer == GL_FRONT_RIGHT) - ctx->DrawBuffer->Alpha = ctx->DrawBuffer->FrontRightAlpha; - else if (ctx->Color.DriverDrawBuffer == GL_BACK_RIGHT) - ctx->DrawBuffer->Alpha = ctx->DrawBuffer->BackRightAlpha; - } + ctx->Color.DrawBuffer = mode; + ctx->NewState |= _NEW_COLOR; /* - * If we get here there can't have been an error. Now tell the - * device driver about it. + * Call device driver function. */ - ASSERT(ctx->Driver.SetDrawBuffer); - (*ctx->Driver.SetDrawBuffer)(ctx, ctx->Color.DriverDrawBuffer); - - ctx->Color.DrawBuffer = mode; - ctx->NewState |= _NEW_COLOR; + if (ctx->Driver.DrawBuffer) + (*ctx->Driver.DrawBuffer)(ctx, mode); } @@ -300,7 +274,7 @@ _mesa_ReadBuffer( GLenum mode ) case GL_FRONT: case GL_FRONT_LEFT: /* Front-Left buffer, always exists */ - ctx->Pixel.DriverReadBuffer = GL_FRONT_LEFT; + ctx->Pixel._DriverReadBuffer = GL_FRONT_LEFT; break; case GL_BACK: case GL_BACK_LEFT: @@ -309,7 +283,7 @@ _mesa_ReadBuffer( GLenum mode ) _mesa_error( ctx, GL_INVALID_OPERATION, "glReadBuffer" ); return; } - ctx->Pixel.DriverReadBuffer = GL_BACK_LEFT; + ctx->Pixel._DriverReadBuffer = GL_BACK_LEFT; break; case GL_FRONT_RIGHT: case GL_RIGHT: @@ -317,14 +291,14 @@ _mesa_ReadBuffer( GLenum mode ) _mesa_error( ctx, GL_INVALID_OPERATION, "glReadBuffer" ); return; } - ctx->Pixel.DriverReadBuffer = GL_FRONT_RIGHT; + ctx->Pixel._DriverReadBuffer = GL_FRONT_RIGHT; break; case GL_BACK_RIGHT: if (!ctx->Visual.stereoMode || !ctx->Visual.doubleBufferMode) { _mesa_error( ctx, GL_INVALID_OPERATION, "glReadBuffer" ); return; } - ctx->Pixel.DriverReadBuffer = GL_BACK_RIGHT; + ctx->Pixel._DriverReadBuffer = GL_BACK_RIGHT; break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glReadBuffer" ); @@ -333,6 +307,12 @@ _mesa_ReadBuffer( GLenum mode ) ctx->Pixel.ReadBuffer = mode; ctx->NewState |= _NEW_PIXEL; + + /* + * Call device driver function. + */ + if (ctx->Driver.ReadBuffer) + (*ctx->Driver.ReadBuffer)(ctx, mode); } diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c index 417954369ae..88963dccc68 100644 --- a/src/mesa/main/colortab.c +++ b/src/mesa/main/colortab.c @@ -1,4 +1,4 @@ -/* $Id: colortab.c,v 1.44 2002/06/29 19:48:15 brianp Exp $ */ +/* $Id: colortab.c,v 1.45 2002/07/09 01:22:50 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -36,7 +36,6 @@ #include "mem.h" #include "mmath.h" #include "state.h" -#include "swrast/s_span.h" /* XXX SWRAST hack */ #endif diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 9a141d9db20..7fa32c601c0 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1,4 +1,4 @@ -/* $Id: context.c,v 1.174 2002/06/29 19:48:15 brianp Exp $ */ +/* $Id: context.c,v 1.175 2002/07/09 01:22:50 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -978,7 +978,6 @@ init_attrib_groups( GLcontext *ctx ) ctx->Color.ColorLogicOpEnabled = GL_FALSE; ctx->Color.LogicOp = GL_COPY; ctx->Color.DitherFlag = GL_TRUE; - ctx->Color.MultiDrawBuffer = GL_FALSE; /* Current group */ ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_WEIGHT], 0.0, 0.0, 0.0, 0.0 ); @@ -1689,17 +1688,17 @@ _mesa_initialize_context( GLcontext *ctx, if (visual->doubleBufferMode) { ctx->Color.DrawBuffer = GL_BACK; - ctx->Color.DriverDrawBuffer = GL_BACK_LEFT; - ctx->Color.DrawDestMask = BACK_LEFT_BIT; + ctx->Color._DriverDrawBuffer = GL_BACK_LEFT; + ctx->Color._DrawDestMask = BACK_LEFT_BIT; ctx->Pixel.ReadBuffer = GL_BACK; - ctx->Pixel.DriverReadBuffer = GL_BACK_LEFT; + ctx->Pixel._DriverReadBuffer = GL_BACK_LEFT; } else { ctx->Color.DrawBuffer = GL_FRONT; - ctx->Color.DriverDrawBuffer = GL_FRONT_LEFT; - ctx->Color.DrawDestMask = FRONT_LEFT_BIT; + ctx->Color._DriverDrawBuffer = GL_FRONT_LEFT; + ctx->Color._DrawDestMask = FRONT_LEFT_BIT; ctx->Pixel.ReadBuffer = GL_FRONT; - ctx->Pixel.DriverReadBuffer = GL_FRONT_LEFT; + ctx->Pixel._DriverReadBuffer = GL_FRONT_LEFT; } if (!alloc_proxy_textures(ctx)) { @@ -1716,6 +1715,8 @@ _mesa_initialize_context( GLcontext *ctx, _glapi_add_entrypoint("glCompressedTexSubImage2DARB", 558); _glapi_add_entrypoint("glCompressedTexSubImage1DARB", 559); _glapi_add_entrypoint("glGetCompressedTexImageARB", 560); + /* XXX we should add a bunch of new functions here */ + /* Find the larger of Mesa's dispatch table and libGL's dispatch table. * In practice, this'll be the same for stand-alone Mesa. But for DRI diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c index cf88bbcb7d2..ce01a121871 100644 --- a/src/mesa/main/convolve.c +++ b/src/mesa/main/convolve.c @@ -1,4 +1,4 @@ -/* $Id: convolve.c,v 1.26 2002/03/19 15:22:50 brianp Exp $ */ +/* $Id: convolve.c,v 1.27 2002/07/09 01:22:50 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -43,7 +43,6 @@ #include "image.h" #include "mtypes.h" #include "state.h" -#include "swrast/s_span.h" /* XXX SWRAST hack */ #endif diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 1a100102ae4..81ae9e4a125 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -1,4 +1,4 @@ -/* $Id: dd.h,v 1.69 2002/06/15 02:38:15 brianp Exp $ */ +/* $Id: dd.h,v 1.70 2002/07/09 01:22:50 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -48,11 +48,6 @@ struct gl_pixelstore_attrib; */ struct dd_function_table { - /********************************************************************** - *** Mandatory functions: these functions must be implemented by *** - *** every device driver. *** - **********************************************************************/ - const GLubyte * (*GetString)( GLcontext *ctx, GLenum name ); /* Return a string as needed by glGetString(). * Only the GL_RENDERER token must be implemented. Otherwise, @@ -74,28 +69,23 @@ struct dd_function_table { * If 'all' is true then the clear the whole buffer, else clear only the * region defined by (x,y,width,height). * This function must obey the glColorMask, glIndexMask and glStencilMask - * settings! Software Mesa can do masked clears if the device driver can't. + * settings! + * Software Mesa can do masked clears if the device driver can't. */ - void (*SetDrawBuffer)( GLcontext *ctx, GLenum buffer ); + void (*DrawBuffer)( GLcontext *ctx, GLenum buffer ); /* - * Specifies the current buffer for writing. - * The following values must be accepted when applicable: - * GL_FRONT_LEFT - this buffer always exists - * GL_BACK_LEFT - when double buffering - * GL_FRONT_RIGHT - when using stereo - * GL_BACK_RIGHT - when using stereo and double buffering - * GL_FRONT - write to front left and front right if it exists - * GL_BACK - write to back left and back right if it exists - * GL_LEFT - write to front left and back left if it exists - * GL_RIGHT - write to right left and back right if they exist - * GL_FRONT_AND_BACK - write to all four buffers if they exist - * GL_NONE - disable buffer write in device driver. - * + * Specifies the current buffer for writing. Called via glDrawBuffer(). * Note the driver must organize fallbacks (eg with swrast) if it * cannot implement the requested mode. */ + + void (*ReadBuffer)( GLcontext *ctx, GLenum buffer ); + /* + * Specifies the current buffer for reading. Called via glReadBuffer(). + */ + void (*GetBufferSize)( GLframebuffer *buffer, GLuint *width, GLuint *height ); /* @@ -520,7 +510,6 @@ struct dd_function_table { void (*TextureMatrix)(GLcontext *ctx, GLuint unit, const GLmatrix *mat); void (*Viewport)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h); - /*** *** Vertex array functions *** @@ -555,8 +544,6 @@ struct dd_function_table { GLboolean (*GetIntegerv)(GLcontext *ctx, GLenum pname, GLint *result); GLboolean (*GetPointerv)(GLcontext *ctx, GLenum pname, GLvoid **result); - - /*** *** Support for multiple t&l engines ***/ diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index a4673bf1c0e..4f12e06b414 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1,4 +1,4 @@ -/* $Id: get.c,v 1.86 2002/06/29 20:04:57 brianp Exp $ */ +/* $Id: get.c,v 1.87 2002/07/09 01:22:50 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -5596,7 +5596,7 @@ _mesa_GetString( GLenum name ) static const char *renderer = "Mesa"; static const char *version_1_2 = "1.2 Mesa 4.1 beta"; static const char *version_1_3 = "1.3 Mesa 4.1 beta"; - static const char *version_1_4 = "1.4 Mesa 4.1 beta"; + static const char *version_1_4 = "1.3 Mesa 4.1 beta"; /* change to 1.4 */ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index 038518d90aa..37f4f16f268 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -1,4 +1,4 @@ -/* $Id: macros.h,v 1.28 2002/06/12 00:52:50 brianp Exp $ */ +/* $Id: macros.h,v 1.29 2002/07/09 01:22:50 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -59,15 +59,6 @@ #endif - -/* - * Bitmask helpers - */ -#define SET_BITS(WORD, BITS) (WORD) |= (BITS) -#define CLEAR_BITS(WORD, BITS) (WORD) &= ~(BITS) -#define TEST_BITS(WORD, BITS) ((WORD) & (BITS)) - - /* Stepping a GLfloat pointer by a byte stride */ #define STRIDE_F(p, i) (p = (GLfloat *)((GLubyte *)p + i)) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index b5798bc0942..6f33ae6658d 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1,4 +1,4 @@ -/* $Id: mtypes.h,v 1.83 2002/06/29 20:03:14 brianp Exp $ */ +/* $Id: mtypes.h,v 1.84 2002/07/09 01:22:50 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -317,9 +317,8 @@ struct gl_colorbuffer_attrib { GLubyte ColorMask[4]; /* Each flag is 0xff or 0x0 */ GLenum DrawBuffer; /* Which buffer to draw into */ - GLenum DriverDrawBuffer; /* Current device driver dest buffer */ - GLboolean MultiDrawBuffer; /* Drawing to multiple buffers? */ - GLubyte DrawDestMask; /* bitwise-OR of bitflags above */ + GLenum _DriverDrawBuffer; /* Single src/dst buffer for drivers */ + GLubyte _DrawDestMask; /* bitwise-OR of bitflags above */ /* alpha testing */ GLboolean AlphaEnabled; /* Alpha test enabled flag */ @@ -599,7 +598,7 @@ struct gl_multisample_attrib { struct gl_pixel_attrib { GLenum ReadBuffer; /* src buffer for glRead/CopyPixels */ - GLenum DriverReadBuffer; /* Driver's current source buffer */ + GLenum _DriverReadBuffer; /* Driver's current source buffer */ GLfloat RedBias, RedScale; GLfloat GreenBias, GreenScale; GLfloat BlueBias, BlueScale; @@ -1315,7 +1314,6 @@ struct gl_frame_buffer { GLchan *BackLeftAlpha; /* array [Width*Height] of GLubyte */ GLchan *FrontRightAlpha; /* array [Width*Height] of GLubyte */ GLchan *BackRightAlpha; /* array [Width*Height] of GLubyte */ - GLchan *Alpha; /* Points to current alpha buffer */ /* Drawing bounds: intersection of window size and scissor box */ GLint _Xmin, _Ymin; /* inclusive */ @@ -1431,7 +1429,9 @@ struct gl_extensions { }; -/* XXX just an idea */ +/* + * A stack of matrices (projection, modelview, color, texture, etc). + */ struct matrix_stack { GLmatrix *Top; /* points into Stack */ @@ -1532,7 +1532,9 @@ struct matrix_stack #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i)) #define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i)) + /* A bunch of flags that we think might be useful to drivers. + * Set in the ctx->_TriangleCaps bitfield. */ #define DD_FLATSHADE 0x1 #define DD_SEPARATE_SPECULAR 0x2 @@ -1549,6 +1551,7 @@ struct matrix_stack #define DD_POINT_SIZE 0x1000 #define DD_POINT_ATTEN 0x2000 + /* Define the state changes under which each of these bits might change */ #define _DD_NEW_FLATSHADE _NEW_LIGHT diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 27e7e0017ad..500ba2640ff 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -1,4 +1,4 @@ -/* $Id: state.c,v 1.88 2002/06/30 15:47:01 brianp Exp $ */ +/* $Id: state.c,v 1.89 2002/07/09 01:22:50 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1017,7 +1017,6 @@ void _mesa_update_state( GLcontext *ctx ) ASSERT(ctx->Driver.GetString); ASSERT(ctx->Driver.UpdateState); ASSERT(ctx->Driver.Clear); - ASSERT(ctx->Driver.SetDrawBuffer); ASSERT(ctx->Driver.GetBufferSize); if (ctx->Visual.accumRedBits > 0) { ASSERT(ctx->Driver.Accum); diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index 65ad6d2a871..4795aeffb2f 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -1,4 +1,4 @@ -/* $Id: texformat.c,v 1.13 2002/06/29 19:48:16 brianp Exp $ */ +/* $Id: texformat.c,v 1.14 2002/07/09 01:22:50 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -40,7 +40,6 @@ #include "texformat.h" #include "teximage.h" #include "texstate.h" -#include "swrast/s_span.h" #endif diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 2ff9d891219..95bed13d9d1 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1,4 +1,4 @@ -/* $Id: teximage.c,v 1.110 2002/06/29 19:48:16 brianp Exp $ */ +/* $Id: teximage.c,v 1.111 2002/07/09 01:22:50 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -41,7 +41,6 @@ #include "texstate.h" #include "texstore.h" #include "mtypes.h" -#include "swrast/s_span.h" /* XXX SWRAST hack */ #endif diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c index 09c4d8647b0..0159304c172 100644 --- a/src/mesa/swrast/s_accum.c +++ b/src/mesa/swrast/s_accum.c @@ -1,4 +1,4 @@ -/* $Id: s_accum.c,v 1.17 2002/06/15 02:38:17 brianp Exp $ */ +/* $Id: s_accum.c,v 1.18 2002/07/09 01:22:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -306,8 +306,7 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value, if (value == 0.0F) return; - (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, - ctx->Pixel.DriverReadBuffer ); + _swrast_use_read_buffer(ctx); /* May have to leave optimized accum buffer mode */ if (swrast->_IntegerAccumScaler == 0.0 && value > 0.0 && value <= 1.0) @@ -359,14 +358,13 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value, } } /* restore read buffer = draw buffer (the default) */ - (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, - ctx->Color.DriverDrawBuffer ); + _swrast_use_draw_buffer(ctx); + RENDER_FINISH(swrast,ctx); break; case GL_LOAD: - (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, - ctx->Pixel.DriverReadBuffer ); + _swrast_use_read_buffer(ctx); /* This is a change to go into optimized accum buffer mode */ if (value > 0.0 && value <= 1.0) { @@ -433,8 +431,8 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value, } /* restore read buffer = draw buffer (the default) */ - (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, - ctx->Color.DriverDrawBuffer ); + _swrast_use_draw_buffer(ctx); + RENDER_FINISH(swrast,ctx); break; diff --git a/src/mesa/swrast/s_alphabuf.c b/src/mesa/swrast/s_alphabuf.c index 56c4d552da2..b303c0fc76c 100644 --- a/src/mesa/swrast/s_alphabuf.c +++ b/src/mesa/swrast/s_alphabuf.c @@ -1,4 +1,4 @@ -/* $Id: s_alphabuf.c,v 1.10 2002/03/19 16:47:05 brianp Exp $ */ +/* $Id: s_alphabuf.c,v 1.11 2002/07/09 01:22:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -38,20 +38,12 @@ #include "s_alphabuf.h" -#define ALPHA_DRAW_ADDR(X,Y) \ - (ctx->DrawBuffer->Alpha + (Y) * ctx->DrawBuffer->Width + (X)) - -#define ALPHA_READ_ADDR(X,Y) \ - (ctx->ReadBuffer->Alpha + (Y) * ctx->ReadBuffer->Width + (X)) - - /* * Allocate a new front and back alpha buffer. */ void _mesa_alloc_alpha_buffers( GLframebuffer *buffer ) { - GET_CURRENT_CONTEXT(ctx); const GLint bytes = buffer->Width * buffer->Height * sizeof(GLchan); ASSERT(buffer->UseSoftwareAlphaBuffers); @@ -101,17 +93,6 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer ) } } } - - if (ctx) { - if (ctx->Color.DriverDrawBuffer == GL_FRONT_LEFT) - buffer->Alpha = buffer->FrontLeftAlpha; - else if (ctx->Color.DriverDrawBuffer == GL_BACK_LEFT) - buffer->Alpha = buffer->BackLeftAlpha; - else if (ctx->Color.DriverDrawBuffer == GL_FRONT_RIGHT) - buffer->Alpha = buffer->FrontRightAlpha; - else if (ctx->Color.DriverDrawBuffer == GL_BACK_RIGHT) - buffer->Alpha = buffer->BackRightAlpha; - } } @@ -129,7 +110,7 @@ _mesa_clear_alpha_buffers( GLcontext *ctx ) /* loop over four possible alpha buffers */ for (bufferBit = 1; bufferBit <= 8; bufferBit = bufferBit << 1) { - if (bufferBit & ctx->Color.DrawDestMask) { + if (bufferBit & ctx->Color._DrawDestMask) { GLchan *buffer; if (bufferBit == FRONT_LEFT_BIT) { buffer = ctx->DrawBuffer->FrontLeftAlpha; @@ -187,13 +168,39 @@ _mesa_clear_alpha_buffers( GLcontext *ctx ) +static INLINE +GLchan *get_alpha_buffer( GLcontext *ctx ) +{ + switch (ctx->Color._DriverDrawBuffer) { + case GL_FRONT_LEFT: + return ctx->DrawBuffer->FrontLeftAlpha; + break; + case GL_BACK_LEFT: + return ctx->DrawBuffer->BackLeftAlpha; + break; + case GL_FRONT_RIGHT: + return ctx->DrawBuffer->FrontRightAlpha; + break; + case GL_BACK_RIGHT: + return ctx->DrawBuffer->BackRightAlpha; + break; + default: + _mesa_problem(ctx, "Bad DriverDrawBuffer in _mesa_write_alpha_span()"); + return ctx->DrawBuffer->FrontLeftAlpha; /* aribitrary */ + } +} + + void _mesa_write_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y, CONST GLchan rgba[][4], const GLubyte mask[] ) { - GLchan *aptr = ALPHA_DRAW_ADDR( x, y ); + GLchan *buffer, *aptr; GLuint i; + buffer = get_alpha_buffer(ctx); + aptr = buffer + y * ctx->DrawBuffer->Width + x; + if (mask) { for (i=0;i<n;i++) { if (mask[i]) { @@ -214,9 +221,12 @@ void _mesa_write_mono_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y, GLchan alpha, const GLubyte mask[] ) { - GLchan *aptr = ALPHA_DRAW_ADDR( x, y ); + GLchan *buffer, *aptr; GLuint i; + buffer = get_alpha_buffer(ctx); + aptr = buffer + y * ctx->DrawBuffer->Width + x; + if (mask) { for (i=0;i<n;i++) { if (mask[i]) { @@ -238,19 +248,22 @@ _mesa_write_alpha_pixels( GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], CONST GLchan rgba[][4], const GLubyte mask[] ) { + GLchan *buffer; GLuint i; + buffer = get_alpha_buffer(ctx); + if (mask) { for (i=0;i<n;i++) { if (mask[i]) { - GLchan *aptr = ALPHA_DRAW_ADDR( x[i], y[i] ); + GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i]; *aptr = rgba[i][ACOMP]; } } } else { for (i=0;i<n;i++) { - GLchan *aptr = ALPHA_DRAW_ADDR( x[i], y[i] ); + GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i]; *aptr = rgba[i][ACOMP]; } } @@ -262,19 +275,22 @@ _mesa_write_mono_alpha_pixels( GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], GLchan alpha, const GLubyte mask[] ) { + GLchan *buffer; GLuint i; + buffer = get_alpha_buffer(ctx); + if (mask) { for (i=0;i<n;i++) { if (mask[i]) { - GLchan *aptr = ALPHA_DRAW_ADDR( x[i], y[i] ); + GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i]; *aptr = alpha; } } } else { for (i=0;i<n;i++) { - GLchan *aptr = ALPHA_DRAW_ADDR( x[i], y[i] ); + GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i]; *aptr = alpha; } } @@ -286,11 +302,14 @@ void _mesa_read_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y, GLchan rgba[][4] ) { - GLchan *aptr = ALPHA_READ_ADDR( x, y ); + const GLchan *buffer, *aptr; GLuint i; - for (i=0;i<n;i++) { + + buffer = get_alpha_buffer(ctx); + aptr = buffer + y * ctx->DrawBuffer->Width + x; + + for (i = 0; i < n; i++) rgba[i][ACOMP] = *aptr++; - } } @@ -299,10 +318,14 @@ _mesa_read_alpha_pixels( GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], GLchan rgba[][4], const GLubyte mask[] ) { + const GLchan *buffer; GLuint i; - for (i=0;i<n;i++) { + + buffer = get_alpha_buffer(ctx); + + for (i = 0; i < n; i++) { if (mask[i]) { - GLchan *aptr = ALPHA_READ_ADDR( x[i], y[i] ); + const GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i]; rgba[i][ACOMP] = *aptr; } } diff --git a/src/mesa/swrast/s_buffers.c b/src/mesa/swrast/s_buffers.c index 6c7b447aba8..dcfa26f5e20 100644 --- a/src/mesa/swrast/s_buffers.c +++ b/src/mesa/swrast/s_buffers.c @@ -1,4 +1,4 @@ -/* $Id: s_buffers.c,v 1.11 2002/06/15 02:38:17 brianp Exp $ */ +/* $Id: s_buffers.c,v 1.12 2002/07/09 01:22:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -167,22 +167,18 @@ clear_color_buffers(GLcontext *ctx) /* loop over four possible dest color buffers */ for (bufferBit = 1; bufferBit <= 8; bufferBit = bufferBit << 1) { - if (bufferBit & ctx->Color.DrawDestMask) { + if (bufferBit & ctx->Color._DrawDestMask) { if (bufferBit == FRONT_LEFT_BIT) { - (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_LEFT); - (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_FRONT_LEFT); + (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_FRONT_LEFT); } else if (bufferBit == FRONT_RIGHT_BIT) { - (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_RIGHT); - (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_FRONT_RIGHT); + (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_FRONT_RIGHT); } else if (bufferBit == BACK_LEFT_BIT) { - (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_LEFT); - (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_BACK_LEFT); + (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_BACK_LEFT); } else { - (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_RIGHT); - (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_BACK_RIGHT); + (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_BACK_RIGHT); } if (colorMask != 0xffffffff) { @@ -194,9 +190,8 @@ clear_color_buffers(GLcontext *ctx) } } - /* restore default read/draw buffers */ - (void) (*ctx->Driver.SetDrawBuffer)( ctx, ctx->Color.DriverDrawBuffer ); - (void) (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, ctx->Pixel.DriverReadBuffer ); + /* restore default read/draw buffer */ + _swrast_use_draw_buffer(ctx); } @@ -224,7 +219,7 @@ _swrast_Clear( GLcontext *ctx, GLbitfield mask, /* do software clearing here */ if (mask) { - if (mask & ctx->Color.DrawDestMask) clear_color_buffers(ctx); + if (mask & ctx->Color._DrawDestMask) clear_color_buffers(ctx); if (mask & GL_DEPTH_BUFFER_BIT) _mesa_clear_depth_buffer(ctx); if (mask & GL_ACCUM_BUFFER_BIT) _mesa_clear_accum_buffer(ctx); if (mask & GL_STENCIL_BUFFER_BIT) _mesa_clear_stencil_buffer(ctx); @@ -258,3 +253,68 @@ _swrast_alloc_buffers( GLframebuffer *buffer ) _mesa_alloc_alpha_buffers( buffer ); } } + + +/* + * Fallback for ctx->Driver.DrawBuffer() + */ +void +_swrast_DrawBuffer( GLcontext *ctx, GLenum mode ) +{ + _swrast_use_draw_buffer(ctx); +} + + +/* + * Setup things so that we read/write spans from the user-designated + * read buffer (set via glReadPixels). We usually just have to call + * this for glReadPixels, glCopyPixels, etc. + */ +void +_swrast_use_read_buffer( GLcontext *ctx ) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + + /* Do this so the software-emulated alpha plane span functions work! */ + ctx->Color._DriverDrawBuffer = ctx->Pixel._DriverReadBuffer; + /* Tell the device driver where to read/write spans */ + (*swrast->Driver.SetBuffer)( ctx, ctx->ReadBuffer, + ctx->Pixel._DriverReadBuffer ); +} + + +/* + * Setup things so that we read/write spans from the default draw buffer. + * This is the usual mode that Mesa's software rasterizer operates in. + */ +void +_swrast_use_draw_buffer( GLcontext *ctx ) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + + /* The user can specify rendering to zero, one, two, or four color + * buffers simultaneously with glDrawBuffer()! + * We don't expect the span/point/line/triangle functions to deal with + * that mess so we'll iterate over the multiple buffers as needed. + * But usually we only render to one color buffer at a time. + * We set ctx->Color._DriverDrawBuffer to that buffer and tell the + * device driver to use that buffer. + * Look in s_span.c's multi_write_rgba_span() function to see how + * we loop over multiple color buffers when needed. + */ + + if (ctx->Color._DrawDestMask & FRONT_LEFT_BIT) + ctx->Color._DriverDrawBuffer = GL_FRONT_LEFT; + else if (ctx->Color._DrawDestMask & BACK_LEFT_BIT) + ctx->Color._DriverDrawBuffer = GL_BACK_LEFT; + else if (ctx->Color._DrawDestMask & FRONT_RIGHT_BIT) + ctx->Color._DriverDrawBuffer = GL_FRONT_RIGHT; + else if (ctx->Color._DrawDestMask & BACK_RIGHT_BIT) + ctx->Color._DriverDrawBuffer = GL_BACK_RIGHT; + else + /* glDrawBuffer(GL_NONE) */ + ctx->Color._DriverDrawBuffer = GL_FRONT_LEFT; /* always have this */ + + (*swrast->Driver.SetBuffer)( ctx, ctx->DrawBuffer, + ctx->Color._DriverDrawBuffer ); +} diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index a4f59df8ae3..105b562d90f 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -1,4 +1,4 @@ -/* $Id: s_context.c,v 1.35 2002/06/15 03:03:11 brianp Exp $ */ +/* $Id: s_context.c,v 1.36 2002/07/09 01:22:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -87,8 +87,11 @@ _swrast_update_rasterflags( GLcontext *ctx ) * MULTI_DRAW_BIT flag. Also set it if we're drawing to no * buffers or the RGBA or CI mask disables all writes. */ - if (ctx->Color.DrawBuffer == GL_FRONT_AND_BACK || - ctx->Color.DrawBuffer == GL_NONE) { + if (ctx->Color._DrawDestMask != FRONT_LEFT_BIT && + ctx->Color._DrawDestMask != BACK_LEFT_BIT && + ctx->Color._DrawDestMask != FRONT_RIGHT_BIT && + ctx->Color._DrawDestMask != BACK_RIGHT_BIT) { + /* more than one color buffer designated for writing (or zero buffers) */ RasterMask |= MULTI_DRAW_BIT; } else if (ctx->Visual.rgbMode && *((GLuint *) ctx->Color.ColorMask) == 0) { diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index 2c6bd263123..7f5f41b78f6 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -1,4 +1,4 @@ -/* $Id: s_copypix.c,v 1.38 2002/06/15 03:03:11 brianp Exp $ */ +/* $Id: s_copypix.c,v 1.39 2002/07/09 01:22:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -103,7 +103,6 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, GLboolean quick_draw; GLint row; GLboolean changeBuffer; - GLchan *saveReadAlpha; const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; const GLuint transferOps = ctx->_ImageTransferState; GLfloat *dest, *tmpImage, *convImage; @@ -128,7 +127,6 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, } /* If read and draw buffer are different we must do buffer switching */ - saveReadAlpha = ctx->ReadBuffer->Alpha; changeBuffer = ctx->Pixel.ReadBuffer != ctx->Color.DrawBuffer || ctx->DrawBuffer != ctx->ReadBuffer; @@ -149,16 +147,8 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, dest = tmpImage; if (changeBuffer) { - (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, - ctx->Pixel.DriverReadBuffer ); - if (ctx->Pixel.DriverReadBuffer == GL_FRONT_LEFT) - ctx->ReadBuffer->Alpha = ctx->ReadBuffer->FrontLeftAlpha; - else if (ctx->Pixel.DriverReadBuffer == GL_BACK_LEFT) - ctx->ReadBuffer->Alpha = ctx->ReadBuffer->BackLeftAlpha; - else if (ctx->Pixel.DriverReadBuffer == GL_FRONT_RIGHT) - ctx->ReadBuffer->Alpha = ctx->ReadBuffer->FrontRightAlpha; - else - ctx->ReadBuffer->Alpha = ctx->ReadBuffer->BackRightAlpha; + /* choose the read buffer */ + _swrast_use_read_buffer(ctx); } /* read source image */ @@ -176,11 +166,9 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, } } - /* read from the draw buffer again (in case of blending) */ if (changeBuffer) { - (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, - ctx->Color.DriverDrawBuffer ); - ctx->ReadBuffer->Alpha = saveReadAlpha; + /* restore default src/dst buffer */ + _swrast_use_draw_buffer(ctx); } /* do image transfer ops up until convolution */ @@ -301,7 +289,6 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, GLboolean quick_draw; GLint sy, dy, stepy, j; GLboolean changeBuffer; - GLchan *saveReadAlpha; const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; GLint overlapping; const GLuint transferOps = ctx->_ImageTransferState; @@ -347,13 +334,9 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, } /* If read and draw buffer are different we must do buffer switching */ - saveReadAlpha = ctx->ReadBuffer->Alpha; changeBuffer = ctx->Pixel.ReadBuffer != ctx->Color.DrawBuffer || ctx->DrawBuffer != ctx->ReadBuffer; - (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, - ctx->Pixel.DriverReadBuffer ); - if (overlapping) { GLint ssy = sy; tmpImage = (GLchan *) MALLOC(width * height * sizeof(GLchan) * 4); @@ -361,25 +344,22 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" ); return; } + /* setup source */ + if (changeBuffer) + _swrast_use_read_buffer(ctx); + /* read the source image */ p = tmpImage; - if (changeBuffer) { - (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, - ctx->Pixel.DriverReadBuffer ); - if (ctx->Pixel.DriverReadBuffer == GL_FRONT_LEFT) - ctx->ReadBuffer->Alpha = ctx->ReadBuffer->FrontLeftAlpha; - else if (ctx->Pixel.DriverReadBuffer == GL_BACK_LEFT) - ctx->ReadBuffer->Alpha = ctx->ReadBuffer->BackLeftAlpha; - else if (ctx->Pixel.DriverReadBuffer == GL_FRONT_RIGHT) - ctx->ReadBuffer->Alpha = ctx->ReadBuffer->FrontRightAlpha; - else - ctx->ReadBuffer->Alpha = ctx->ReadBuffer->BackRightAlpha; - } for (j = 0; j < height; j++, ssy += stepy) { _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, srcx, ssy, (GLchan (*)[4]) p ); p += width * 4; } p = tmpImage; + /* restore dest */ + if (changeBuffer) { + _swrast_use_draw_buffer(ctx); + changeBuffer = GL_FALSE; + } } else { tmpImage = NULL; /* silence compiler warnings */ @@ -395,30 +375,12 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, } else { /* get from framebuffer */ - if (changeBuffer) { - (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, - ctx->Pixel.DriverReadBuffer ); - if (ctx->Pixel.DriverReadBuffer == GL_FRONT_LEFT) { - ctx->ReadBuffer->Alpha = ctx->ReadBuffer->FrontLeftAlpha; - } - else if (ctx->Pixel.DriverReadBuffer == GL_BACK_LEFT) { - ctx->ReadBuffer->Alpha = ctx->ReadBuffer->BackLeftAlpha; - } - else if (ctx->Pixel.DriverReadBuffer == GL_FRONT_RIGHT) { - ctx->ReadBuffer->Alpha = ctx->ReadBuffer->FrontRightAlpha; - } - else { - ctx->ReadBuffer->Alpha = ctx->ReadBuffer->BackRightAlpha; - } - } - _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, srcx, sy, span->color.rgba ); - } - - if (changeBuffer) { - /* read from the draw buffer again (in case of blending) */ - (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, - ctx->Color.DriverDrawBuffer ); - ctx->ReadBuffer->Alpha = saveReadAlpha; + if (changeBuffer) + _swrast_use_read_buffer(ctx); + _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, srcx, sy, + span->color.rgba ); + if (changeBuffer) + _swrast_use_draw_buffer(ctx); } if (transferOps) { @@ -525,10 +487,6 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, } } - /* Restore pixel source to be the draw buffer (for blending, etc) */ - (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, - ctx->Color.DriverDrawBuffer ); - if (overlapping) FREE(tmpImage); } @@ -576,9 +534,6 @@ static void copy_ci_pixels( GLcontext *ctx, changeBuffer = ctx->Pixel.ReadBuffer != ctx->Color.DrawBuffer || ctx->DrawBuffer != ctx->ReadBuffer; - (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, - ctx->Pixel.DriverReadBuffer ); - if (overlapping) { GLint ssy = sy; tmpImage = (GLuint *) MALLOC(width * height * sizeof(GLuint)); @@ -586,16 +541,21 @@ static void copy_ci_pixels( GLcontext *ctx, _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" ); return; } + /* setup source */ + if (changeBuffer) + _swrast_use_read_buffer(ctx); + /* read the image */ p = tmpImage; - if (changeBuffer) { - (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, - ctx->Pixel.DriverReadBuffer ); - } for (j = 0; j < height; j++, ssy += stepy) { _mesa_read_index_span( ctx, ctx->ReadBuffer, width, srcx, ssy, p ); p += width; } p = tmpImage; + /* restore to draw buffer */ + if (changeBuffer) { + _swrast_use_draw_buffer(ctx); + changeBuffer = GL_FALSE; + } } else { tmpImage = NULL; /* silence compiler warning */ @@ -608,18 +568,12 @@ static void copy_ci_pixels( GLcontext *ctx, p += width; } else { - if (changeBuffer) { - (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, - ctx->Pixel.DriverReadBuffer ); - } + if (changeBuffer) + _swrast_use_read_buffer(ctx); _mesa_read_index_span( ctx, ctx->ReadBuffer, width, srcx, sy, span->color.index ); - } - - if (changeBuffer) { - /* set read buffer back to draw buffer (in case of logicops) */ - (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, - ctx->Color.DriverDrawBuffer ); + if (changeBuffer) + _swrast_use_draw_buffer(ctx); } if (shift_or_offset) { @@ -638,10 +592,6 @@ static void copy_ci_pixels( GLcontext *ctx, _mesa_write_index_span(ctx, span); } - /* Restore pixel source to be the draw buffer (for blending, etc) */ - (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, - ctx->Color.DriverDrawBuffer ); - if (overlapping) FREE(tmpImage); } diff --git a/src/mesa/swrast/s_imaging.c b/src/mesa/swrast/s_imaging.c index 1c63f5c3416..98cbe347a72 100644 --- a/src/mesa/swrast/s_imaging.c +++ b/src/mesa/swrast/s_imaging.c @@ -1,4 +1,4 @@ -/* $Id: s_imaging.c,v 1.5 2002/04/04 16:53:00 brianp Exp $ */ +/* $Id: s_imaging.c,v 1.6 2002/07/09 01:22:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -37,12 +37,10 @@ _swrast_CopyColorTable( GLcontext *ctx, GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); GLchan data[MAX_WIDTH][4]; /* Select buffer to read from */ - (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, - ctx->Pixel.DriverReadBuffer ); + _swrast_use_read_buffer(ctx); if (width > MAX_WIDTH) width = MAX_WIDTH; @@ -51,8 +49,7 @@ _swrast_CopyColorTable( GLcontext *ctx, _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data ); /* Restore reading from draw buffer (the default) */ - (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, - ctx->Color.DriverDrawBuffer ); + _swrast_use_draw_buffer(ctx); glColorTable(target, internalformat, width, GL_RGBA, CHAN_TYPE, data); } @@ -61,12 +58,10 @@ void _swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start, GLint x, GLint y, GLsizei width) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); GLchan data[MAX_WIDTH][4]; /* Select buffer to read from */ - (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, - ctx->Pixel.DriverReadBuffer ); + _swrast_use_read_buffer(ctx); if (width > MAX_WIDTH) width = MAX_WIDTH; @@ -75,8 +70,7 @@ _swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start, _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data ); /* Restore reading from draw buffer (the default) */ - (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, - ctx->Color.DriverDrawBuffer ); + _swrast_use_draw_buffer(ctx); glColorSubTable(target, start, width, GL_RGBA, CHAN_TYPE, data); } @@ -90,6 +84,9 @@ _swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target, SWcontext *swrast = SWRAST_CONTEXT(ctx); GLchan rgba[MAX_CONVOLUTION_WIDTH][4]; + /* Select buffer to read from */ + _swrast_use_read_buffer(ctx); + RENDER_START( swrast, ctx ); /* read the data from framebuffer */ @@ -98,6 +95,9 @@ _swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target, RENDER_FINISH( swrast, ctx ); + /* Restore reading from draw buffer (the default) */ + _swrast_use_draw_buffer(ctx); + /* store as convolution filter */ glConvolutionFilter1D(target, internalFormat, width, GL_RGBA, CHAN_TYPE, rgba); @@ -114,6 +114,9 @@ _swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target, GLchan rgba[MAX_CONVOLUTION_HEIGHT][MAX_CONVOLUTION_WIDTH][4]; GLint i; + /* Select buffer to read from */ + _swrast_use_read_buffer(ctx); + RENDER_START(swrast,ctx); /* read pixels from framebuffer */ @@ -124,6 +127,9 @@ _swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target, RENDER_FINISH(swrast,ctx); + /* Restore reading from draw buffer (the default) */ + _swrast_use_draw_buffer(ctx); + /* * HACK: save & restore context state so we can store this as a * convolution filter via the GL api. Doesn't call any callbacks diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index a52cd8e7c0b..f925e791162 100644 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@ -1,4 +1,4 @@ -/* $Id: s_readpix.c,v 1.14 2002/04/19 00:38:27 brianp Exp $ */ +/* $Id: s_readpix.c,v 1.15 2002/07/09 01:22:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -62,9 +62,7 @@ read_index_pixels( GLcontext *ctx, return; } - ASSERT(swrast->Driver.SetReadBuffer); - (*swrast->Driver.SetReadBuffer)(ctx, ctx->ReadBuffer, - ctx->Pixel.DriverReadBuffer); + _swrast_use_read_buffer(ctx); readWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width; @@ -82,8 +80,7 @@ read_index_pixels( GLcontext *ctx, &ctx->Pack, ctx->_ImageTransferState); } - (*swrast->Driver.SetReadBuffer)(ctx, ctx->DrawBuffer, - ctx->Color.DriverDrawBuffer); + _swrast_use_draw_buffer(ctx); } @@ -318,13 +315,13 @@ read_rgba_pixels( GLcontext *ctx, SWcontext *swrast = SWRAST_CONTEXT(ctx); GLint readWidth; - (*swrast->Driver.SetReadBuffer)(ctx, ctx->ReadBuffer, ctx->Pixel.DriverReadBuffer); + _swrast_use_read_buffer(ctx); /* Try optimized path first */ if (read_fast_rgba_pixels( ctx, x, y, width, height, format, type, pixels, packing )) { - (*swrast->Driver.SetReadBuffer)(ctx, ctx->DrawBuffer, ctx->Color.DriverDrawBuffer); + _swrast_use_draw_buffer(ctx); return; /* done! */ } @@ -470,7 +467,7 @@ read_rgba_pixels( GLcontext *ctx, } } - (*swrast->Driver.SetReadBuffer)(ctx, ctx->DrawBuffer, ctx->Color.DriverDrawBuffer); + _swrast_use_draw_buffer(ctx); } diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index a3271d7806d..94cd4a9ce83 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -1,4 +1,4 @@ -/* $Id: s_span.c,v 1.44 2002/06/15 03:03:11 brianp Exp $ */ +/* $Id: s_span.c,v 1.45 2002/07/09 01:22:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -608,19 +608,19 @@ multi_write_index_span( GLcontext *ctx, struct sw_span *span ) GLuint bufferBit; /* loop over four possible dest color buffers */ - for (bufferBit = 1; bufferBit <= 8; bufferBit = bufferBit << 1) { - if (bufferBit & ctx->Color.DrawDestMask) { + for (bufferBit = 1; bufferBit <= 8; bufferBit <<= 1) { + if (bufferBit & ctx->Color._DrawDestMask) { GLuint indexTmp[MAX_WIDTH]; ASSERT(span->end < MAX_WIDTH); if (bufferBit == FRONT_LEFT_BIT) - (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_LEFT); + (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_FRONT_LEFT); else if (bufferBit == FRONT_RIGHT_BIT) - (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_RIGHT); + (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_FRONT_RIGHT); else if (bufferBit == BACK_LEFT_BIT) - (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_LEFT); + (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_BACK_LEFT); else - (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_RIGHT); + (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_BACK_RIGHT); /* make copy of incoming indexes */ MEMCPY( indexTmp, span->color.index, span->end * sizeof(GLuint) ); @@ -648,7 +648,7 @@ multi_write_index_span( GLcontext *ctx, struct sw_span *span ) } /* restore default dest buffer */ - (void) (*ctx->Driver.SetDrawBuffer)( ctx, ctx->Color.DriverDrawBuffer); + _swrast_use_draw_buffer(ctx); } @@ -670,26 +670,26 @@ multi_write_rgba_span( GLcontext *ctx, struct sw_span *span ) return; /* loop over four possible dest color buffers */ - for (bufferBit = 1; bufferBit <= 8; bufferBit = bufferBit << 1) { - if (bufferBit & ctx->Color.DrawDestMask) { + for (bufferBit = 1; bufferBit <= 8; bufferBit <<= 1) { + if (bufferBit & ctx->Color._DrawDestMask) { GLchan rgbaTmp[MAX_WIDTH][4]; ASSERT(span->end < MAX_WIDTH); if (bufferBit == FRONT_LEFT_BIT) { - (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_LEFT); - ctx->DrawBuffer->Alpha = ctx->DrawBuffer->FrontLeftAlpha; + ctx->Color._DriverDrawBuffer = GL_FRONT_LEFT; + (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_FRONT_LEFT); } else if (bufferBit == FRONT_RIGHT_BIT) { - (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_RIGHT); - ctx->DrawBuffer->Alpha = ctx->DrawBuffer->FrontRightAlpha; + ctx->Color._DriverDrawBuffer = GL_FRONT_RIGHT; + (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_FRONT_RIGHT); } else if (bufferBit == BACK_LEFT_BIT) { - (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_LEFT); - ctx->DrawBuffer->Alpha = ctx->DrawBuffer->BackLeftAlpha; + ctx->Color._DriverDrawBuffer = GL_BACK_LEFT; + (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_BACK_LEFT); } else { - (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_RIGHT); - ctx->DrawBuffer->Alpha = ctx->DrawBuffer->BackRightAlpha; + ctx->Color._DriverDrawBuffer = GL_BACK_RIGHT; + (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_BACK_RIGHT); } /* make copy of incoming colors */ @@ -734,7 +734,7 @@ multi_write_rgba_span( GLcontext *ctx, struct sw_span *span ) } /* restore default dest buffer */ - (void) (*ctx->Driver.SetDrawBuffer)( ctx, ctx->Color.DriverDrawBuffer ); + _swrast_use_draw_buffer(ctx); } diff --git a/src/mesa/swrast/s_texstore.c b/src/mesa/swrast/s_texstore.c index e1adeded7fc..88fe786ef8c 100644 --- a/src/mesa/swrast/s_texstore.c +++ b/src/mesa/swrast/s_texstore.c @@ -1,4 +1,4 @@ -/* $Id: s_texstore.c,v 1.5 2001/05/21 16:41:04 brianp Exp $ */ +/* $Id: s_texstore.c,v 1.6 2002/07/09 01:22:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -73,8 +73,7 @@ read_color_image( GLcontext *ctx, GLint x, GLint y, return NULL; /* Select buffer to read from */ - (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, - ctx->Pixel.DriverReadBuffer ); + _swrast_use_read_buffer(ctx); RENDER_START(swrast,ctx); @@ -89,8 +88,7 @@ read_color_image( GLcontext *ctx, GLint x, GLint y, RENDER_FINISH(swrast,ctx); /* Read from draw buffer (the default) */ - (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, - ctx->Color.DriverDrawBuffer ); + _swrast_use_draw_buffer(ctx); return image; } diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c index bdbdde76b83..634664371bd 100644 --- a/src/mesa/swrast/s_triangle.c +++ b/src/mesa/swrast/s_triangle.c @@ -1,4 +1,4 @@ -/* $Id: s_triangle.c,v 1.59 2002/06/15 03:03:12 brianp Exp $ */ +/* $Id: s_triangle.c,v 1.60 2002/07/09 01:22:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -218,7 +218,7 @@ static void simple_textured_triangle( GLcontext *ctx, span->intTex[1] += span->intTexStep[1]; \ } \ (*swrast->Driver.WriteRGBSpan)(ctx, span->end, span->x, span->y, \ - (CONST GLchan (*)[3]) span->color.rgb, \ + (CONST GLchan (*)[3]) span->color.rgb,\ NULL ); #include "s_tritemp.h" @@ -283,7 +283,7 @@ static void simple_z_textured_triangle( GLcontext *ctx, span->z += span->zStep; \ } \ (*swrast->Driver.WriteRGBSpan)(ctx, span->end, span->x, span->y, \ - (CONST GLchan (*)[3]) span->color.rgb, \ + (CONST GLchan (*)[3]) span->color.rgb,\ span->mask ); #include "s_tritemp.h" @@ -589,7 +589,7 @@ static void affine_textured_triangle( GLcontext *ctx, info.format = obj->Image[b]->Format; \ info.filter = obj->MinFilter; \ info.envmode = unit->EnvMode; \ - span->arrayMask |= SPAN_RGBA; \ + span->arrayMask |= SPAN_RGBA; \ \ if (info.envmode == GL_BLEND) { \ /* potential off-by-one error here? (1.0f -> 2048 -> 0) */ \ @@ -896,7 +896,7 @@ static void persp_textured_triangle( GLcontext *ctx, #define RENDER_SPAN( span ) \ span->interpMask &= ~SPAN_RGBA; \ - span->arrayMask |= SPAN_RGBA; \ + span->arrayMask |= SPAN_RGBA; \ fast_persp_span(ctx, span, &info); #include "s_tritemp.h" @@ -976,7 +976,7 @@ static void occlusion_zless_triangle( GLcontext *ctx, #define RENDER_SPAN( span ) \ GLuint i; \ for (i = 0; i < span->end; i++) { \ - GLdepth z = FixedToDepth(span->z); \ + GLdepth z = FixedToDepth(span->z); \ if (z < zRow[i]) { \ ctx->OcclusionResult = GL_TRUE; \ return; \ diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h index f36031cfb4a..a33e97ec017 100644 --- a/src/mesa/swrast/swrast.h +++ b/src/mesa/swrast/swrast.h @@ -1,4 +1,4 @@ -/* $Id: swrast.h,v 1.24 2002/04/19 14:05:50 brianp Exp $ */ +/* $Id: swrast.h,v 1.25 2002/07/09 01:22:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -204,6 +204,12 @@ struct swrast_device_driver; extern void _swrast_alloc_buffers( GLframebuffer *buffer ); +extern void +_swrast_use_read_buffer( GLcontext *ctx ); + +extern void +_swrast_use_draw_buffer( GLcontext *ctx ); + extern GLboolean _swrast_CreateContext( GLcontext *ctx ); @@ -254,6 +260,10 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLint width, GLint height ); +extern void +_swrast_DrawBuffer( GLcontext *ctx, GLenum mode ); + + /* Reset the stipple counter */ extern void @@ -363,11 +373,14 @@ _swrast_copy_texsubimage3d(GLcontext *ctx, */ struct swrast_device_driver { - void (*SetReadBuffer)( GLcontext *ctx, GLframebuffer *colorBuffer, - GLenum buffer ); + void (*SetBuffer)( GLcontext *ctx, GLframebuffer *buffer, + GLenum colorBuffer ); /* - * Specifies the current buffer for span/pixel reading. - * colorBuffer will be one of: + * Specifies the current buffer for span/pixel writing/reading. + * buffer indicates which window to write to / read from. Normally, + * this'll be the buffer currently bound to the context, but it doesn't + * have to be! + * colorBuffer indicates which color buffer, one of: * GL_FRONT_LEFT - this buffer always exists * GL_BACK_LEFT - when double buffering * GL_FRONT_RIGHT - when using stereo |