anv: Transition MCS buffers from the undefined layout
authorNanley Chery <nanley.g.chery@intel.com>
Tue, 11 Jul 2017 17:46:58 +0000 (10:46 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sun, 23 Jul 2017 03:12:09 +0000 (20:12 -0700)
v2: Define MCS buffers with any sample count (Jason)

Cc: <mesa-stable@lists.freedesktop.org>
Suggested-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Nanley Chery <nanley.g.chery@intel.com>
src/intel/vulkan/anv_blorp.c
src/intel/vulkan/anv_private.h
src/intel/vulkan/genX_cmd_buffer.c

index eca7a7e9dbc576ba3e1c5783217ce750b8f106ec..232bee4bb535482677357323de1eaeffe84c8cc1 100644 (file)
@@ -1436,10 +1436,10 @@ void anv_CmdResolveImage(
 }
 
 void
-anv_image_ccs_clear(struct anv_cmd_buffer *cmd_buffer,
-                    const struct anv_image *image,
-                    const uint32_t base_level, const uint32_t level_count,
-                    const uint32_t base_layer, uint32_t layer_count)
+anv_image_fast_clear(struct anv_cmd_buffer *cmd_buffer,
+                     const struct anv_image *image,
+                     const uint32_t base_level, const uint32_t level_count,
+                     const uint32_t base_layer, uint32_t layer_count)
 {
    assert(image->type == VK_IMAGE_TYPE_3D || image->extent.depth == 1);
 
index 4dce360c76eb49d82addcfbfcb56b97a523c9c39..9a5d2d6fa49cf51e6de01041e6ac4006cd5ba428 100644 (file)
@@ -2108,10 +2108,10 @@ anv_ccs_resolve(struct anv_cmd_buffer * const cmd_buffer,
                 const enum blorp_fast_clear_op op);
 
 void
-anv_image_ccs_clear(struct anv_cmd_buffer *cmd_buffer,
-                    const struct anv_image *image,
-                    const uint32_t base_level, const uint32_t level_count,
-                    const uint32_t base_layer, uint32_t layer_count);
+anv_image_fast_clear(struct anv_cmd_buffer *cmd_buffer,
+                     const struct anv_image *image,
+                     const uint32_t base_level, const uint32_t level_count,
+                     const uint32_t base_layer, uint32_t layer_count);
 
 enum isl_aux_usage
 anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
index 9b3bb101645cf957c8f9b27225fea1868b0a3b78..963634f55e3a4ba9ec187c8ed27d2e61fea920df 100644 (file)
@@ -392,7 +392,9 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
                         VkImageLayout initial_layout,
                         VkImageLayout final_layout)
 {
-   if (image->aux_usage != ISL_AUX_USAGE_CCS_E)
+   assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
+
+   if (image->aux_usage == ISL_AUX_USAGE_NONE)
       return;
 
    if (initial_layout != VK_IMAGE_LAYOUT_UNDEFINED &&
@@ -405,15 +407,30 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
       layer_count = anv_minify(image->extent.depth, base_level);
    }
 
-#if GEN_GEN >= 9
-   /* We're transitioning from an undefined layout so it doesn't really matter
-    * what data ends up in the color buffer.  We do, however, need to ensure
-    * that the CCS has valid data in it.  One easy way to do that is to
-    * fast-clear the specified range.
-    */
-   anv_image_ccs_clear(cmd_buffer, image, base_level, level_count,
-                       base_layer, layer_count);
-#endif
+   if (image->aux_usage == ISL_AUX_USAGE_CCS_E ||
+       image->aux_usage == ISL_AUX_USAGE_MCS) {
+      /* We're transitioning from an undefined layout so it doesn't really
+       * matter what data ends up in the color buffer. We do, however, need to
+       * ensure that the auxiliary surface is not in an undefined state. This
+       * state is possible for CCS buffers SKL+ and MCS buffers with certain
+       * sample counts that require certain bits to be reserved (2x and 8x).
+       * One easy way to get to a valid state is to fast-clear the specified
+       * range.
+       *
+       * Even for MCS buffers that have sample counts that don't require
+       * certain bits to be reserved (4x and 8x), we're unsure if the hardware
+       * will be okay with the sample mappings given by the undefined buffer.
+       * We don't have any data to show that this is a problem, but we want to
+       * avoid causing difficult-to-debug problems.
+       */
+      if (image->samples == 4 || image->samples == 16) {
+         anv_perf_warn("Doing a potentially unnecessary fast-clear to define "
+                       "an MCS buffer.");
+      }
+
+      anv_image_fast_clear(cmd_buffer, image, base_level, level_count,
+                           base_layer, layer_count);
+   }
 }
 
 /**