diff options
author | Brian <[email protected]> | 2007-04-19 11:23:26 -0600 |
---|---|---|
committer | Brian <[email protected]> | 2007-04-19 11:23:26 -0600 |
commit | 6bde08815fae2a5ba95e0446d8c73040d1f321bc (patch) | |
tree | 1f07eae60b4c9e3daaa072f88120b45e158eec15 /src/mesa/main/image.c | |
parent | 8e6207396c6314d07614c80670f4e3196e3a8551 (diff) |
In _mesa_unpack_depth_span() look for special cases of GLuint->GLushort and GLushort->GLuint conversion.
This improves performance and avoids int/float/int conversion problems that
can introduce errors during glCopyTexImage(). Another fix for the depth peeling
algorithm.
Diffstat (limited to 'src/mesa/main/image.c')
-rw-r--r-- | src/mesa/main/image.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 394a7c65cdf..dcd7f10b26e 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -3893,6 +3893,36 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, { GLfloat depthTemp[MAX_WIDTH], *depthValues; + /* Look for special cases first. + * Not only are these faster, they're less prone to numeric conversion + * problems. Otherwise, converting from an int type to a float then + * back to an int type can introduce errors that will show up as + * artifacts in things like depth peeling which uses glCopyTexImage. + */ + if (ctx->Pixel.DepthScale == 1.0 && ctx->Pixel.DepthBias == 0.0) { + if (srcType == GL_UNSIGNED_INT && dstType == GL_UNSIGNED_SHORT) { + const GLuint *src = (const GLuint *) source; + GLushort *dst = (GLushort *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = src[i] >> 16; + } + return; + } + if (srcType == GL_UNSIGNED_SHORT && dstType == GL_UNSIGNED_INT) { + const GLushort *src = (const GLushort *) source; + GLuint *dst = (GLuint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = src[i] | (src[i] << 16); + } + return; + } + /* XXX may want to add additional cases here someday */ + } + + /* general case path */ + if (dstType == GL_FLOAT) { depthValues = (GLfloat *) dest; } @@ -3903,6 +3933,7 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, /* XXX we need to obey srcPacking->SwapBytes here!!! */ (void) srcPacking; + /* convert incoming values to GLfloat */ switch (srcType) { case GL_BYTE: DEPTH_VALUES(GLbyte, BYTE_TO_FLOAT); |