i965: refactor format munging for separate stencil
authorChris Forbes <chrisf@ijw.co.nz>
Fri, 21 Feb 2014 19:51:41 +0000 (08:51 +1300)
committerChris Forbes <chrisf@ijw.co.nz>
Thu, 10 Apr 2014 06:27:40 +0000 (18:27 +1200)
We will need this for munging the view's format.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/intel_mipmap_tree.c
src/mesa/drivers/dri/i965/intel_mipmap_tree.h

index 1a7a9e836c36b3d56bebc720619e36222cab4bde..9b2e27bc21ca3697e765891f25c009011235e733 100644 (file)
@@ -210,6 +210,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
@@ -368,14 +385,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));
       }
    }
 
index 2565db800e5de2f36d159b065f2a8c7726c03ba1..de682332f3ba597842de7e555a8613adfc26f73e 100644 (file)
@@ -500,6 +500,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,