diff options
-rw-r--r-- | src/mesa/drivers/dri/r300/radeon_context.c | 5 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_api.c | 16 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_buffer.c | 39 | ||||
-rw-r--r-- | src/mesa/main/attrib.c | 19 | ||||
-rw-r--r-- | src/mesa/main/colortab.c | 313 | ||||
-rw-r--r-- | src/mesa/main/enable.c | 18 | ||||
-rw-r--r-- | src/mesa/main/framebuffer.c | 7 | ||||
-rw-r--r-- | src/mesa/main/get.c | 18 | ||||
-rw-r--r-- | src/mesa/main/get_gen.py | 6 | ||||
-rw-r--r-- | src/mesa/main/image.c | 6 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 40 | ||||
-rw-r--r-- | src/mesa/main/pixel.c | 20 | ||||
-rw-r--r-- | src/mesa/main/renderbuffer.c | 26 |
13 files changed, 228 insertions, 305 deletions
diff --git a/src/mesa/drivers/dri/r300/radeon_context.c b/src/mesa/drivers/dri/r300/radeon_context.c index 66d1b153b3c..22f943ebf38 100644 --- a/src/mesa/drivers/dri/r300/radeon_context.c +++ b/src/mesa/drivers/dri/r300/radeon_context.c @@ -70,7 +70,10 @@ static const GLubyte *radeonGetString(GLcontext * ctx, GLenum name) switch (name) { case GL_VENDOR: - return (GLubyte *) "Tungsten Graphics, Inc."; + if (IS_R300_CLASS(radeon->radeonScreen)) + return (GLubyte *) "DRI R300 Project"; + else + return (GLubyte *) "Tungsten Graphics, Inc."; case GL_RENDERER: { diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index cbbbd56efd5..b513dc8d40a 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -1842,16 +1842,18 @@ XMesaDestroyBuffer(XMesaBuffer b) * 1. the first time a buffer is bound to a context. * 2. from glViewport to poll for window size changes * 3. from the XMesaResizeBuffers() API function. + * Note: it's possible (and legal) for xmctx to be NULL. That can happen + * when resizing a buffer when no rendering context is bound. */ void xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer) { GLuint width, height; - xmesa_get_window_size(xmctx->display, drawBuffer, &width, &height); + xmesa_get_window_size(drawBuffer->display, drawBuffer, &width, &height); if (drawBuffer->mesa_buffer.Width != width || drawBuffer->mesa_buffer.Height != height) { - _mesa_resize_framebuffer(&(xmctx->mesa), - &(drawBuffer->mesa_buffer), width, height); + GLcontext *ctx = xmctx ? &xmctx->mesa : NULL; + _mesa_resize_framebuffer(ctx, &(drawBuffer->mesa_buffer), width, height); } drawBuffer->mesa_buffer.Initialized = GL_TRUE; /* XXX TEMPORARY? */ } @@ -2175,7 +2177,7 @@ void XMesaSwapBuffers( XMesaBuffer b ) } #endif if (b->backxrb->ximage) { - /* Copy Ximage from host's memory to server's window */ + /* Copy Ximage (back buf) from client memory to server window */ #if defined(USE_XSHM) && !defined(XFree86Server) if (b->shm) { /*_glthread_LOCK_MUTEX(_xmesa_lock);*/ @@ -2197,8 +2199,8 @@ void XMesaSwapBuffers( XMesaBuffer b ) /*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/ } } - else { - /* Copy pixmap to window on server */ + else if (b->backxrb->pixmap) { + /* Copy pixmap (back buf) to window (front buf) on server */ /*_glthread_LOCK_MUTEX(_xmesa_lock);*/ XMesaCopyArea( b->xm_visual->display, b->backxrb->pixmap, /* source drawable */ @@ -2499,6 +2501,8 @@ XMesaResizeBuffers( XMesaBuffer b ) { GET_CURRENT_CONTEXT(ctx); XMesaContext xmctx = XMESA_CONTEXT(ctx); + if (!xmctx) + return; xmesa_check_and_update_buffer_size(xmctx, b); } diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c index 73c46b1fe60..c1fa23328f0 100644 --- a/src/mesa/drivers/x11/xm_buffer.c +++ b/src/mesa/drivers/x11/xm_buffer.c @@ -168,9 +168,6 @@ alloc_back_shm_ximage(XMesaBuffer b, GLuint width, GLuint height) static void alloc_back_buffer(XMesaBuffer b, GLuint width, GLuint height) { - if (width == 0 || height == 0) - return; - if (b->db_mode == BACK_XIMAGE) { /* Deallocate the old backxrb->ximage, if any */ if (b->backxrb->ximage) { @@ -186,6 +183,9 @@ alloc_back_buffer(XMesaBuffer b, GLuint width, GLuint height) b->backxrb->ximage = NULL; } + if (width == 0 || height == 0) + return; + /* Allocate new back buffer */ #ifdef XFree86Server /* Allocate a regular XImage for the back buffer. */ @@ -218,20 +218,20 @@ alloc_back_buffer(XMesaBuffer b, GLuint width, GLuint height) b->backxrb->pixmap = None; } else if (b->db_mode == BACK_PIXMAP) { - if (!width) - width = 1; - if (!height) - height = 1; - /* Free the old back pixmap */ if (b->backxrb->pixmap) { - XMesaFreePixmap(b->xm_visual->display, b->backxrb->pixmap); + XMesaFreePixmap(b->xm_visual->display, b->backxrb->pixmap); + b->backxrb->pixmap = 0; } - /* Allocate new back pixmap */ - b->backxrb->pixmap = XMesaCreatePixmap(b->xm_visual->display, - b->frontxrb->drawable, - width, height, - GET_VISUAL_DEPTH(b->xm_visual)); + + if (width > 0 && height > 0) { + /* Allocate new back pixmap */ + b->backxrb->pixmap = XMesaCreatePixmap(b->xm_visual->display, + b->frontxrb->drawable, + width, height, + GET_VISUAL_DEPTH(b->xm_visual)); + } + b->backxrb->ximage = NULL; } } @@ -250,6 +250,7 @@ xmesa_delete_renderbuffer(struct gl_renderbuffer *rb) /** * Reallocate renderbuffer storage for front color buffer. + * Called via gl_renderbuffer::AllocStorage() */ static GLboolean xmesa_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb, @@ -260,6 +261,7 @@ xmesa_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb, /* just clear these to be sure we don't accidentally use them */ xrb->origin1 = NULL; xrb->origin2 = NULL; + xrb->origin3 = NULL; xrb->origin4 = NULL; /* for the FLIP macro: */ @@ -275,6 +277,7 @@ xmesa_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb, /** * Reallocate renderbuffer storage for back color buffer. + * Called via gl_renderbuffer::AllocStorage() */ static GLboolean xmesa_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb, @@ -309,8 +312,12 @@ xmesa_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb, xrb->origin4 = (GLuint *) xrb->ximage->data + xrb->width4 * (height - 1); } else { - /* this assertion will fail if we happend to run out of memory */ - /*assert(xrb->pixmap);*/ + /* out of memory or buffer size is 0 x 0 */ + xrb->width1 = xrb->width2 = xrb->width3 = xrb->width4 = 0; + xrb->origin1 = NULL; + xrb->origin2 = NULL; + xrb->origin3 = NULL; + xrb->origin4 = NULL; } return GL_TRUE; diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 2b1a35f3de3..0df8d230500 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -138,9 +138,9 @@ _mesa_PushAttrib(GLbitfield mask) attr->Blend = ctx->Color.BlendEnabled; attr->ClipPlanes = ctx->Transform.ClipPlanesEnabled; attr->ColorMaterial = ctx->Light.ColorMaterialEnabled; - attr->ColorTable = ctx->Pixel.ColorTableEnabled; - attr->PostColorMatrixColorTable = ctx->Pixel.PostColorMatrixColorTableEnabled; - attr->PostConvolutionColorTable = ctx->Pixel.PostConvolutionColorTableEnabled; + for (i = 0; i < COLORTABLE_MAX; i++) { + attr->ColorTable[i] = ctx->Pixel.ColorTableEnabled[i]; + } attr->Convolution1D = ctx->Pixel.Convolution1DEnabled; attr->Convolution2D = ctx->Pixel.Convolution2DEnabled; attr->Separable2D = ctx->Pixel.Separable2DEnabled; @@ -432,14 +432,15 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable) TEST_AND_UPDATE(ctx->Light.ColorMaterialEnabled, enable->ColorMaterial, GL_COLOR_MATERIAL); - TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled, enable->ColorTable, + TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION], + enable->ColorTable[COLORTABLE_PRECONVOLUTION], GL_COLOR_TABLE); - TEST_AND_UPDATE(ctx->Pixel.PostColorMatrixColorTableEnabled, - enable->PostColorMatrixColorTable, - GL_POST_COLOR_MATRIX_COLOR_TABLE); - TEST_AND_UPDATE(ctx->Pixel.PostConvolutionColorTableEnabled, - enable->PostConvolutionColorTable, + TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION], + enable->ColorTable[COLORTABLE_POSTCONVOLUTION], GL_POST_CONVOLUTION_COLOR_TABLE); + TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX], + enable->ColorTable[COLORTABLE_POSTCOLORMATRIX], + GL_POST_COLOR_MATRIX_COLOR_TABLE); TEST_AND_UPDATE(ctx->Polygon.CullFlag, enable->CullFace, GL_CULL_FACE); TEST_AND_UPDATE(ctx->Depth.Test, enable->DepthTest, GL_DEPTH_TEST); TEST_AND_UPDATE(ctx->Color.DitherFlag, enable->Dither, GL_DITHER); diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c index 9fb0baf4a7c..d8c4136f49e 100644 --- a/src/mesa/main/colortab.c +++ b/src/mesa/main/colortab.c @@ -291,15 +291,17 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *data ) { + static const GLfloat one[4] = { 1.0, 1.0, 1.0, 1.0 }; + static const GLfloat zero[4] = { 0.0, 0.0, 0.0, 0.0 }; GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; struct gl_texture_object *texObj = NULL; struct gl_color_table *table = NULL; GLboolean proxy = GL_FALSE; GLint baseFormat; - GLfloat rScale = 1.0, gScale = 1.0, bScale = 1.0, aScale = 1.0; - GLfloat rBias = 0.0, gBias = 0.0, bBias = 0.0, aBias = 0.0; + const GLfloat *scale = one, *bias = zero; GLint comps; + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex */ switch (target) { @@ -350,18 +352,12 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat, table = &ctx->Texture.Palette; break; case GL_COLOR_TABLE: - table = &ctx->ColorTable; - rScale = ctx->Pixel.ColorTableScale[0]; - gScale = ctx->Pixel.ColorTableScale[1]; - bScale = ctx->Pixel.ColorTableScale[2]; - aScale = ctx->Pixel.ColorTableScale[3]; - rBias = ctx->Pixel.ColorTableBias[0]; - gBias = ctx->Pixel.ColorTableBias[1]; - bBias = ctx->Pixel.ColorTableBias[2]; - aBias = ctx->Pixel.ColorTableBias[3]; + table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION]; + scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]; + bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]; break; case GL_PROXY_COLOR_TABLE: - table = &ctx->ProxyColorTable; + table = &ctx->ProxyColorTable[COLORTABLE_PRECONVOLUTION]; proxy = GL_TRUE; break; case GL_TEXTURE_COLOR_TABLE_SGI: @@ -370,14 +366,8 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat, return; } table = &(texUnit->ColorTable); - rScale = ctx->Pixel.TextureColorTableScale[0]; - gScale = ctx->Pixel.TextureColorTableScale[1]; - bScale = ctx->Pixel.TextureColorTableScale[2]; - aScale = ctx->Pixel.TextureColorTableScale[3]; - rBias = ctx->Pixel.TextureColorTableBias[0]; - gBias = ctx->Pixel.TextureColorTableBias[1]; - bBias = ctx->Pixel.TextureColorTableBias[2]; - aBias = ctx->Pixel.TextureColorTableBias[3]; + scale = ctx->Pixel.TextureColorTableScale; + bias = ctx->Pixel.TextureColorTableBias; break; case GL_PROXY_TEXTURE_COLOR_TABLE_SGI: if (!ctx->Extensions.SGI_texture_color_table) { @@ -388,33 +378,21 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat, proxy = GL_TRUE; break; case GL_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->PostConvolutionColorTable; - rScale = ctx->Pixel.PCCTscale[0]; - gScale = ctx->Pixel.PCCTscale[1]; - bScale = ctx->Pixel.PCCTscale[2]; - aScale = ctx->Pixel.PCCTscale[3]; - rBias = ctx->Pixel.PCCTbias[0]; - gBias = ctx->Pixel.PCCTbias[1]; - bBias = ctx->Pixel.PCCTbias[2]; - aBias = ctx->Pixel.PCCTbias[3]; + table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION]; + scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]; + bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]; break; case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->ProxyPostConvolutionColorTable; + table = &ctx->ProxyColorTable[COLORTABLE_POSTCONVOLUTION]; proxy = GL_TRUE; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->PostColorMatrixColorTable; - rScale = ctx->Pixel.PCMCTscale[0]; - gScale = ctx->Pixel.PCMCTscale[1]; - bScale = ctx->Pixel.PCMCTscale[2]; - aScale = ctx->Pixel.PCMCTscale[3]; - rBias = ctx->Pixel.PCMCTbias[0]; - gBias = ctx->Pixel.PCMCTbias[1]; - bBias = ctx->Pixel.PCMCTbias[2]; - aBias = ctx->Pixel.PCMCTbias[3]; + table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; + scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]; + bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX]; break; case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->ProxyPostColorMatrixColorTable; + table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX]; proxy = GL_TRUE; break; default: @@ -483,10 +461,10 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat, store_colortable_entries(ctx, table, 0, width, /* start, count */ format, type, data, - rScale, rBias, - gScale, gBias, - bScale, bBias, - aScale, aBias); + scale[0], bias[0], + scale[1], bias[1], + scale[2], bias[2], + scale[3], bias[3]); } } /* proxy */ @@ -510,12 +488,14 @@ _mesa_ColorSubTable( GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data ) { + static const GLfloat one[4] = { 1.0, 1.0, 1.0, 1.0 }; + static const GLfloat zero[4] = { 0.0, 0.0, 0.0, 0.0 }; GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; struct gl_texture_object *texObj = NULL; struct gl_color_table *table = NULL; - GLfloat rScale = 1.0, gScale = 1.0, bScale = 1.0, aScale = 1.0; - GLfloat rBias = 0.0, gBias = 0.0, bBias = 0.0, aBias = 0.0; + const GLfloat *scale = one, *bias = zero; + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); switch (target) { @@ -543,15 +523,9 @@ _mesa_ColorSubTable( GLenum target, GLsizei start, table = &ctx->Texture.Palette; break; case GL_COLOR_TABLE: - table = &ctx->ColorTable; - rScale = ctx->Pixel.ColorTableScale[0]; - gScale = ctx->Pixel.ColorTableScale[1]; - bScale = ctx->Pixel.ColorTableScale[2]; - aScale = ctx->Pixel.ColorTableScale[3]; - rBias = ctx->Pixel.ColorTableBias[0]; - gBias = ctx->Pixel.ColorTableBias[1]; - bBias = ctx->Pixel.ColorTableBias[2]; - aBias = ctx->Pixel.ColorTableBias[3]; + table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION]; + scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]; + bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]; break; case GL_TEXTURE_COLOR_TABLE_SGI: if (!ctx->Extensions.SGI_texture_color_table) { @@ -559,36 +533,18 @@ _mesa_ColorSubTable( GLenum target, GLsizei start, return; } table = &(texUnit->ColorTable); - rScale = ctx->Pixel.TextureColorTableScale[0]; - gScale = ctx->Pixel.TextureColorTableScale[1]; - bScale = ctx->Pixel.TextureColorTableScale[2]; - aScale = ctx->Pixel.TextureColorTableScale[3]; - rBias = ctx->Pixel.TextureColorTableBias[0]; - gBias = ctx->Pixel.TextureColorTableBias[1]; - bBias = ctx->Pixel.TextureColorTableBias[2]; - aBias = ctx->Pixel.TextureColorTableBias[3]; + scale = ctx->Pixel.TextureColorTableScale; + bias = ctx->Pixel.TextureColorTableBias; break; case GL_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->PostConvolutionColorTable; - rScale = ctx->Pixel.PCCTscale[0]; - gScale = ctx->Pixel.PCCTscale[1]; - bScale = ctx->Pixel.PCCTscale[2]; - aScale = ctx->Pixel.PCCTscale[3]; - rBias = ctx->Pixel.PCCTbias[0]; - gBias = ctx->Pixel.PCCTbias[1]; - bBias = ctx->Pixel.PCCTbias[2]; - aBias = ctx->Pixel.PCCTbias[3]; + table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION]; + scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]; + bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->PostColorMatrixColorTable; - rScale = ctx->Pixel.PCMCTscale[0]; - gScale = ctx->Pixel.PCMCTscale[1]; - bScale = ctx->Pixel.PCMCTscale[2]; - aScale = ctx->Pixel.PCMCTscale[3]; - rBias = ctx->Pixel.PCMCTbias[0]; - gBias = ctx->Pixel.PCMCTbias[1]; - bBias = ctx->Pixel.PCMCTbias[2]; - aBias = ctx->Pixel.PCMCTbias[3]; + table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; + scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]; + bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX]; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)"); @@ -623,10 +579,10 @@ _mesa_ColorSubTable( GLenum target, GLsizei start, store_colortable_entries(ctx, table, start, count, format, type, data, - rScale, rBias, - gScale, gBias, - bScale, bBias, - aScale, aBias); + scale[0], bias[0], + scale[1], bias[1], + scale[2], bias[2], + scale[3], bias[3]); if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) { /* per-texture object palette */ @@ -700,7 +656,7 @@ _mesa_GetColorTable( GLenum target, GLenum format, table = &ctx->Texture.Palette; break; case GL_COLOR_TABLE: - table = &ctx->ColorTable; + table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION]; break; case GL_TEXTURE_COLOR_TABLE_SGI: if (!ctx->Extensions.SGI_texture_color_table) { @@ -710,10 +666,10 @@ _mesa_GetColorTable( GLenum target, GLenum format, table = &(texUnit->ColorTable); break; case GL_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->PostConvolutionColorTable; + table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION]; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->PostColorMatrixColorTable; + table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)"); @@ -827,16 +783,10 @@ _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) switch (target) { case GL_COLOR_TABLE_SGI: if (pname == GL_COLOR_TABLE_SCALE_SGI) { - ctx->Pixel.ColorTableScale[0] = params[0]; - ctx->Pixel.ColorTableScale[1] = params[1]; - ctx->Pixel.ColorTableScale[2] = params[2]; - ctx->Pixel.ColorTableScale[3] = params[3]; + COPY_4V(ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION], params); } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - ctx->Pixel.ColorTableBias[0] = params[0]; - ctx->Pixel.ColorTableBias[1] = params[1]; - ctx->Pixel.ColorTableBias[2] = params[2]; - ctx->Pixel.ColorTableBias[3] = params[3]; + COPY_4V(ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION], params); } else { _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); @@ -849,16 +799,10 @@ _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) return; } if (pname == GL_COLOR_TABLE_SCALE_SGI) { - ctx->Pixel.TextureColorTableScale[0] = params[0]; - ctx->Pixel.TextureColorTableScale[1] = params[1]; - ctx->Pixel.TextureColorTableScale[2] = params[2]; - ctx->Pixel.TextureColorTableScale[3] = params[3]; + COPY_4V(ctx->Pixel.TextureColorTableScale, params); } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - ctx->Pixel.TextureColorTableBias[0] = params[0]; - ctx->Pixel.TextureColorTableBias[1] = params[1]; - ctx->Pixel.TextureColorTableBias[2] = params[2]; - ctx->Pixel.TextureColorTableBias[3] = params[3]; + COPY_4V(ctx->Pixel.TextureColorTableBias, params); } else { _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); @@ -867,16 +811,10 @@ _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) break; case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: if (pname == GL_COLOR_TABLE_SCALE_SGI) { - ctx->Pixel.PCCTscale[0] = params[0]; - ctx->Pixel.PCCTscale[1] = params[1]; - ctx->Pixel.PCCTscale[2] = params[2]; - ctx->Pixel.PCCTscale[3] = params[3]; + COPY_4V(ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION], params); } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - ctx->Pixel.PCCTbias[0] = params[0]; - ctx->Pixel.PCCTbias[1] = params[1]; - ctx->Pixel.PCCTbias[2] = params[2]; - ctx->Pixel.PCCTbias[3] = params[3]; + COPY_4V(ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION], params); } else { _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); @@ -885,16 +823,10 @@ _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) break; case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: if (pname == GL_COLOR_TABLE_SCALE_SGI) { - ctx->Pixel.PCMCTscale[0] = params[0]; - ctx->Pixel.PCMCTscale[1] = params[1]; - ctx->Pixel.PCMCTscale[2] = params[2]; - ctx->Pixel.PCMCTscale[3] = params[3]; + COPY_4V(ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX], params); } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - ctx->Pixel.PCMCTbias[0] = params[0]; - ctx->Pixel.PCMCTbias[1] = params[1]; - ctx->Pixel.PCMCTbias[2] = params[2]; - ctx->Pixel.PCMCTbias[3] = params[3]; + COPY_4V(ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX], params); } else { _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); @@ -981,24 +913,18 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) table = &ctx->Texture.Palette; break; case GL_COLOR_TABLE: - table = &ctx->ColorTable; + table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION]; if (pname == GL_COLOR_TABLE_SCALE_SGI) { - params[0] = ctx->Pixel.ColorTableScale[0]; - params[1] = ctx->Pixel.ColorTableScale[1]; - params[2] = ctx->Pixel.ColorTableScale[2]; - params[3] = ctx->Pixel.ColorTableScale[3]; + COPY_4V(params, ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]); return; } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - params[0] = ctx->Pixel.ColorTableBias[0]; - params[1] = ctx->Pixel.ColorTableBias[1]; - params[2] = ctx->Pixel.ColorTableBias[2]; - params[3] = ctx->Pixel.ColorTableBias[3]; + COPY_4V(params, ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]); return; } break; case GL_PROXY_COLOR_TABLE: - table = &ctx->ProxyColorTable; + table = &ctx->ProxyColorTable[COLORTABLE_PRECONVOLUTION]; break; case GL_TEXTURE_COLOR_TABLE_SGI: if (!ctx->Extensions.SGI_texture_color_table) { @@ -1007,17 +933,11 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) } table = &(texUnit->ColorTable); if (pname == GL_COLOR_TABLE_SCALE_SGI) { - params[0] = ctx->Pixel.TextureColorTableScale[0]; - params[1] = ctx->Pixel.TextureColorTableScale[1]; - params[2] = ctx->Pixel.TextureColorTableScale[2]; - params[3] = ctx->Pixel.TextureColorTableScale[3]; + COPY_4V(params, ctx->Pixel.TextureColorTableScale); return; } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - params[0] = ctx->Pixel.TextureColorTableBias[0]; - params[1] = ctx->Pixel.TextureColorTableBias[1]; - params[2] = ctx->Pixel.TextureColorTableBias[2]; - params[3] = ctx->Pixel.TextureColorTableBias[3]; + COPY_4V(params, ctx->Pixel.TextureColorTableBias); return; } break; @@ -1029,44 +949,32 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) table = &(texUnit->ProxyColorTable); break; case GL_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->PostConvolutionColorTable; + table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION]; if (pname == GL_COLOR_TABLE_SCALE_SGI) { - params[0] = ctx->Pixel.PCCTscale[0]; - params[1] = ctx->Pixel.PCCTscale[1]; - params[2] = ctx->Pixel.PCCTscale[2]; - params[3] = ctx->Pixel.PCCTscale[3]; + COPY_4V(params, ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]); return; } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - params[0] = ctx->Pixel.PCCTbias[0]; - params[1] = ctx->Pixel.PCCTbias[1]; - params[2] = ctx->Pixel.PCCTbias[2]; - params[3] = ctx->Pixel.PCCTbias[3]; + COPY_4V(params, ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]); return; } break; case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->ProxyPostConvolutionColorTable; + table = &ctx->ProxyColorTable[COLORTABLE_POSTCONVOLUTION]; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->PostColorMatrixColorTable; + table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; if (pname == GL_COLOR_TABLE_SCALE_SGI) { - params[0] = ctx->Pixel.PCMCTscale[0]; - params[1] = ctx->Pixel.PCMCTscale[1]; - params[2] = ctx->Pixel.PCMCTscale[2]; - params[3] = ctx->Pixel.PCMCTscale[3]; + COPY_4V(params, ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]); return; } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - params[0] = ctx->Pixel.PCMCTbias[0]; - params[1] = ctx->Pixel.PCMCTbias[1]; - params[2] = ctx->Pixel.PCMCTbias[2]; - params[3] = ctx->Pixel.PCMCTbias[3]; + COPY_4V(params, ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX]); return; } break; case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->ProxyPostColorMatrixColorTable; + table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX]; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(target)"); @@ -1155,24 +1063,26 @@ _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) table = &ctx->Texture.Palette; break; case GL_COLOR_TABLE: - table = &ctx->ColorTable; + table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION]; if (pname == GL_COLOR_TABLE_SCALE_SGI) { - params[0] = (GLint) ctx->Pixel.ColorTableScale[0]; - params[1] = (GLint) ctx->Pixel.ColorTableScale[1]; - params[2] = (GLint) ctx->Pixel.ColorTableScale[2]; - params[3] = (GLint) ctx->Pixel.ColorTableScale[3]; + GLfloat *scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]; + params[0] = (GLint) scale[0]; + params[1] = (GLint) scale[1]; + params[2] = (GLint) scale[2]; + params[3] = (GLint) scale[3]; return; } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - params[0] = (GLint) ctx->Pixel.ColorTableBias[0]; - params[1] = (GLint) ctx->Pixel.ColorTableBias[1]; - params[2] = (GLint) ctx->Pixel.ColorTableBias[2]; - params[3] = (GLint) ctx->Pixel.ColorTableBias[3]; + GLfloat *bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]; + params[0] = (GLint) bias[0]; + params[1] = (GLint) bias[1]; + params[2] = (GLint) bias[2]; + params[3] = (GLint) bias[3]; return; } break; case GL_PROXY_COLOR_TABLE: - table = &ctx->ProxyColorTable; + table = &ctx->ProxyColorTable[COLORTABLE_PRECONVOLUTION]; break; case GL_TEXTURE_COLOR_TABLE_SGI: if (!ctx->Extensions.SGI_texture_color_table) { @@ -1203,44 +1113,48 @@ _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) table = &(texUnit->ProxyColorTable); break; case GL_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->PostConvolutionColorTable; + table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION]; if (pname == GL_COLOR_TABLE_SCALE_SGI) { - params[0] = (GLint) ctx->Pixel.PCCTscale[0]; - params[1] = (GLint) ctx->Pixel.PCCTscale[1]; - params[2] = (GLint) ctx->Pixel.PCCTscale[2]; - params[3] = (GLint) ctx->Pixel.PCCTscale[3]; + GLfloat *scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]; + params[0] = (GLint) scale[0]; + params[1] = (GLint) scale[1]; + params[2] = (GLint) scale[2]; + params[3] = (GLint) scale[3]; return; } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - params[0] = (GLint) ctx->Pixel.PCCTbias[0]; - params[1] = (GLint) ctx->Pixel.PCCTbias[1]; - params[2] = (GLint) ctx->Pixel.PCCTbias[2]; - params[3] = (GLint) ctx->Pixel.PCCTbias[3]; + GLfloat *bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]; + params[0] = (GLint) bias[0]; + params[1] = (GLint) bias[1]; + params[2] = (GLint) bias[2]; + params[3] = (GLint) bias[3]; return; } break; case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->ProxyPostConvolutionColorTable; + table = &ctx->ProxyColorTable[COLORTABLE_POSTCONVOLUTION]; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->PostColorMatrixColorTable; + table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; if (pname == GL_COLOR_TABLE_SCALE_SGI) { - params[0] = (GLint) ctx->Pixel.PCMCTscale[0]; - params[1] = (GLint) ctx->Pixel.PCMCTscale[1]; - params[2] = (GLint) ctx->Pixel.PCMCTscale[2]; - params[3] = (GLint) ctx->Pixel.PCMCTscale[3]; + GLfloat *scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]; + params[0] = (GLint) scale[0]; + params[0] = (GLint) scale[1]; + params[0] = (GLint) scale[2]; + params[0] = (GLint) scale[3]; return; } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - params[0] = (GLint) ctx->Pixel.PCMCTbias[0]; - params[1] = (GLint) ctx->Pixel.PCMCTbias[1]; - params[2] = (GLint) ctx->Pixel.PCMCTbias[2]; - params[3] = (GLint) ctx->Pixel.PCMCTbias[3]; + GLfloat *bias = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]; + params[0] = (GLint) bias[0]; + params[1] = (GLint) bias[1]; + params[2] = (GLint) bias[2]; + params[3] = (GLint) bias[3]; return; } break; case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->ProxyPostColorMatrixColorTable; + table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX]; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(target)"); @@ -1316,13 +1230,11 @@ _mesa_free_colortable_data( struct gl_color_table *p ) void _mesa_init_colortables( GLcontext * ctx ) { - /* Color tables */ - _mesa_init_colortable(&ctx->ColorTable); - _mesa_init_colortable(&ctx->ProxyColorTable); - _mesa_init_colortable(&ctx->PostConvolutionColorTable); - _mesa_init_colortable(&ctx->ProxyPostConvolutionColorTable); - _mesa_init_colortable(&ctx->PostColorMatrixColorTable); - _mesa_init_colortable(&ctx->ProxyPostColorMatrixColorTable); + GLuint i; + for (i = 0; i < COLORTABLE_MAX; i++) { + _mesa_init_colortable(&ctx->ColorTable[i]); + _mesa_init_colortable(&ctx->ProxyColorTable[i]); + } } @@ -1332,10 +1244,9 @@ _mesa_init_colortables( GLcontext * ctx ) void _mesa_free_colortables_data( GLcontext *ctx ) { - _mesa_free_colortable_data(&ctx->ColorTable); - _mesa_free_colortable_data(&ctx->ProxyColorTable); - _mesa_free_colortable_data(&ctx->PostConvolutionColorTable); - _mesa_free_colortable_data(&ctx->ProxyPostConvolutionColorTable); - _mesa_free_colortable_data(&ctx->PostColorMatrixColorTable); - _mesa_free_colortable_data(&ctx->ProxyPostColorMatrixColorTable); + GLuint i; + for (i = 0; i < COLORTABLE_MAX; i++) { + _mesa_free_colortable_data(&ctx->ColorTable[i]); + _mesa_free_colortable_data(&ctx->ProxyColorTable[i]); + } } diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 0d54c29949b..11b4ad6400e 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -663,24 +663,24 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state) /* GL_SGI_color_table */ case GL_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_color_table, cap); - if (ctx->Pixel.ColorTableEnabled == state) + if (ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.ColorTableEnabled = state; + ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] = state; break; case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_color_table, cap); - if (ctx->Pixel.PostConvolutionColorTableEnabled == state) + if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostConvolutionColorTableEnabled = state; + ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] = state; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_color_table, cap); - if (ctx->Pixel.PostColorMatrixColorTableEnabled == state) + if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostColorMatrixColorTableEnabled = state; + ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] = state; break; case GL_TEXTURE_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_texture_color_table, cap); @@ -1192,13 +1192,13 @@ _mesa_IsEnabled( GLenum cap ) /* GL_SGI_color_table */ case GL_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_color_table); - return ctx->Pixel.ColorTableEnabled; + return ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]; case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_color_table); - return ctx->Pixel.PostConvolutionColorTableEnabled; + return ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]; case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_color_table); - return ctx->Pixel.PostColorMatrixColorTableEnabled; + return ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]; /* GL_SGI_texture_color_table */ case GL_TEXTURE_COLOR_TABLE_SGI: diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 3136a950e08..cd4f594aa29 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -647,7 +647,7 @@ update_color_draw_buffers(GLcontext *ctx, struct gl_framebuffer *fb) const GLuint bufferBit = 1 << i; if (bufferBit & bufferMask) { struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer; - if (rb) { + if (rb && rb->Width > 0 && rb->Height > 0) { fb->_ColorDrawBuffers[output][count] = rb; count++; } @@ -673,7 +673,10 @@ static void update_color_read_buffer(GLcontext *ctx, struct gl_framebuffer *fb) { (void) ctx; - if (fb->_ColorReadBufferIndex == -1 || fb->DeletePending) { + if (fb->_ColorReadBufferIndex == -1 || + fb->DeletePending || + fb->Width == 0 || + fb->Height == 0) { fb->_ColorReadBuffer = NULL; /* legal! */ } else { diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 7601f320697..4eda3491341 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1283,15 +1283,15 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) break; case GL_COLOR_TABLE_SGI: CHECK_EXT1(SGI_color_table, "GetBooleanv"); - params[0] = ctx->Pixel.ColorTableEnabled; + params[0] = ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]; break; case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: CHECK_EXT1(SGI_color_table, "GetBooleanv"); - params[0] = ctx->Pixel.PostConvolutionColorTableEnabled; + params[0] = ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: CHECK_EXT1(SGI_color_table, "GetBooleanv"); - params[0] = ctx->Pixel.PostColorMatrixColorTableEnabled; + params[0] = ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]; break; case GL_TEXTURE_COLOR_TABLE_SGI: CHECK_EXT1(SGI_texture_color_table, "GetBooleanv"); @@ -3110,15 +3110,15 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) break; case GL_COLOR_TABLE_SGI: CHECK_EXT1(SGI_color_table, "GetFloatv"); - params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.ColorTableEnabled); + params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]); break; case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: CHECK_EXT1(SGI_color_table, "GetFloatv"); - params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.PostConvolutionColorTableEnabled); + params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]); break; case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: CHECK_EXT1(SGI_color_table, "GetFloatv"); - params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.PostColorMatrixColorTableEnabled); + params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]); break; case GL_TEXTURE_COLOR_TABLE_SGI: CHECK_EXT1(SGI_texture_color_table, "GetFloatv"); @@ -4937,15 +4937,15 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) break; case GL_COLOR_TABLE_SGI: CHECK_EXT1(SGI_color_table, "GetIntegerv"); - params[0] = BOOLEAN_TO_INT(ctx->Pixel.ColorTableEnabled); + params[0] = BOOLEAN_TO_INT(ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]); break; case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: CHECK_EXT1(SGI_color_table, "GetIntegerv"); - params[0] = BOOLEAN_TO_INT(ctx->Pixel.PostConvolutionColorTableEnabled); + params[0] = BOOLEAN_TO_INT(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]); break; case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: CHECK_EXT1(SGI_color_table, "GetIntegerv"); - params[0] = BOOLEAN_TO_INT(ctx->Pixel.PostColorMatrixColorTableEnabled); + params[0] = BOOLEAN_TO_INT(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]); break; case GL_TEXTURE_COLOR_TABLE_SGI: CHECK_EXT1(SGI_texture_color_table, "GetIntegerv"); diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index 76417d28991..0b6cd3e5c58 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -624,11 +624,11 @@ StateVars = [ # GL_SGI_color_table / GL_ARB_imaging ( "GL_COLOR_TABLE_SGI", GLboolean, - ["ctx->Pixel.ColorTableEnabled"], "", ["SGI_color_table"] ), + ["ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]"], "", ["SGI_color_table"] ), ( "GL_POST_CONVOLUTION_COLOR_TABLE_SGI", GLboolean, - ["ctx->Pixel.PostConvolutionColorTableEnabled"], "", ["SGI_color_table"] ), + ["ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]"], "", ["SGI_color_table"] ), ( "GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI", GLboolean, - ["ctx->Pixel.PostColorMatrixColorTableEnabled"], "", ["SGI_color_table"] ), + ["ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]"], "", ["SGI_color_table"] ), # GL_SGI_texture_color_table ( "GL_TEXTURE_COLOR_TABLE_SGI", GLboolean, diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index f53730cbcf5..cad9736b30b 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1036,7 +1036,7 @@ _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps, } /* GL_COLOR_TABLE lookup */ if (transferOps & IMAGE_COLOR_TABLE_BIT) { - _mesa_lookup_rgba_float(&ctx->ColorTable, n, rgba); + _mesa_lookup_rgba_float(&ctx->ColorTable[COLORTABLE_PRECONVOLUTION], n, rgba); } /* convolution */ if (transferOps & IMAGE_CONVOLUTION_BIT) { @@ -1057,7 +1057,7 @@ _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps, } /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */ if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) { - _mesa_lookup_rgba_float(&ctx->PostConvolutionColorTable, n, rgba); + _mesa_lookup_rgba_float(&ctx->ColorTable[COLORTABLE_POSTCONVOLUTION], n, rgba); } /* color matrix transform */ if (transferOps & IMAGE_COLOR_MATRIX_BIT) { @@ -1065,7 +1065,7 @@ _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps, } /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */ if (transferOps & IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT) { - _mesa_lookup_rgba_float(&ctx->PostColorMatrixColorTable, n, rgba); + _mesa_lookup_rgba_float(&ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX], n, rgba); } /* update histogram count */ if (transferOps & IMAGE_HISTOGRAM_BIT) { diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index bced1a64d98..65246eb116b 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -383,6 +383,13 @@ enum { BUFFER_BIT_COLOR7) +/** The pixel transfer path has three color tables: */ +/*@{*/ +#define COLORTABLE_PRECONVOLUTION 0 +#define COLORTABLE_POSTCONVOLUTION 1 +#define COLORTABLE_POSTCOLORMATRIX 2 +#define COLORTABLE_MAX 3 +/*@}*/ /** @@ -663,9 +670,7 @@ struct gl_enable_attrib GLboolean Blend; GLbitfield ClipPlanes; GLboolean ColorMaterial; - GLboolean ColorTable; /* SGI_color_table */ - GLboolean PostColorMatrixColorTable; /* SGI_color_table */ - GLboolean PostConvolutionColorTable; /* SGI_color_table */ + GLboolean ColorTable[COLORTABLE_MAX]; GLboolean Convolution1D; GLboolean Convolution2D; GLboolean Separable2D; @@ -1016,11 +1021,10 @@ struct gl_pixel_attrib GLboolean MapColorFlag; GLboolean MapStencilFlag; - /* Color table lookup (GL_SGI_color_table) */ - /* Note: actual table is not part of this attrib group */ - GLfloat ColorTableScale[4]; - GLfloat ColorTableBias[4]; - GLboolean ColorTableEnabled; + /* There are multiple color table stages: */ + GLboolean ColorTableEnabled[COLORTABLE_MAX]; + GLfloat ColorTableScale[COLORTABLE_MAX][4]; /**< RGBA */ + GLfloat ColorTableBias[COLORTABLE_MAX][4]; /**< RGBA */ /* Convolution (GL_EXT_convolution) */ GLboolean Convolution1DEnabled; @@ -1033,23 +1037,11 @@ struct gl_pixel_attrib GLfloat PostConvolutionScale[4]; /**< RGBA */ GLfloat PostConvolutionBias[4]; /**< RGBA */ - /* Post-convolution color table */ - /* Note: actual table is not part of this attrib group */ - GLboolean PostConvolutionColorTableEnabled; - GLfloat PCCTscale[4]; /** Post Convolution Color Table scale */ - GLfloat PCCTbias[4]; /** Post Convolution Color Table bias */ - /* Color matrix (GL_SGI_color_matrix) */ /* Note: the color matrix is not part of this attrib group */ GLfloat PostColorMatrixScale[4]; /**< RGBA */ GLfloat PostColorMatrixBias[4]; /**< RGBA */ - /* Post color matrix color table */ - /* Note: actual table is not part of this attrib group */ - GLboolean PostColorMatrixColorTableEnabled; - GLfloat PCMCTscale[4]; /** Post Color Matrix Color Table scale */ - GLfloat PCMCTbias[4]; /** Post Color Matrix Color Table bias */ - /* Histogram & minmax (GL_EXT_histogram) */ /* Note: histogram and minmax data are not part of this attrib group */ GLboolean HistogramEnabled; @@ -2169,7 +2161,7 @@ struct gl_renderbuffer GLubyte IndexBits; GLubyte DepthBits; GLubyte StencilBits; - GLvoid *Data; + GLvoid *Data; /**< This may not be used by some kinds of RBs */ /* Used to wrap one renderbuffer around another: */ struct gl_renderbuffer *Wrapped; @@ -2934,12 +2926,14 @@ struct __GLcontextRec struct gl_feedback Feedback; /**< Feedback */ struct gl_selection Select; /**< Selection */ - struct gl_color_table ColorTable; /**< Pre-convolution */ - struct gl_color_table ProxyColorTable; /**< Pre-convolution */ + struct gl_color_table ColorTable[COLORTABLE_MAX]; + struct gl_color_table ProxyColorTable[COLORTABLE_MAX]; +#if 0 struct gl_color_table PostConvolutionColorTable; struct gl_color_table ProxyPostConvolutionColorTable; struct gl_color_table PostColorMatrixColorTable; struct gl_color_table ProxyPostColorMatrixColorTable; +#endif struct gl_program_state Program; /**< for vertex or fragment progs */ struct gl_vertex_program_state VertexProgram; /**< GL_ARB/NV_vertex_program */ diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c index ae014a23c4c..b9e23d80b62 100644 --- a/src/mesa/main/pixel.c +++ b/src/mesa/main/pixel.c @@ -1367,7 +1367,7 @@ update_image_transfer_state(GLcontext *ctx) if (ctx->Pixel.MapColorFlag) mask |= IMAGE_MAP_COLOR_BIT; - if (ctx->Pixel.ColorTableEnabled) + if (ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]) mask |= IMAGE_COLOR_TABLE_BIT; if (ctx->Pixel.Convolution1DEnabled || @@ -1386,7 +1386,7 @@ update_image_transfer_state(GLcontext *ctx) } } - if (ctx->Pixel.PostConvolutionColorTableEnabled) + if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]) mask |= IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT; if (ctx->ColorMatrixStack.Top->type != MATRIX_IDENTITY || @@ -1400,7 +1400,7 @@ update_image_transfer_state(GLcontext *ctx) ctx->Pixel.PostColorMatrixBias[3] != 0.0F) mask |= IMAGE_COLOR_MATRIX_BIT; - if (ctx->Pixel.PostColorMatrixColorTableEnabled) + if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]) mask |= IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT; if (ctx->Pixel.HistogramEnabled) @@ -1477,15 +1477,11 @@ _mesa_init_pixel( GLcontext *ctx ) ctx->Pixel.MinMaxEnabled = GL_FALSE; ASSIGN_4V(ctx->Pixel.PostColorMatrixScale, 1.0, 1.0, 1.0, 1.0); ASSIGN_4V(ctx->Pixel.PostColorMatrixBias, 0.0, 0.0, 0.0, 0.0); - ASSIGN_4V(ctx->Pixel.ColorTableScale, 1.0, 1.0, 1.0, 1.0); - ASSIGN_4V(ctx->Pixel.ColorTableBias, 0.0, 0.0, 0.0, 0.0); - ASSIGN_4V(ctx->Pixel.PCCTscale, 1.0, 1.0, 1.0, 1.0); - ASSIGN_4V(ctx->Pixel.PCCTbias, 0.0, 0.0, 0.0, 0.0); - ASSIGN_4V(ctx->Pixel.PCMCTscale, 1.0, 1.0, 1.0, 1.0); - ASSIGN_4V(ctx->Pixel.PCMCTbias, 0.0, 0.0, 0.0, 0.0); - ctx->Pixel.ColorTableEnabled = GL_FALSE; - ctx->Pixel.PostConvolutionColorTableEnabled = GL_FALSE; - ctx->Pixel.PostColorMatrixColorTableEnabled = GL_FALSE; + for (i = 0; i < COLORTABLE_MAX; i++) { + ASSIGN_4V(ctx->Pixel.ColorTableScale[i], 1.0, 1.0, 1.0, 1.0); + ASSIGN_4V(ctx->Pixel.ColorTableBias[i], 0.0, 0.0, 0.0, 0.0); + ctx->Pixel.ColorTableEnabled[i] = GL_FALSE; + } ctx->Pixel.Convolution1DEnabled = GL_FALSE; ctx->Pixel.Convolution2DEnabled = GL_FALSE; ctx->Pixel.Separable2DEnabled = GL_FALSE; diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index 1cc95a7d3b4..e387c42c345 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -1192,18 +1192,22 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, ASSERT(rb->PutMonoValues); /* free old buffer storage */ - if (rb->Data) + if (rb->Data) { _mesa_free(rb->Data); - - /* allocate new buffer storage */ - rb->Data = _mesa_malloc(width * height * pixelSize); - if (rb->Data == NULL) { - rb->Width = 0; - rb->Height = 0; - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "software renderbuffer allocation (%d x %d x %d)", - width, height, pixelSize); - return GL_FALSE; + rb->Data = NULL; + } + + if (width > 0 && height > 0) { + /* allocate new buffer storage */ + rb->Data = _mesa_malloc(width * height * pixelSize); + if (rb->Data == NULL) { + rb->Width = 0; + rb->Height = 0; + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "software renderbuffer allocation (%d x %d x %d)", + width, height, pixelSize); + return GL_FALSE; + } } rb->Width = width; |