From: Brian Paul Date: Thu, 25 Nov 1999 17:36:48 +0000 (+0000) Subject: replaced Driver.SetBuffer() with SetDrawBuffer() and SetReadBuffer() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cea0e8e6700e871bb9bcb334cb75fbfbfcdfd702;p=mesa.git replaced Driver.SetBuffer() with SetDrawBuffer() and SetReadBuffer() --- diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c index cbe63695fa2..0668195797b 100644 --- a/src/mesa/drivers/glide/fxdd.c +++ b/src/mesa/drivers/glide/fxdd.c @@ -242,8 +242,9 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all, } -/* Set the buffer used in double buffering */ -static GLboolean fxDDSetBuffer(GLcontext *ctx, GLenum mode ) +/* Set the buffer used for drawing */ +/* XXX support for separate read/draw buffers hasn't been tested */ +static GLboolean fxDDSetDrawBuffer(GLcontext *ctx, GLenum mode ) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; @@ -267,6 +268,29 @@ static GLboolean fxDDSetBuffer(GLcontext *ctx, GLenum mode ) } +/* 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 ) +{ + fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; + (void) buffer; + + if (MESA_VERBOSE&VERBOSE_DRIVER) { + fprintf(stderr,"fxmesa: fxDDSetBuffer(%x)\n",mode); + } + + if (mode == GL_FRONT_LEFT) { + fxMesa->currentFB = GR_BUFFER_FRONTBUFFER; + FX_grRenderBuffer(fxMesa->currentFB); + } + else if (mode == GL_BACK_LEFT) { + fxMesa->currentFB = GR_BUFFER_BACKBUFFER; + FX_grRenderBuffer(fxMesa->currentFB); + } +} + + #ifdef XF86DRI static GLboolean inClipRects(fxMesaContext fxMesa, int px, int py) { @@ -808,7 +832,8 @@ void fxSetupDDPointers(GLcontext *ctx) ctx->Driver.Index=NULL; ctx->Driver.Color=fxDDSetColor; - ctx->Driver.SetBuffer=fxDDSetBuffer; + ctx->Driver.SetDrawBuffer=fxDDSetDrawBuffer; + ctx->Driver.SetReadBuffer=fxDDSetReadBuffer; ctx->Driver.GetBufferSize=fxDDBufferSize; ctx->Driver.Bitmap=fxDDDrawBitMap; diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index a0bb746d007..e5dca912504 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -1,4 +1,4 @@ -/* $Id: osmesa.c,v 1.3 1999/11/11 01:28:41 brianp Exp $ */ +/* $Id: osmesa.c,v 1.4 1999/11/25 17:37:00 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -541,7 +541,7 @@ GLboolean GLAPIENTRY OSMesaGetDepthBuffer( OSMesaContext c, GLint *width, GLint -static GLboolean set_buffer( GLcontext *ctx, GLenum mode ) +static GLboolean set_draw_buffer( GLcontext *ctx, GLenum mode ) { (void) ctx; if (mode==GL_FRONT_LEFT) { @@ -553,6 +553,14 @@ static GLboolean set_buffer( GLcontext *ctx, GLenum mode ) } +static void set_read_buffer( GLcontext *ctx, GLframebuffer *buffer, GLenum mode ) +{ + /* separate read buffer not supported */ + ASSERT(buffer == ctx->DrawBuffer); + ASSERT(mode == GL_FRONT_LEFT); +} + + static void clear_index( GLcontext *ctx, GLuint index ) { OSMesaContext osmesa = (OSMesaContext) ctx->DriverCtx; @@ -1539,7 +1547,8 @@ static void osmesa_update_state( GLcontext *ctx ) ctx->Driver.GetString = get_string; ctx->Driver.UpdateState = osmesa_update_state; - ctx->Driver.SetBuffer = set_buffer; + ctx->Driver.SetDrawBuffer = set_draw_buffer; + ctx->Driver.SetReadBuffer = set_read_buffer; ctx->Driver.Color = set_color; ctx->Driver.Index = set_index; ctx->Driver.ClearIndex = clear_index; diff --git a/src/mesa/main/accum.c b/src/mesa/main/accum.c index 8e6f3cae0ff..81af5f60689 100644 --- a/src/mesa/main/accum.c +++ b/src/mesa/main/accum.c @@ -1,4 +1,4 @@ -/* $Id: accum.c,v 1.12 1999/11/24 18:48:30 brianp Exp $ */ +/* $Id: accum.c,v 1.13 1999/11/25 17:36:48 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -221,7 +221,8 @@ _mesa_Accum( GLenum op, GLfloat value ) break; case GL_ACCUM: - (void) (*ctx->Driver.SetBuffer)( ctx, ctx->Pixel.DriverReadBuffer ); + (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, + ctx->Pixel.DriverReadBuffer ); /* May have to leave optimized accum buffer mode */ if (ctx->IntegerAccumScaler == 0.0 && value > 0.0 && value <= 1.0) @@ -269,11 +270,14 @@ _mesa_Accum( GLenum op, GLfloat value ) ypos++; } } - (void) (*ctx->Driver.SetBuffer)( ctx, ctx->Color.DriverDrawBuffer ); + /* restore read buffer = draw buffer (the default) */ + (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, + ctx->Color.DriverDrawBuffer ); break; case GL_LOAD: - (void) (*ctx->Driver.SetBuffer)( ctx, ctx->Pixel.DriverReadBuffer ); + (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, + ctx->Pixel.DriverReadBuffer ); /* This is a change to go into optimized accum buffer mode */ if (value > 0.0 && value <= 1.0) { @@ -328,7 +332,10 @@ _mesa_Accum( GLenum op, GLfloat value ) ypos++; } } - (void) (*ctx->Driver.SetBuffer)( ctx, ctx->Color.DriverDrawBuffer ); + + /* restore read buffer = draw buffer (the default) */ + (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, + ctx->Color.DriverDrawBuffer ); break; case GL_RETURN: diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 55b973e43c7..5dc04fb6fc0 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -1,4 +1,4 @@ -/* $Id: dd.h,v 1.5 1999/11/22 21:54:14 brianp Exp $ */ +/* $Id: dd.h,v 1.6 1999/11/25 17:36:48 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -180,9 +180,9 @@ struct dd_function_table { * This color should also be used in the "mono" drawing functions. */ - GLboolean (*SetBuffer)( GLcontext *ctx, GLenum buffer ); + GLboolean (*SetDrawBuffer)( GLcontext *ctx, GLenum buffer ); /* - * Selects the color buffer(s) for reading and writing. + * 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 @@ -200,6 +200,17 @@ struct dd_function_table { * GL_NONE - disable buffer write in device driver. */ + void (*SetReadBuffer)( GLcontext *ctx, GLframebuffer *colorBuffer, + GLenum buffer ); + /* + * Specifies the current buffer for reading. + * colorBuffer will be one of: + * 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 + */ + void (*GetBufferSize)( GLcontext *ctx, GLuint *width, GLuint *height ); /* * Returns the width and height of the current color buffer. diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 56955af6c86..2db59c0d7fa 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1,4 +1,4 @@ -/* $Id: teximage.c,v 1.13 1999/11/24 18:48:31 brianp Exp $ */ +/* $Id: teximage.c,v 1.14 1999/11/25 17:36:48 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1627,7 +1627,8 @@ read_color_image( GLcontext *ctx, GLint x, GLint y, return NULL; /* Select buffer to read from */ - (void) (*ctx->Driver.SetBuffer)( ctx, ctx->Pixel.DriverReadBuffer ); + (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, + ctx->Pixel.DriverReadBuffer ); dst = image; stride = width * 4 * sizeof(GLubyte); @@ -1637,8 +1638,9 @@ read_color_image( GLcontext *ctx, GLint x, GLint y, dst += stride; } - /* Restore drawing buffer */ - (void) (*ctx->Driver.SetBuffer)( ctx, ctx->Color.DriverDrawBuffer ); + /* Read from draw buffer (the default) */ + (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, + ctx->Color.DriverDrawBuffer ); return image; } @@ -1728,7 +1730,8 @@ copy_tex_sub_image( GLcontext *ctx, struct gl_texture_image *dest, components = components_in_intformat( format ); /* Select buffer to read from */ - (void) (*ctx->Driver.SetBuffer)( ctx, ctx->Pixel.DriverReadBuffer ); + (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, + ctx->Pixel.DriverReadBuffer ); for (i = 0;i < height; i++) { GLubyte rgba[MAX_WIDTH][4]; @@ -1740,8 +1743,9 @@ copy_tex_sub_image( GLcontext *ctx, struct gl_texture_image *dest, &packing, GL_TRUE); } - /* Restore drawing buffer */ - (void) (*ctx->Driver.SetBuffer)( ctx, ctx->Color.DriverDrawBuffer ); + /* Read from draw buffer (the default) */ + (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, + ctx->Color.DriverDrawBuffer ); }