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/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 +- 4 files changed, 138 insertions(+), 182 deletions(-) (limited to 'src/mesa/drivers/x11') 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