[Mesa-dev] [PATCH 14/18] anv/image: Add an aux_usage field for "default" aux

Jason Ekstrand jason at jlekstrand.net
Fri Oct 28 09:17:10 UTC 2016


Initially, the field is set to ISL_AUX_USAGE_NONE so this commit shouldn't
bring any functional changes.  Setting this field to something else will
cause all sampled and storage image views to be created with AUX and blorp
will start trying to respect it so set with care.

Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
---
 src/intel/vulkan/anv_blorp.c       | 50 +++++++++++++++++++++++++-------------
 src/intel/vulkan/anv_image.c       |  5 ++++
 src/intel/vulkan/anv_private.h     |  3 +++
 src/intel/vulkan/genX_cmd_buffer.c |  6 +++--
 4 files changed, 45 insertions(+), 19 deletions(-)

diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
index bf317c7..4cc82ac 100644
--- a/src/intel/vulkan/anv_blorp.c
+++ b/src/intel/vulkan/anv_blorp.c
@@ -154,8 +154,12 @@ get_blorp_surf_for_anv_buffer(struct anv_device *device,
 static void
 get_blorp_surf_for_anv_image(const struct anv_image *image,
                              VkImageAspectFlags aspect,
+                             enum isl_aux_usage aux_usage,
                              struct blorp_surf *blorp_surf)
 {
+   if (aspect == VK_IMAGE_ASPECT_STENCIL_BIT)
+      aux_usage = ISL_AUX_USAGE_NONE;
+
    const struct anv_surface *surface =
       anv_image_get_surface_for_aspect_mask(image, aspect);
 
@@ -166,6 +170,15 @@ get_blorp_surf_for_anv_image(const struct anv_image *image,
          .offset = image->offset + surface->offset,
       },
    };
+
+   if (aux_usage != ISL_AUX_USAGE_NONE) {
+      blorp_surf->aux_surf = &image->aux_surface.isl,
+      blorp_surf->aux_addr = (struct blorp_address) {
+         .buffer = image->bo,
+         .offset = image->offset + image->aux_surface.offset,
+      };
+      blorp_surf->aux_usage = aux_usage;
+   }
 }
 
 void anv_CmdCopyImage(
@@ -217,8 +230,10 @@ void anv_CmdCopyImage(
          VkImageAspectFlagBits aspect = (1 << a);
 
          struct blorp_surf src_surf, dst_surf;
-         get_blorp_surf_for_anv_image(src_image, aspect, &src_surf);
-         get_blorp_surf_for_anv_image(dst_image, aspect, &dst_surf);
+         get_blorp_surf_for_anv_image(src_image, aspect, src_image->aux_usage,
+                                      &src_surf);
+         get_blorp_surf_for_anv_image(dst_image, aspect, dst_image->aux_usage,
+                                      &dst_surf);
 
          for (unsigned i = 0; i < layer_count; i++) {
             blorp_copy(&batch, &src_surf, pRegions[r].srcSubresource.mipLevel,
@@ -266,7 +281,8 @@ copy_buffer_to_image(struct anv_cmd_buffer *cmd_buffer,
    for (unsigned r = 0; r < regionCount; r++) {
       const VkImageAspectFlags aspect = pRegions[r].imageSubresource.aspectMask;
 
-      get_blorp_surf_for_anv_image(anv_image, aspect, &image.surf);
+      get_blorp_surf_for_anv_image(anv_image, aspect, anv_image->aux_usage,
+                                   &image.surf);
       image.offset =
          anv_sanitize_image_offset(anv_image->type, pRegions[r].imageOffset);
       image.level = pRegions[r].imageSubresource.mipLevel;
@@ -410,8 +426,10 @@ void anv_CmdBlitImage(
       const VkImageSubresourceLayers *src_res = &pRegions[r].srcSubresource;
       const VkImageSubresourceLayers *dst_res = &pRegions[r].dstSubresource;
 
-      get_blorp_surf_for_anv_image(src_image, src_res->aspectMask, &src);
-      get_blorp_surf_for_anv_image(dst_image, dst_res->aspectMask, &dst);
+      get_blorp_surf_for_anv_image(src_image, src_res->aspectMask,
+                                   src_image->aux_usage, &src);
+      get_blorp_surf_for_anv_image(dst_image, dst_res->aspectMask,
+                                   dst_image->aux_usage, &dst);
 
       struct anv_format src_format =
          anv_get_format(&cmd_buffer->device->info, src_image->vk_format,
@@ -773,7 +791,8 @@ void anv_CmdClearColorImage(
    memcpy(clear_color.u32, pColor->uint32, sizeof(pColor->uint32));
 
    struct blorp_surf surf;
-   get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT, &surf);
+   get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT,
+                                image->aux_usage, &surf);
 
    for (unsigned r = 0; r < rangeCount; r++) {
       if (pRanges[r].aspectMask == 0)
@@ -826,14 +845,14 @@ void anv_CmdClearDepthStencilImage(
    struct blorp_surf depth, stencil;
    if (image->aspects & VK_IMAGE_ASPECT_DEPTH_BIT) {
       get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_DEPTH_BIT,
-                                   &depth);
+                                   image->aux_usage, &depth);
    } else {
       memset(&depth, 0, sizeof(depth));
    }
 
    if (image->aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
       get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_STENCIL_BIT,
-                                   &stencil);
+                                   ISL_AUX_USAGE_NONE, &stencil);
    } else {
       memset(&stencil, 0, sizeof(stencil));
    }
@@ -1125,8 +1144,10 @@ resolve_image(struct blorp_batch *batch,
       VkImageAspectFlagBits aspect = 1 << a;
 
       struct blorp_surf src_surf, dst_surf;
-      get_blorp_surf_for_anv_image(src_image, aspect, &src_surf);
-      get_blorp_surf_for_anv_image(dst_image, aspect, &dst_surf);
+      get_blorp_surf_for_anv_image(src_image, aspect,
+                                   src_image->aux_usage, &src_surf);
+      get_blorp_surf_for_anv_image(dst_image, aspect,
+                                   dst_image->aux_usage, &dst_surf);
 
       blorp_blit(batch,
                  &src_surf, src_level, src_layer,
@@ -1218,13 +1239,8 @@ ccs_resolve_attachment(struct anv_cmd_buffer *cmd_buffer,
    assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
 
    struct blorp_surf surf;
-   get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT, &surf);
-   surf.aux_surf = &image->aux_surface.isl;
-   surf.aux_addr = (struct blorp_address) {
-      .buffer = image->bo,
-      .offset = image->offset + image->aux_surface.offset,
-   };
-   surf.aux_usage = att_state->aux_usage;
+   get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT,
+                                att_state->aux_usage, &surf);
 
    for (uint32_t layer = 0; layer < fb->layers; layer++) {
       blorp_ccs_resolve(batch, &surf,
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 4bef5ce..ba7c54f 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -242,6 +242,7 @@ anv_image_create(VkDevice _device,
    image->samples = pCreateInfo->samples;
    image->usage = pCreateInfo->usage;
    image->tiling = pCreateInfo->tiling;
+   image->aux_usage = ISL_AUX_USAGE_NONE;
 
    uint32_t b;
    for_each_bit(b, image->aspects) {
@@ -503,6 +504,8 @@ anv_CreateImageView(VkDevice _device,
                           iview->sampler_surface_state.map,
                           .surf = &surface->isl,
                           .view = &view,
+                          .aux_surf = &image->aux_surface.isl,
+                          .aux_usage = image->aux_usage,
                           .mocs = device->default_mocs);
 
       if (!device->info.has_llc)
@@ -525,6 +528,8 @@ anv_CreateImageView(VkDevice _device,
                              iview->storage_surface_state.map,
                              .surf = &surface->isl,
                              .view = &view,
+                             .aux_surf = &image->aux_surface.isl,
+                             .aux_usage = image->aux_usage,
                              .mocs = device->default_mocs);
       } else {
          anv_fill_buffer_surface_state(device, iview->storage_surface_state,
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 6e8f5e0..b562169 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1533,6 +1533,9 @@ struct anv_image {
       };
    };
 
+   /** The aux usage for this surface when outside a render pass */
+   enum isl_aux_usage aux_usage;
+
    struct anv_surface aux_surface;
 };
 
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index 3b9f946..717fc7a 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -957,14 +957,16 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
          surface_state = desc->image_view->sampler_surface_state;
          assert(surface_state.alloc_size);
          add_image_view_relocs(cmd_buffer, desc->image_view,
-                               ISL_AUX_USAGE_NONE, surface_state);
+                               desc->image_view->image->aux_usage,
+                               surface_state);
          break;
 
       case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: {
          surface_state = desc->image_view->storage_surface_state;
          assert(surface_state.alloc_size);
          add_image_view_relocs(cmd_buffer, desc->image_view,
-                               ISL_AUX_USAGE_NONE, surface_state);
+                               desc->image_view->image->aux_usage,
+                               surface_state);
 
          struct brw_image_param *image_param =
             &cmd_buffer->state.push_constants[stage]->images[image++];
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list