anv/cmd_buffer: Add support for MCS fast-clears and resolves
authorJason Ekstrand <jason.ekstrand@intel.com>
Sat, 24 Feb 2018 05:12:35 +0000 (21:12 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 1 Mar 2018 22:07:58 +0000 (14:07 -0800)
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
src/intel/vulkan/genX_cmd_buffer.c

index 47542ea4ac0e8c0a669d20d557838348acf785ff..98e58cadba973752890c684dd941d0668b5d7d99 100644 (file)
@@ -754,6 +754,29 @@ anv_cmd_predicated_ccs_resolve(struct anv_cmd_buffer *cmd_buffer,
                     array_layer, 1, resolve_op, true);
 }
 
+static void
+anv_cmd_predicated_mcs_resolve(struct anv_cmd_buffer *cmd_buffer,
+                               const struct anv_image *image,
+                               VkImageAspectFlagBits aspect,
+                               uint32_t array_layer,
+                               enum isl_aux_op resolve_op,
+                               enum anv_fast_clear_type fast_clear_supported)
+{
+   assert(aspect == VK_IMAGE_ASPECT_COLOR_BIT);
+   assert(resolve_op == ISL_AUX_OP_PARTIAL_RESOLVE);
+
+#if GEN_GEN >= 8 || GEN_IS_HASWELL
+   anv_cmd_compute_resolve_predicate(cmd_buffer, image,
+                                     aspect, 0, array_layer,
+                                     resolve_op, fast_clear_supported);
+
+   anv_image_mcs_op(cmd_buffer, image, aspect,
+                    array_layer, 1, resolve_op, true);
+#else
+   unreachable("MCS resolves are unsupported on Ivybridge and Bay Trail");
+#endif
+}
+
 void
 genX(cmd_buffer_mark_image_written)(struct anv_cmd_buffer *cmd_buffer,
                                     const struct anv_image *image,
@@ -1096,9 +1119,15 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
 
       for (uint32_t a = 0; a < level_layer_count; a++) {
          uint32_t array_layer = base_layer + a;
-         anv_cmd_predicated_ccs_resolve(cmd_buffer, image, aspect,
-                                        level, array_layer, resolve_op,
-                                        final_fast_clear);
+         if (image->samples == 1) {
+            anv_cmd_predicated_ccs_resolve(cmd_buffer, image, aspect,
+                                           level, array_layer, resolve_op,
+                                           final_fast_clear);
+         } else {
+            anv_cmd_predicated_mcs_resolve(cmd_buffer, image, aspect,
+                                           array_layer, resolve_op,
+                                           final_fast_clear);
+         }
       }
    }
 
@@ -3448,8 +3477,13 @@ cmd_buffer_begin_subpass(struct anv_cmd_buffer *cmd_buffer,
             assert(iview->planes[0].isl.base_level == 0);
             assert(iview->planes[0].isl.base_array_layer == 0);
 
-            anv_image_ccs_op(cmd_buffer, image, VK_IMAGE_ASPECT_COLOR_BIT,
-                             0, 0, 1, ISL_AUX_OP_FAST_CLEAR, false);
+            if (iview->image->samples == 1) {
+               anv_image_ccs_op(cmd_buffer, image, VK_IMAGE_ASPECT_COLOR_BIT,
+                                0, 0, 1, ISL_AUX_OP_FAST_CLEAR, false);
+            } else {
+               anv_image_mcs_op(cmd_buffer, image, VK_IMAGE_ASPECT_COLOR_BIT,
+                                0, 1, ISL_AUX_OP_FAST_CLEAR, false);
+            }
             base_clear_layer++;
             clear_layer_count--;