anv/blorp: Use regular blorp clears for subpass clears
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 18 Nov 2016 21:35:42 +0000 (13:35 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 22 Nov 2016 22:24:29 +0000 (14:24 -0800)
At vkCmdNextSubpass time, we have the actual framebuffer so we can use
regular blorp_clear for subpass clears.  For fast clears, there is no
attachment version, so this will make fast clears a bit easier.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
src/intel/vulkan/anv_blorp.c

index 0565f0ca92666d0c376093975dd16ee2fbcff4df..1b5df6d97c50063beb2d9b0da0fe8b8786733893 100644 (file)
@@ -1178,24 +1178,33 @@ anv_cmd_buffer_clear_subpass(struct anv_cmd_buffer *cmd_buffer)
       .layerCount = cmd_buffer->state.framebuffer->layers,
    };
 
+   struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
    for (uint32_t i = 0; i < cmd_state->subpass->color_count; ++i) {
       const uint32_t a = cmd_state->subpass->color_attachments[i];
+      struct anv_attachment_state *att_state = &cmd_state->attachments[a];
 
-      if (!cmd_state->attachments[a].pending_clear_aspects)
+      if (!att_state->pending_clear_aspects)
          continue;
 
-      assert(cmd_state->attachments[a].pending_clear_aspects ==
-             VK_IMAGE_ASPECT_COLOR_BIT);
+      assert(att_state->pending_clear_aspects == VK_IMAGE_ASPECT_COLOR_BIT);
 
-      VkClearAttachment clear_att = {
-         .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
-         .colorAttachment = i, /* Use attachment index relative to subpass */
-         .clearValue = cmd_state->attachments[a].clear_value,
-      };
+      struct anv_image_view *iview = fb->attachments[a];
+      const struct anv_image *image = iview->image;
+      struct blorp_surf surf;
+      get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT,
+                                   att_state->aux_usage, &surf);
+
+      const VkRect2D render_area = cmd_buffer->state.render_area;
 
-      clear_color_attachment(cmd_buffer, &batch, &clear_att, 1, &clear_rect);
+      blorp_clear(&batch, &surf, iview->isl.format, iview->isl.swizzle,
+                  iview->isl.base_level,
+                  iview->isl.base_array_layer, fb->layers,
+                  render_area.offset.x, render_area.offset.y,
+                  render_area.offset.x + render_area.extent.width,
+                  render_area.offset.y + render_area.extent.height,
+                  vk_to_isl_color(att_state->clear_value.color), NULL);
 
-      cmd_state->attachments[a].pending_clear_aspects = 0;
+      att_state->pending_clear_aspects = 0;
    }
 
    const uint32_t ds = cmd_state->subpass->depth_stencil_attachment;