summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2015-08-13 01:51:37 +0200
committerMarek Olšák <marek.olsak@amd.com>2015-08-14 15:02:28 +0200
commit973988ab8dd4d04b925a5859d1da0801e858a6fe (patch)
treecb0207180a2aec8cb9576e93382e744b85acd1b2 /src/mesa/swrast
parent97f58fb59a45f04c9d03709063a081f572509f51 (diff)
downloadexternal_mesa3d-973988ab8dd4d04b925a5859d1da0801e858a6fe.zip
external_mesa3d-973988ab8dd4d04b925a5859d1da0801e858a6fe.tar.gz
external_mesa3d-973988ab8dd4d04b925a5859d1da0801e858a6fe.tar.bz2
swrast: fix EXT_depth_bounds_test
zMin and zMax can't use _DepthMaxF, because the test is done in Z32_UNORM. Probably a useless patch given how popular swrast is nowadays, but it helped create and validate the piglit test. v2: add an explicit cast to GLuint Reviewed-by: Brian Paul <brianp@vmware.com>
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_depth.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c
index 134f897..ffadc05 100644
--- a/src/mesa/swrast/s_depth.c
+++ b/src/mesa/swrast/s_depth.c
@@ -419,8 +419,8 @@ _swrast_depth_bounds_test( struct gl_context *ctx, SWspan *span )
struct gl_framebuffer *fb = ctx->DrawBuffer;
struct gl_renderbuffer *rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
GLubyte *zStart;
- GLuint zMin = (GLuint) (ctx->Depth.BoundsMin * fb->_DepthMaxF + 0.5F);
- GLuint zMax = (GLuint) (ctx->Depth.BoundsMax * fb->_DepthMaxF + 0.5F);
+ GLuint zMin = (GLuint)((double)ctx->Depth.BoundsMin * 0xffffffff);
+ GLuint zMax = (GLuint)((double)ctx->Depth.BoundsMax * 0xffffffff);
GLubyte *mask = span->array->mask;
const GLuint count = span->end;
GLuint i;
@@ -444,6 +444,16 @@ _swrast_depth_bounds_test( struct gl_context *ctx, SWspan *span )
zBufferVals = (const GLuint *) zStart;
}
else {
+ /* Round the bounds to the precision of the zbuffer. */
+ if (rb->Format == MESA_FORMAT_Z_UNORM16) {
+ zMin = (zMin & 0xffff0000) | (zMin >> 16);
+ zMax = (zMax & 0xffff0000) | (zMax >> 16);
+ } else {
+ /* 24 bits */
+ zMin = (zMin & 0xffffff00) | (zMin >> 24);
+ zMax = (zMax & 0xffffff00) | (zMax >> 24);
+ }
+
/* unpack Z values into a temporary array */
if (span->arrayMask & SPAN_XY) {
get_z32_values(ctx, rb, count, span->array->x, span->array->y,