Mesa (staging/22.1): anv: Stop compacting surface state tables

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jul 14 18:27:50 UTC 2022


Module: Mesa
Branch: staging/22.1
Commit: cc8a8ebfe970a073573868f445ab38267d67ea59
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cc8a8ebfe970a073573868f445ab38267d67ea59

Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date:   Mon Jun 13 16:13:07 2022 -0500

anv: Stop compacting surface state tables

Instead of trying to compact the surface state table to get rid of any
unused render targets, emit MAX(1, colorAttachmentCount) surface states
always.  This ensures that secondaries will always match with primaries
when we go to do the copy since there's no rule requiring the secondary
to have VK_FORMAT_UNDEFINED when the primary has a NULL image view.

Fixes: 3501a3f9ed92 ("anv: Convert to 100% dynamic rendering")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17013>

---

 src/intel/vulkan/genX_cmd_buffer.c | 56 ++++++++++++++------------------------
 1 file changed, 21 insertions(+), 35 deletions(-)

diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index 491af7c3adf..6285fcf03aa 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -1548,13 +1548,12 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
 
 static MUST_CHECK VkResult
 anv_cmd_buffer_init_attachments(struct anv_cmd_buffer *cmd_buffer,
-                                uint32_t color_att_count,
-                                uint32_t color_att_valid)
+                                uint32_t color_att_count)
 {
    struct anv_cmd_graphics_state *gfx = &cmd_buffer->state.gfx;
 
    /* Reserve one for the NULL state. */
-   unsigned num_states = 1 + util_bitcount(color_att_valid);
+   unsigned num_states = 1 + color_att_count;
    const struct isl_device *isl_dev = &cmd_buffer->device->isl_dev;
    const uint32_t ss_stride = align_u32(isl_dev->ss.size, isl_dev->ss.align);
    gfx->att_states =
@@ -1574,17 +1573,11 @@ anv_cmd_buffer_init_attachments(struct anv_cmd_buffer *cmd_buffer,
 
    gfx->color_att_count = color_att_count;
    for (uint32_t i = 0; i < color_att_count; i++) {
-      if (color_att_valid & BITFIELD_BIT(i)) {
-         gfx->color_att[i] = (struct anv_attachment) {
-            .surface_state.state = next_state,
-         };
-         next_state.offset += ss_stride;
-         next_state.map += ss_stride;
-      } else {
-         gfx->color_att[i] = (struct anv_attachment) {
-            .surface_state.state = gfx->null_surface_state,
-         };
-      }
+      gfx->color_att[i] = (struct anv_attachment) {
+         .surface_state.state = next_state,
+      };
+      next_state.offset += ss_stride;
+      next_state.map += ss_stride;
    }
    gfx->depth_att = (struct anv_attachment) { };
    gfx->stencil_att = (struct anv_attachment) { };
@@ -1701,16 +1694,8 @@ genX(BeginCommandBuffer)(
       gfx->depth_att = (struct anv_attachment) { };
       gfx->stencil_att = (struct anv_attachment) { };
 
-      uint32_t color_att_valid = 0;
-      uint32_t color_att_count = inheritance_info->colorAttachmentCount;
-      for (uint32_t i = 0; i < color_att_count; i++) {
-         VkFormat format = inheritance_info->pColorAttachmentFormats[i];
-         if (format != VK_FORMAT_UNDEFINED)
-            color_att_valid |= BITFIELD_BIT(i);
-      }
-      result = anv_cmd_buffer_init_attachments(cmd_buffer,
-                                               color_att_count,
-                                               color_att_valid);
+      const uint32_t color_att_count = inheritance_info->colorAttachmentCount;
+      result = anv_cmd_buffer_init_attachments(cmd_buffer, color_att_count);
       if (result != VK_SUCCESS)
          return result;
 
@@ -6527,23 +6512,15 @@ void genX(CmdBeginRendering)(
       .d = layers,
    };
 
-   /* Reserve one for the NULL state. */
-   uint32_t color_att_valid = 0;
-   uint32_t color_att_count = pRenderingInfo->colorAttachmentCount;
-   for (uint32_t i = 0; i < pRenderingInfo->colorAttachmentCount; i++) {
-      if (pRenderingInfo->pColorAttachments[i].imageView != VK_NULL_HANDLE)
-         color_att_valid |= BITFIELD_BIT(i);
-   }
-   result = anv_cmd_buffer_init_attachments(cmd_buffer,
-                                            color_att_count,
-                                            color_att_valid);
+   const uint32_t color_att_count = pRenderingInfo->colorAttachmentCount;
+   result = anv_cmd_buffer_init_attachments(cmd_buffer, color_att_count);
    if (result != VK_SUCCESS)
       return;
 
    genX(flush_pipeline_select_3d)(cmd_buffer);
 
    for (uint32_t i = 0; i < gfx->color_att_count; i++) {
-      if (!(color_att_valid & BITFIELD_BIT(i)))
+      if (pRenderingInfo->pColorAttachments[i].imageView == VK_NULL_HANDLE)
          continue;
 
       const VkRenderingAttachmentInfo *att =
@@ -6950,6 +6927,15 @@ void genX(CmdBeginRendering)(
                        gfx->null_surface_state.map,
                        .size = fb_size);
 
+   for (uint32_t i = 0; i < gfx->color_att_count; i++) {
+      if (pRenderingInfo->pColorAttachments[i].imageView != VK_NULL_HANDLE)
+         continue;
+
+      isl_null_fill_state(&cmd_buffer->device->isl_dev,
+                          gfx->color_att[i].surface_state.state.map,
+                          .size = fb_size);
+   }
+
    /****** We can now start emitting code to begin the render pass ******/
 
    gfx->dirty |= ANV_CMD_DIRTY_RENDER_TARGETS;



More information about the mesa-commit mailing list