[Mesa-dev] [PATCH 3/8] i965: Properly demote the depth mt format for fake packed depth/stencil.

Eric Anholt eric at anholt.net
Thu Dec 15 20:43:39 PST 2011


gen7 only supports the non-packed formats, even if you associate a
real separate stencil buffer -- otherwise it's as if the depth test
always fails.

This requires a little bit of care in the match_texture_image case,
since the miptree doesn't track the effective format of a mapping
(with S8 merged in).
---
 src/mesa/drivers/dri/i965/gen7_misc_state.c    |    1 +
 src/mesa/drivers/dri/intel/intel_fbo.c         |    3 ++-
 src/mesa/drivers/dri/intel/intel_mipmap_tree.c |   16 +++++++++++++++-
 src/mesa/drivers/dri/intel/intel_mipmap_tree.h |    2 +-
 4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/gen7_misc_state.c b/src/mesa/drivers/dri/i965/gen7_misc_state.c
index 3946cb3..89a4e71 100644
--- a/src/mesa/drivers/dri/i965/gen7_misc_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_misc_state.c
@@ -53,6 +53,7 @@ static void emit_depthbuffer(struct brw_context *brw)
 
    /* Gen7 doesn't support packed depth/stencil */
    assert(stencil_mt == NULL || depth_mt != stencil_mt);
+   assert(!depth_mt || !_mesa_is_format_packed_depth_stencil(depth_mt->format));
 
    intel_emit_depth_stall_flushes(intel);
 
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index 6f518ee..1711803 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -279,7 +279,8 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer
 	 return false;
       }
 
-      assert(irb->mt->format == MESA_FORMAT_S8_Z24);
+      assert(irb->mt->format == MESA_FORMAT_S8_Z24 ||
+	     irb->mt->format == MESA_FORMAT_X8_Z24);
       ok = intel_renderbuffer_update_wrapper(intel, depth_irb, irb->mt,
 					     0, 0, /* level, layer */
 					     MESA_FORMAT_X8_Z24,
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 989038e..ee2d1e0 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -136,6 +136,16 @@ intel_miptree_create_internal(struct intel_context *intel,
 	 intel_miptree_release(&mt);
 	 return NULL;
       }
+
+      /* Fix up the Z miptree format for how we're splitting out separate
+       * stencil.  Gen7 expects there to be no stencil bits in its depth buffer.
+       */
+      if (mt->format == MESA_FORMAT_S8_Z24) {
+	 mt->format = MESA_FORMAT_X8_Z24;
+      } else {
+	 _mesa_problem("Unknown format %s in separate stencil\n",
+		       _mesa_get_format_name(mt->format));
+      }
    }
 
    return mt;
@@ -320,8 +330,12 @@ intel_miptree_match_image(struct intel_mipmap_tree *mt,
    GLuint level = intelImage->base.Base.Level;
    int width, height, depth;
 
-   if (image->TexFormat != mt->format)
+   if (image->TexFormat != mt->format &&
+       !(image->TexFormat == MESA_FORMAT_S8_Z24 &&
+	 mt->format == MESA_FORMAT_X8_Z24 &&
+	 mt->stencil_mt)) {
       return false;
+   }
 
    intel_miptree_get_dimensions_for_image(image, &width, &height, &depth);
 
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
index fef1dcf..9082864 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
@@ -149,7 +149,7 @@ struct intel_mipmap_tree
     * two miptrees for storing the data.  If the depthstencil texture or rb is
     * MESA_FORMAT_Z32_FLOAT_X24S8, then mt->format will be
     * MESA_FORMAT_Z32_FLOAT, otherwise for MESA_FORMAT_S8_Z24 objects it will be
-    * MESA_FORMAT_S8_Z24.
+    * MESA_FORMAT_X8_Z24.
     */
    gl_format format;
 
-- 
1.7.7.3



More information about the mesa-dev mailing list