[Mesa-dev] [PATCH V2 04/22] i965: refactor format munging for separate stencil

Chris Forbes chrisf at ijw.co.nz
Fri Feb 21 12:48:05 PST 2014


We will need this for munging the view's format.

Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 31 ++++++++++++++++++++-------
 src/mesa/drivers/dri/i965/intel_mipmap_tree.h |  3 +++
 2 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index e43c1ff..d0cbbad 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -227,6 +227,23 @@ intel_is_non_msrt_mcs_buffer_supported(struct brw_context *brw,
 
 
 /**
+ * Determine depth format corresponding to a depth+stencil format,
+ * for separate stencil.
+ */
+mesa_format
+intel_depth_format_for_depthstencil_format(mesa_format format) {
+   switch (format) {
+   case MESA_FORMAT_Z24_UNORM_S8_UINT:
+      return MESA_FORMAT_Z24_UNORM_X8_UINT;
+   case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
+      return MESA_FORMAT_Z_FLOAT32;
+   default:
+      return format;
+   }
+}
+
+
+/**
  * @param for_bo Indicates that the caller is
  *        intel_miptree_create_for_bo(). If true, then do not create
  *        \c stencil_mt.
@@ -384,14 +401,12 @@ intel_miptree_create_layout(struct brw_context *brw,
       /* 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_Z24_UNORM_S8_UINT) {
-	 mt->format = MESA_FORMAT_Z24_UNORM_X8_UINT;
-      } else if (mt->format == MESA_FORMAT_Z32_FLOAT_S8X24_UINT) {
-	 mt->format = MESA_FORMAT_Z_FLOAT32;
-	 mt->cpp = 4;
-      } else {
-	 _mesa_problem(NULL, "Unknown format %s in separate stencil mt\n",
-		       _mesa_get_format_name(mt->format));
+      mt->format = intel_depth_format_for_depthstencil_format(mt->format);
+      mt->cpp = 4;
+
+      if (format == mt->format) {
+         _mesa_problem(NULL, "Unknown format %s in separate stencil mt\n",
+                       _mesa_get_format_name(mt->format));
       }
    }
 
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
index 6c45cfd..2ed1941 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
@@ -498,6 +498,9 @@ intel_miptree_create_for_renderbuffer(struct brw_context *brw,
                                       uint32_t height,
                                       uint32_t num_samples);
 
+mesa_format
+intel_depth_format_for_depthstencil_format(mesa_format format);
+
 /** \brief Assert that the level and layer are valid for the miptree. */
 static inline void
 intel_miptree_check_level_layer(struct intel_mipmap_tree *mt,
-- 
1.9.0



More information about the mesa-dev mailing list