[Mesa-dev] [PATCH] i965: verify depth render buffer depth when in fast clear WIP

Tapani Pälli tapani.palli at intel.com
Wed May 8 02:49:15 PDT 2013


Patch makes sure in conservative way that the depth_clear_value
is correct and represents max depth of current depth buffer.

This fixes the case where user has 16bit color buffer but 24bit
depth buffer and 'fb->_DepthMax' has a wrong value. I'm currently
investigating how to get _DepthMax corrected on mesa side, but
meanwhile this patch will enable correct rendering results for
16bit benchmarks instead of displaying only white color on the
screen. This bug does not happen with user created framebuffers,
only with window system ones.

Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
---
 src/mesa/drivers/dri/i965/brw_clear.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_clear.c b/src/mesa/drivers/dri/i965/brw_clear.c
index 2b999bf..28dd872 100644
--- a/src/mesa/drivers/dri/i965/brw_clear.c
+++ b/src/mesa/drivers/dri/i965/brw_clear.c
@@ -129,6 +129,9 @@ brw_fast_clear_depth(struct gl_context *ctx)
    }
 
    uint32_t depth_clear_value;
+   struct gl_renderbuffer *depth_rb =
+      ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+   uint32_t depth_bits = _mesa_get_format_bits(depth_rb->Format, GL_DEPTH_BITS);
    switch (mt->format) {
    case MESA_FORMAT_Z32_FLOAT_X24S8:
    case MESA_FORMAT_S8_Z24:
@@ -161,7 +164,7 @@ brw_fast_clear_depth(struct gl_context *ctx)
       /* FALLTHROUGH */
 
    default:
-      depth_clear_value = fb->_DepthMax * ctx->Depth.Clear;
+      depth_clear_value = ((1 << depth_bits) - 1) * ctx->Depth.Clear;
       break;
    }
 
-- 
1.8.1.4



More information about the mesa-dev mailing list