From 3b4fbbc129c711a5aec8d653d5c6eb2e195f947c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 9 Jul 2002 01:22:50 +0000 Subject: Overhaul of glRead/DrawBuffer() code. Now, swrast->Driver.SetBuffer() indicates the read AND draw color buffer for all software rasterization. Lots of related clean-ups. See RELNOTES-4.1 for details. --- src/mesa/drivers/dos/dmesa.c | 19 +--- src/mesa/drivers/ggi/ggimesa.c | 34 ++---- src/mesa/drivers/glide/fxdd.c | 7 +- src/mesa/drivers/glide/fxddspan.c | 6 +- src/mesa/drivers/osmesa/osmesa.c | 20 ++-- src/mesa/drivers/svga/svgamesa.c | 37 ++----- src/mesa/drivers/windows/wmesa.c | 27 ++--- src/mesa/drivers/x11/xm_api.c | 52 ++++----- src/mesa/drivers/x11/xm_dd.c | 222 +++++++++++++++++--------------------- src/mesa/drivers/x11/xm_span.c | 36 ++----- src/mesa/drivers/x11/xmesaP.h | 10 +- 11 files changed, 177 insertions(+), 293 deletions(-) (limited to 'src/mesa/drivers') 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; @@ -523,18 +522,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 @@ -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;yheight;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;yheight;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;ixm_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; ixm_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; ixm_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 (; jxm_buffer->backimage->bytes_per_line; j++) { + for (; jxm_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; ixm_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;jxm_buffer, x, y+j ); + register GLushort *ptr2 = PIXELADDR2( xmesa->xm_draw_buffer, x, y+j ); for (i=0;ixm_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;jxm_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;jxm_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;jxm_buffer, x, y+j ); + register GLuint *ptr4 = PIXELADDR4( xmesa->xm_draw_buffer, x, y+j ); for (i=0;iDriverCtx; - 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;jclearpixel ); @@ -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;jclearpixel ); @@ -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;iDriverCtx; 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 -- cgit v1.2.3