summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-07-05 09:40:37 -0600
committerBrian <[email protected]>2007-07-05 09:40:37 -0600
commitd62be2652c2ef5f64169234513c44be91f48e6c1 (patch)
tree8a16a8ef7be8b68cfee69310f7569ce7ea9b17cc
parentea53ff80af7d78b98520763df15d979f43bd1777 (diff)
Copy from Mesa master. Includes fixes for bugs 11475 and 11448.
-rw-r--r--src/mesa/main/image.c103
1 files changed, 63 insertions, 40 deletions
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index caaf2816571..e874719e645 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 7.0
+ * Version: 7.1
*
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
@@ -3648,11 +3648,13 @@ _mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n,
* Try simple cases first
*/
if (transferOps == 0 &&
+ !ctx->Pixel.MapStencilFlag &&
srcType == GL_UNSIGNED_BYTE &&
dstType == GL_UNSIGNED_BYTE) {
_mesa_memcpy(dest, source, n * sizeof(GLubyte));
}
else if (transferOps == 0 &&
+ !ctx->Pixel.MapStencilFlag &&
srcType == GL_UNSIGNED_INT &&
dstType == GL_UNSIGNED_INT &&
!srcPacking->SwapBytes) {
@@ -3668,19 +3670,17 @@ _mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n,
extract_uint_indexes(n, indexes, GL_STENCIL_INDEX, srcType, source,
srcPacking);
- if (transferOps) {
- if (transferOps & IMAGE_SHIFT_OFFSET_BIT) {
- /* shift and offset indexes */
- shift_and_offset_ci(ctx, n, indexes);
- }
+ if (transferOps & IMAGE_SHIFT_OFFSET_BIT) {
+ /* shift and offset indexes */
+ shift_and_offset_ci(ctx, n, indexes);
+ }
- if (ctx->Pixel.MapStencilFlag) {
- /* Apply stencil lookup table */
- GLuint mask = ctx->PixelMaps.StoS.Size - 1;
- GLuint i;
- for (i=0;i<n;i++) {
- indexes[i] = ctx->PixelMaps.StoS.Map[ indexes[i] & mask ];
- }
+ if (ctx->Pixel.MapStencilFlag) {
+ /* Apply stencil lookup table */
+ const GLuint mask = ctx->PixelMaps.StoS.Size - 1;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ indexes[i] = ctx->PixelMaps.StoS.Map[ indexes[i] & mask ];
}
}
@@ -3878,7 +3878,7 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n,
SWAP4BYTE(value); \
} \
} \
- depthValues[i] = CLAMP(GLTYPE2FLOAT(value), 0.0F, 1.0F); \
+ depthValues[i] = GLTYPE2FLOAT(value); \
} \
} while (0)
@@ -3889,6 +3889,7 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
const struct gl_pixelstore_attrib *srcPacking )
{
GLfloat depthTemp[MAX_WIDTH], *depthValues;
+ GLboolean needClamp = GL_FALSE;
/* Look for special cases first.
* Not only are these faster, they're less prone to numeric conversion
@@ -3918,7 +3919,7 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
/* XXX may want to add additional cases here someday */
}
- /* general case path */
+ /* general case path follows */
if (dstType == GL_FLOAT) {
depthValues = (GLfloat *) dest;
@@ -3927,29 +3928,31 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
depthValues = depthTemp;
}
- /* XXX we need to obey srcPacking->SwapBytes here!!! */
- (void) srcPacking;
-
- /* convert incoming values to GLfloat */
+ /* Convert incoming values to GLfloat. Some conversions will require
+ * clamping, below.
+ */
switch (srcType) {
case GL_BYTE:
- DEPTH_VALUES(GLbyte, BYTE_TO_FLOAT);
- break;
+ DEPTH_VALUES(GLbyte, BYTE_TO_FLOAT);
+ needClamp = GL_TRUE;
+ break;
case GL_UNSIGNED_BYTE:
- DEPTH_VALUES(GLubyte, UBYTE_TO_FLOAT);
- break;
+ DEPTH_VALUES(GLubyte, UBYTE_TO_FLOAT);
+ break;
case GL_SHORT:
- DEPTH_VALUES(GLshort, SHORT_TO_FLOAT);
- break;
+ DEPTH_VALUES(GLshort, SHORT_TO_FLOAT);
+ needClamp = GL_TRUE;
+ break;
case GL_UNSIGNED_SHORT:
- DEPTH_VALUES(GLushort, USHORT_TO_FLOAT);
- break;
+ DEPTH_VALUES(GLushort, USHORT_TO_FLOAT);
+ break;
case GL_INT:
- DEPTH_VALUES(GLint, INT_TO_FLOAT);
- break;
+ DEPTH_VALUES(GLint, INT_TO_FLOAT);
+ needClamp = GL_TRUE;
+ break;
case GL_UNSIGNED_INT:
- DEPTH_VALUES(GLuint, UINT_TO_FLOAT);
- 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 &&
@@ -3981,19 +3984,21 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
}
break;
case GL_FLOAT:
- DEPTH_VALUES(GLfloat, 1*);
- break;
+ DEPTH_VALUES(GLfloat, 1*);
+ needClamp = GL_TRUE;
+ break;
case GL_HALF_FLOAT_ARB:
{
GLuint i;
const GLhalfARB *src = (const GLhalfARB *) source;
for (i = 0; i < n; i++) {
- GLhalfARB value = src[i];
- if (srcPacking->SwapBytes) {
- SWAP2BYTE(value);
- }
+ GLhalfARB value = src[i];
+ if (srcPacking->SwapBytes) {
+ SWAP2BYTE(value);
+ }
depthValues[i] = _mesa_half_to_float(value);
}
+ needClamp = GL_TRUE;
}
break;
default:
@@ -4001,12 +4006,30 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
return;
}
+ /* apply depth scale and bias */
+ {
+ const GLfloat scale = ctx->Pixel.DepthScale;
+ const GLfloat bias = ctx->Pixel.DepthBias;
+ if (scale != 1.0 || bias != 0.0) {
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ depthValues[i] = depthValues[i] * scale + bias;
+ }
+ needClamp = GL_TRUE;
+ }
+ }
- /* apply depth scale and bias and clamp to [0,1] */
- if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) {
- _mesa_scale_and_bias_depth(ctx, n, depthValues);
+ /* clamp to [0, 1] */
+ if (needClamp) {
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ depthValues[i] = CLAMP(depthValues[i], 0.0, 1.0);
+ }
}
+ /*
+ * Convert values to dstType
+ */
if (dstType == GL_UNSIGNED_INT) {
GLuint *zValues = (GLuint *) dest;
GLuint i;