anv: Allow fast-clearing the first slice of a multi-slice image
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 19 Jan 2018 20:07:12 +0000 (12:07 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 9 Feb 2018 00:35:31 +0000 (16:35 -0800)
Now that we're tracking aux properly per-slice, we can enable this for
applications which actually care.

Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
src/intel/vulkan/anv_blorp.c
src/intel/vulkan/genX_cmd_buffer.c

index fc3b717982fc56ce32e444518d6791dfa021d743..3939173bb1601217ac569aede0134b674b84eb25 100644 (file)
@@ -1206,6 +1206,9 @@ anv_cmd_buffer_clear_subpass(struct anv_cmd_buffer *cmd_buffer)
                                    image, VK_IMAGE_ASPECT_COLOR_BIT,
                                    att_state->aux_usage, &surf);
 
+      uint32_t base_layer = iview->planes[0].isl.base_array_layer;
+      uint32_t layer_count = fb->layers;
+
       if (att_state->fast_clear) {
          surf.clear_color = vk_to_isl_color(att_state->clear_value.color);
 
@@ -1228,29 +1231,33 @@ anv_cmd_buffer_clear_subpass(struct anv_cmd_buffer *cmd_buffer)
          cmd_buffer->state.pending_pipe_bits |=
             ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT | ANV_PIPE_CS_STALL_BIT;
 
+         /* We only support fast-clears on the first layer */
+         assert(iview->planes[0].isl.base_level == 0);
+         assert(iview->planes[0].isl.base_array_layer == 0);
+
          assert(image->n_planes == 1);
-         blorp_fast_clear(&batch, &surf, iview->planes[0].isl.format,
-                          iview->planes[0].isl.base_level,
-                          iview->planes[0].isl.base_array_layer, fb->layers,
+         blorp_fast_clear(&batch, &surf, iview->planes[0].isl.format, 0, 0, 1,
                           render_area.offset.x, render_area.offset.y,
                           render_area.offset.x + render_area.extent.width,
                           render_area.offset.y + render_area.extent.height);
+         base_layer++;
+         layer_count--;
 
          cmd_buffer->state.pending_pipe_bits |=
             ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT | ANV_PIPE_CS_STALL_BIT;
-      } else {
+      }
+
+      if (layer_count > 0) {
          assert(image->n_planes == 1);
          anv_cmd_buffer_mark_image_written(cmd_buffer, image,
                                            VK_IMAGE_ASPECT_COLOR_BIT,
                                            att_state->aux_usage,
                                            iview->planes[0].isl.base_level,
-                                           iview->planes[0].isl.base_array_layer,
-                                           fb->layers);
+                                           base_layer, layer_count);
 
          blorp_clear(&batch, &surf, iview->planes[0].isl.format,
                      anv_swizzle_for_render(iview->planes[0].isl.swizzle),
-                     iview->planes[0].isl.base_level,
-                     iview->planes[0].isl.base_array_layer, fb->layers,
+                     iview->planes[0].isl.base_level, base_layer, layer_count,
                      render_area.offset.x, render_area.offset.y,
                      render_area.offset.x + render_area.extent.width,
                      render_area.offset.y + render_area.extent.height,
index 89654c221e0dd95ca4ff3ef26029b5cf67c31ac4..f42860b411a074545ee74ba92e9c100bd6554f70 100644 (file)
@@ -329,12 +329,16 @@ color_attachment_compute_aux_usage(struct anv_device * device,
        */
       if (att_state->fast_clear &&
           (iview->planes[0].isl.base_level > 0 ||
-           iview->image->extent.depth > 0 ||
-           iview->image->array_size > 0)) {
+           iview->planes[0].isl.base_array_layer > 0)) {
          anv_perf_warn(device->instance, iview->image,
-                       "Rendering to a multi-LOD or multi-layer framebuffer "
-                       "with LOAD_OP_CLEAR.  Not fast-clearing");
+                       "Rendering with multi-lod or multi-layer framebuffer "
+                       "with LOAD_OP_LOAD and baseMipLevel > 0 or "
+                       "baseArrayLayer > 0.  Not fast clearing.");
          att_state->fast_clear = false;
+      } else if (att_state->fast_clear && cmd_state->framebuffer->layers > 1) {
+         anv_perf_warn(device->instance, iview->image,
+                       "Rendering to a multi-layer framebuffer with "
+                       "LOAD_OP_CLEAR.  Only fast-clearing the first slice");
       }
 
       if (att_state->fast_clear) {