anv: Add TRANSFER_SRC to pass usage not subpass usage
authorJason Ekstrand <jason@jlekstrand.net>
Wed, 25 Mar 2020 05:43:14 +0000 (00:43 -0500)
committerMarge Bot <eric+marge@anholt.net>
Tue, 28 Apr 2020 22:45:39 +0000 (22:45 +0000)
The subpass usage flags are supposed to always be one bit and never
multiple bits.  However, when adding in TRANSFER_SRC usage for resolve
attachments we were adding it to the subpass bits and not the render
pass bits.  This potentially is causing issues where images aren't
getting marked written properly.

Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4393>

src/intel/vulkan/anv_pass.c
src/intel/vulkan/genX_cmd_buffer.c

index 69a66478c565a48fc9c4eeb5b415ac43908e8710..ec32e0ca3bd035118aaa3cde6c709f6ae27afd98 100644 (file)
@@ -86,7 +86,6 @@ anv_render_pass_compile(struct anv_render_pass *pass)
          struct anv_render_pass_attachment *pass_att =
             &pass->attachments[subpass_att->attachment];
 
-         assert(__builtin_popcount(subpass_att->usage) == 1);
          pass_att->usage |= subpass_att->usage;
          pass_att->last_subpass_idx = i;
 
@@ -116,8 +115,13 @@ anv_render_pass_compile(struct anv_render_pass *pass)
 
             subpass->has_color_resolve = true;
 
+            assert(color_att->attachment < pass->attachment_count);
+            struct anv_render_pass_attachment *color_pass_att =
+               &pass->attachments[color_att->attachment];
+
             assert(resolve_att->usage == VK_IMAGE_USAGE_TRANSFER_DST_BIT);
-            color_att->usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
+            assert(color_att->usage == VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
+            color_pass_att->usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
          }
       }
 
@@ -127,9 +131,17 @@ anv_render_pass_compile(struct anv_render_pass *pass)
          UNUSED struct anv_subpass_attachment *resolve_att =
             subpass->ds_resolve_attachment;
 
+         assert(ds_att->attachment < pass->attachment_count);
+         struct anv_render_pass_attachment *ds_pass_att =
+            &pass->attachments[ds_att->attachment];
+
          assert(resolve_att->usage == VK_IMAGE_USAGE_TRANSFER_DST_BIT);
-         ds_att->usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
+         assert(ds_att->usage == VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
+         ds_pass_att->usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
       }
+
+      for (uint32_t j = 0; j < subpass->attachment_count; j++)
+         assert(__builtin_popcount(subpass->attachments[j].usage) == 1);
    }
 
    /* From the Vulkan 1.0.39 spec:
index 3ac514ee777b3937f5fa8fd1dbd8d6d25ad19d0b..28c375cb1b8b01c7edf70e6b53363b0fa686610d 100644 (file)
@@ -5238,6 +5238,7 @@ cmd_buffer_begin_subpass(struct anv_cmd_buffer *cmd_buffer,
          }
       }
 
+      assert(util_bitcount(subpass->attachments[i].usage) == 1);
       if (subpass->attachments[i].usage ==
           VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) {
          /* We assume that if we're starting a subpass, we're going to do some