anv: Let blorp handle indirect clear colors for CCS resolves
authorJason Ekstrand <jason.ekstrand@intel.com>
Sat, 11 Nov 2017 20:22:45 +0000 (12:22 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 28 Nov 2017 00:22:13 +0000 (16:22 -0800)
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-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 7fc6958f22da6cb9928b074f670beff5f2aaf65c..e244468e03b2e5e929791125f7c8265f38d2f642 100644 (file)
@@ -175,6 +175,15 @@ get_blorp_surf_for_anv_buffer(struct anv_device *device,
 
 #define ANV_AUX_USAGE_DEFAULT ((enum isl_aux_usage)0xff)
 
+static struct blorp_address
+anv_to_blorp_address(struct anv_address addr)
+{
+   return (struct blorp_address) {
+      .buffer = addr.bo,
+      .offset = addr.offset,
+   };
+}
+
 static void
 get_blorp_surf_for_anv_image(const struct anv_device *device,
                              const struct anv_image *image,
@@ -1673,10 +1682,10 @@ anv_gen8_hiz_op_resolve(struct anv_cmd_buffer *cmd_buffer,
 
 void
 anv_ccs_resolve(struct anv_cmd_buffer * const cmd_buffer,
-                const struct anv_state surface_state,
                 const struct anv_image * const image,
                 VkImageAspectFlagBits aspect,
-                const uint8_t level, const uint32_t layer_count,
+                const uint8_t level,
+                const uint32_t start_layer, const uint32_t layer_count,
                 const enum blorp_fast_clear_op op)
 {
    assert(cmd_buffer && image);
@@ -1685,17 +1694,10 @@ anv_ccs_resolve(struct anv_cmd_buffer * const cmd_buffer,
 
    /* The resolved subresource range must have a CCS buffer. */
    assert(level < anv_image_aux_levels(image, aspect));
-   assert(layer_count <= anv_image_aux_layers(image, aspect, level));
+   assert(start_layer + layer_count <=
+          anv_image_aux_layers(image, aspect, level));
    assert(image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV && image->samples == 1);
 
-   /* Create a binding table for this surface state. */
-   uint32_t binding_table;
-   VkResult result =
-      binding_table_for_surface_state(cmd_buffer, surface_state,
-                                      &binding_table);
-   if (result != VK_SUCCESS)
-      return;
-
    struct blorp_batch batch;
    blorp_batch_init(&cmd_buffer->device->blorp, &batch, cmd_buffer,
                     BLORP_BATCH_PREDICATE_ENABLE);
@@ -1704,11 +1706,11 @@ anv_ccs_resolve(struct anv_cmd_buffer * const cmd_buffer,
    get_blorp_surf_for_anv_image(cmd_buffer->device, image, aspect,
                                 fast_clear_aux_usage(image, aspect),
                                 &surf);
+   surf.clear_color_addr = anv_to_blorp_address(
+      anv_image_get_clear_color_addr(cmd_buffer->device, image, aspect, level));
 
-   blorp_ccs_resolve_attachment(&batch, binding_table, &surf, level,
-                                layer_count,
-                                image->planes[plane].surface.isl.format,
-                                op);
+   blorp_ccs_resolve(&batch, &surf, level, start_layer, layer_count,
+                     image->planes[plane].surface.isl.format, op);
 
    blorp_batch_finish(&batch);
 }
index 2c2e0b31bf6d0c58036a90e94941ad7cc9e880d2..ca3644d61e9ed09b0250000084902e71334c8287 100644 (file)
@@ -2535,10 +2535,10 @@ anv_gen8_hiz_op_resolve(struct anv_cmd_buffer *cmd_buffer,
                         enum blorp_hiz_op op);
 void
 anv_ccs_resolve(struct anv_cmd_buffer * const cmd_buffer,
-                const struct anv_state surface_state,
                 const struct anv_image * const image,
                 VkImageAspectFlagBits aspect,
-                const uint8_t level, const uint32_t layer_count,
+                const uint8_t level,
+                const uint32_t start_layer, const uint32_t layer_count,
                 const enum blorp_fast_clear_op op);
 
 void
index cc437ff16b027ee2d3617d4593e352dc9279a898..ab5590d7cee11f487ce2b82514551f1ba0dbac88 100644 (file)
@@ -178,29 +178,6 @@ add_surface_state_reloc(struct anv_cmd_buffer *cmd_buffer,
       anv_batch_set_error(&cmd_buffer->batch, result);
 }
 
-static void
-add_image_relocs(struct anv_cmd_buffer *cmd_buffer,
-                 const struct anv_image *image,
-                 const uint32_t plane,
-                 struct anv_surface_state state)
-{
-   const struct isl_device *isl_dev = &cmd_buffer->device->isl_dev;
-
-   add_surface_state_reloc(cmd_buffer, state.state,
-                           image->planes[plane].bo, state.address);
-
-   if (state.aux_address) {
-      VkResult result =
-         anv_reloc_list_add(&cmd_buffer->surface_relocs,
-                            &cmd_buffer->pool->alloc,
-                            state.state.offset + isl_dev->ss.aux_addr_offset,
-                            image->planes[plane].bo,
-                            state.aux_address);
-      if (result != VK_SUCCESS)
-         anv_batch_set_error(&cmd_buffer->batch, result);
-   }
-}
-
 static void
 add_image_view_relocs(struct anv_cmd_buffer *cmd_buffer,
                       const struct anv_image_view *image_view,
@@ -783,33 +760,7 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
 
       genX(load_needs_resolve_predicate)(cmd_buffer, image, aspect, level);
 
-      enum isl_aux_usage aux_usage =
-         image->planes[plane].aux_usage == ISL_AUX_USAGE_NONE ?
-         ISL_AUX_USAGE_CCS_D : image->planes[plane].aux_usage;
-
-      /* Create a surface state with the right clear color and perform the
-       * resolve.
-       */
-      struct anv_surface_state surface_state;
-      surface_state.state = anv_cmd_buffer_alloc_surface_state(cmd_buffer);
-      anv_image_fill_surface_state(cmd_buffer->device,
-                                   image, VK_IMAGE_ASPECT_COLOR_BIT,
-                                   &(struct isl_view) {
-                                      .format = image->planes[plane].surface.isl.format,
-                                      .swizzle = ISL_SWIZZLE_IDENTITY,
-                                      .base_level = level,
-                                      .levels = 1,
-                                      .base_array_layer = base_layer,
-                                      .array_len = layer_count,
-                                   },
-                                   ISL_SURF_USAGE_RENDER_TARGET_BIT,
-                                   aux_usage, NULL, 0,
-                                   &surface_state, NULL);
-      add_image_relocs(cmd_buffer, image, 0, surface_state);
-      genX(copy_fast_clear_dwords)(cmd_buffer, surface_state.state, image,
-                                   aspect, level, false /* copy to ss */);
-      anv_ccs_resolve(cmd_buffer, surface_state.state, image,
-                      aspect, level, layer_count,
+      anv_ccs_resolve(cmd_buffer, image, aspect, level, base_layer, layer_count,
                       image->planes[plane].aux_usage == ISL_AUX_USAGE_CCS_E ?
                       BLORP_FAST_CLEAR_OP_RESOLVE_PARTIAL :
                       BLORP_FAST_CLEAR_OP_RESOLVE_FULL);