One minor nit below.

For 1, 2, 4:
Reviewed-by: Brian Paul <bri...@vmware.com>

On 08/13/2015 02:32 PM, Marek Olšák wrote:
From: Marek Olšák <marek.ol...@amd.com>

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.
---
  src/mesa/swrast/s_depth.c | 14 ++++++++++++--
  1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c
index 134f897..0a03541 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 = (double)ctx->Depth.BoundsMin * 0xffffffff;
+   GLuint zMax = (double)ctx->Depth.BoundsMax * 0xffffffff;

I think a final cast to GLuint is needed to avoid an 'implicit conversion from double to int' warning with some compilers.



     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,


_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to