From 038e981cacdc6f32588442666cde8a8fc16cfdfc Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 15 Mar 2007 11:11:41 -0600 Subject: add some rb->Data null ptr checks (bug 7205) --- src/mesa/swrast/s_accum.c | 4 +++- src/mesa/swrast/s_depth.c | 2 +- src/mesa/swrast/s_stencil.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c index 69e9404c55..f53e7f52c5 100644 --- a/src/mesa/swrast/s_accum.c +++ b/src/mesa/swrast/s_accum.c @@ -136,7 +136,9 @@ _swrast_clear_accum_buffer( GLcontext *ctx, struct gl_renderbuffer *rb ) return; } - assert(rb); + if (!rb || !rb->Data) + return; + assert(rb->_BaseFormat == GL_RGBA); /* add other types in future? */ assert(rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT); diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c index 408174c990..dde2b1db83 100644 --- a/src/mesa/swrast/s_depth.c +++ b/src/mesa/swrast/s_depth.c @@ -1350,7 +1350,7 @@ _swrast_clear_depth_buffer( GLcontext *ctx, struct gl_renderbuffer *rb ) GLuint clearValue; GLint x, y, width, height; - if (!rb || !ctx->Depth.Mask) { + if (!rb || !ctx->Depth.Mask || !rb->Data) { /* no depth buffer, or writing to it is disabled */ return; } diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c index a8aa1d4b6d..43475c0e81 100644 --- a/src/mesa/swrast/s_stencil.c +++ b/src/mesa/swrast/s_stencil.c @@ -1154,7 +1154,7 @@ _swrast_clear_stencil_buffer( GLcontext *ctx, struct gl_renderbuffer *rb ) const GLuint stencilMax = (1 << stencilBits) - 1; GLint x, y, width, height; - if (!rb || mask == 0) + if (!rb || mask == 0 || !rb->Data) return; ASSERT(rb->DataType == GL_UNSIGNED_BYTE || -- cgit v1.2.3 From bb02092d749ff9d58a13fd99f66154504b4f3dd1 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Sun, 18 Mar 2007 18:44:51 +0800 Subject: mesa: SWAP_BUFF support when calling DrawPixels(DEPTH_COMPONENT) or TexImage(DEPTH_COMPONENT) --- src/mesa/main/image.c | 98 +++++++++++++++++++++------------------------ src/mesa/swrast/s_drawpix.c | 6 ++- 2 files changed, 49 insertions(+), 55 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index cad9736b30..44729b7419 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -3877,6 +3877,22 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n, } } +#define DEPTH_VALUES(GLTYPE, GLTYPE2FLOAT) \ + do { \ + GLuint i; \ + const GLTYPE *src = (const GLTYPE *)source; \ + for (i = 0; i < n; i++) { \ + GLTYPE value = src[i]; \ + if (srcPacking->SwapBytes) { \ + if (sizeof(GLTYPE) == 2) { \ + SWAP2BYTE(value); \ + } else if (sizeof(GLTYPE) == 4) { \ + SWAP4BYTE(value); \ + } \ + } \ + depthValues[i] = CLAMP(GLTYPE2FLOAT(value), 0.0F, 1.0F); \ + } \ + } while (0) void _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, @@ -3898,59 +3914,23 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, switch (srcType) { case GL_BYTE: - { - GLuint i; - const GLubyte *src = (const GLubyte *) source; - for (i = 0; i < n; i++) { - depthValues[i] = BYTE_TO_FLOAT(src[i]); - } - } - break; + DEPTH_VALUES(GLbyte, BYTE_TO_FLOAT); + break; case GL_UNSIGNED_BYTE: - { - GLuint i; - const GLubyte *src = (const GLubyte *) source; - for (i = 0; i < n; i++) { - depthValues[i] = UBYTE_TO_FLOAT(src[i]); - } - } - break; + DEPTH_VALUES(GLubyte, UBYTE_TO_FLOAT); + break; case GL_SHORT: - { - GLuint i; - const GLshort *src = (const GLshort *) source; - for (i = 0; i < n; i++) { - depthValues[i] = SHORT_TO_FLOAT(src[i]); - } - } - break; + DEPTH_VALUES(GLshort, SHORT_TO_FLOAT); + break; case GL_UNSIGNED_SHORT: - { - GLuint i; - const GLushort *src = (const GLushort *) source; - for (i = 0; i < n; i++) { - depthValues[i] = USHORT_TO_FLOAT(src[i]); - } - } - break; + DEPTH_VALUES(GLushort, USHORT_TO_FLOAT); + break; case GL_INT: - { - GLuint i; - const GLint *src = (const GLint *) source; - for (i = 0; i < n; i++) { - depthValues[i] = INT_TO_FLOAT(src[i]); - } - } - break; + DEPTH_VALUES(GLint, INT_TO_FLOAT); + break; case GL_UNSIGNED_INT: - { - GLuint i; - const GLuint *src = (const GLuint *) source; - for (i = 0; i < n; i++) { - depthValues[i] = UINT_TO_FLOAT(src[i]); - } - } - break; + DEPTH_VALUES(GLuint, UINT_TO_FLOAT); + break; case GL_UNSIGNED_INT_24_8_EXT: /* GL_EXT_packed_depth_stencil */ if (dstType == GL_UNSIGNED_INT && depthScale == (GLfloat) 0xffffff && @@ -3960,7 +3940,11 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLuint *zValues = (GLuint *) dest; GLuint i; for (i = 0; i < n; i++) { - zValues[i] = src[i] & 0xffffff00; + GLuint value = src[i]; + if (srcPacking->SwapBytes) { + SWAP4BYTE(value); + } + zValues[i] = value & 0xffffff00; } return; } @@ -3969,19 +3953,27 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, const GLfloat scale = 1.0f / 0xffffff; GLuint i; for (i = 0; i < n; i++) { - depthValues[i] = (src[i] >> 8) * scale; + GLuint value = src[i]; + if (srcPacking->SwapBytes) { + SWAP4BYTE(value); + } + depthValues[i] = (value >> 8) * scale; } } break; case GL_FLOAT: - _mesa_memcpy(depthValues, source, n * sizeof(GLfloat)); - break; + DEPTH_VALUES(GLfloat, 1*); + break; case GL_HALF_FLOAT_ARB: { GLuint i; const GLhalfARB *src = (const GLhalfARB *) source; for (i = 0; i < n; i++) { - depthValues[i] = _mesa_half_to_float(src[i]); + GLhalfARB value = src[i]; + if (srcPacking->SwapBytes) { + SWAP2BYTE(value); + } + depthValues[i] = _mesa_half_to_float(value); } } break; diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index d945a871ae..d97d53e83b 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -452,7 +452,8 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, && !scaleOrBias && !zoom && ctx->Visual.rgbMode - && width <= MAX_WIDTH) { + && width <= MAX_WIDTH + && !unpack->SwapBytes) { /* Special case: directly write 16-bit depth values */ GLint row; for (row = 0; row < height; row++) { @@ -472,7 +473,8 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, && !scaleOrBias && !zoom && ctx->Visual.rgbMode - && width <= MAX_WIDTH) { + && width <= MAX_WIDTH + && !unpack->SwapBytes) { /* Special case: shift 32-bit values down to Visual.depthBits */ const GLint shift = 32 - ctx->DrawBuffer->Visual.depthBits; GLint row; -- cgit v1.2.3 From 441f038748975d4e14ca3da7098045dd1013e531 Mon Sep 17 00:00:00 2001 From: Nicolai Haehnle Date: Sun, 18 Mar 2007 11:02:35 -0600 Subject: fix assertion in read_depth_pixels() --- src/mesa/swrast/s_readpix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index 15dc8106b4..c5524c0630 100644 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@ -119,7 +119,7 @@ read_depth_pixels( GLcontext *ctx, && !biasOrScale && !packing->SwapBytes) { /* Special case: directly read 24-bit unsigned depth values. */ GLint j; - ASSERT(rb->InternalFormat == GL_DEPTH_COMPONENT32); + ASSERT(rb->InternalFormat == GL_DEPTH_COMPONENT24); ASSERT(rb->DataType == GL_UNSIGNED_INT); for (j = 0; j < height; j++, y++) { GLuint *dest = (GLuint *) -- cgit v1.2.3 From 249b451d2068c781d29a6527e152b39d08b1c877 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 21 Mar 2007 09:44:03 -0600 Subject: 1D convolution (and post-conv scale/bias) were inadvertantly applied to 2D image transfers. --- src/mesa/swrast/s_copypix.c | 7 ++++++- src/mesa/swrast/s_drawpix.c | 5 +++++ src/mesa/swrast/s_readpix.c | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index 7e8ebb4477..b318777072 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -199,7 +199,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, GLint sy, dy, stepy, row; const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; GLint overlapping; - const GLuint transferOps = ctx->_ImageTransferState; + GLuint transferOps = ctx->_ImageTransferState; SWspan span; if (!ctx->ReadBuffer->_ColorReadBuffer) { @@ -211,6 +211,11 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, copy_conv_rgba_pixels(ctx, srcx, srcy, width, height, destx, desty); return; } + else if (ctx->Pixel.Convolution1DEnabled) { + /* make sure we don't apply 1D convolution */ + transferOps &= ~(IMAGE_CONVOLUTION_BIT | + IMAGE_POST_CONVOLUTION_SCALE_BIAS); + } /* Determine if copy should be done bottom-to-top or top-to-bottom */ if (srcy < desty) { diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index d97d53e83b..99ad71143e 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -619,6 +619,11 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, type = GL_FLOAT; transferOps &= IMAGE_POST_CONVOLUTION_BITS; } + else if (ctx->Pixel.Convolution1DEnabled) { + /* we only want to apply 1D convolution to glTexImage1D */ + transferOps &= ~(IMAGE_CONVOLUTION_BIT | + IMAGE_POST_CONVOLUTION_SCALE_BIAS); + } if (ctx->DrawBuffer->_NumColorDrawBuffers[0] > 0 && ctx->DrawBuffer->_ColorDrawBuffers[0][0]->DataType != GL_FLOAT && diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index c5524c0630..7dc48aec68 100644 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@ -410,6 +410,10 @@ read_rgba_pixels( GLcontext *ctx, = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height, format, type, 0, 0); + /* make sure we don't apply 1D convolution */ + transferOps &= ~(IMAGE_CONVOLUTION_BIT | + IMAGE_POST_CONVOLUTION_SCALE_BIAS); + for (row = 0; row < height; row++, y++) { /* Get float rgba pixels */ -- cgit v1.2.3