Mesa (main): v3dv: fix merge jobs

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jul 6 06:10:05 UTC 2022


Module: Mesa
Branch: main
Commit: 7dc951374c1a0bd0115e6a1013880863b17da53b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7dc951374c1a0bd0115e6a1013880863b17da53b

Author: Iago Toral Quiroga <itoral at igalia.com>
Date:   Tue Jul  5 09:04:41 2022 +0200

v3dv: fix merge jobs

This only works if the framebuffer config is exactly the same so
testing both subpasses have the same attachments is not enough,
they also need to be exactly in the same order.

Reviewed-by: Alejandro Piñeiro <apinheiro at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17358>

---

 src/broadcom/vulkan/v3dv_cmd_buffer.c | 59 +++++++++--------------------------
 1 file changed, 14 insertions(+), 45 deletions(-)

diff --git a/src/broadcom/vulkan/v3dv_cmd_buffer.c b/src/broadcom/vulkan/v3dv_cmd_buffer.c
index f4e6a9956c7..b57f11531e8 100644
--- a/src/broadcom/vulkan/v3dv_cmd_buffer.c
+++ b/src/broadcom/vulkan/v3dv_cmd_buffer.c
@@ -276,27 +276,6 @@ cmd_buffer_destroy(struct vk_command_buffer *vk_cmd_buffer)
    vk_free(&cmd_buffer->vk.pool->alloc, cmd_buffer);
 }
 
-static bool
-attachment_list_is_subset(struct v3dv_subpass_attachment *l1, uint32_t l1_count,
-                          struct v3dv_subpass_attachment *l2, uint32_t l2_count)
-{
-   for (uint32_t i = 0; i < l1_count; i++) {
-      uint32_t attachment_idx = l1[i].attachment;
-      if (attachment_idx == VK_ATTACHMENT_UNUSED)
-         continue;
-
-      uint32_t j;
-      for (j = 0; j < l2_count; j++) {
-         if (l2[j].attachment == attachment_idx)
-            break;
-      }
-      if (j == l2_count)
-         return false;
-   }
-
-   return true;
- }
-
 static bool
 cmd_buffer_can_merge_subpass(struct v3dv_cmd_buffer *cmd_buffer,
                              uint32_t subpass_idx)
@@ -332,35 +311,25 @@ cmd_buffer_can_merge_subpass(struct v3dv_cmd_buffer *cmd_buffer,
    struct v3dv_subpass *prev_subpass = &state->pass->subpasses[state->subpass_idx];
    struct v3dv_subpass *subpass = &state->pass->subpasses[subpass_idx];
 
-   /* Don't merge if the subpasses have different view masks, since in that
-    * case the framebuffer setup is different and we need to emit different
-    * RCLs.
-    */
-   if (subpass->view_mask != prev_subpass->view_mask)
+   if (subpass->ds_attachment.attachment !=
+       prev_subpass->ds_attachment.attachment)
       return false;
 
-   /* Because the list of subpass attachments can include VK_ATTACHMENT_UNUSED,
-    * we need to check that for each subpass all its used attachments are
-    * used by the other subpass.
-    */
-   bool compatible =
-      attachment_list_is_subset(prev_subpass->color_attachments,
-                                prev_subpass->color_count,
-                                subpass->color_attachments,
-                                subpass->color_count);
-   if (!compatible)
+   if (subpass->color_count != prev_subpass->color_count)
       return false;
 
-   compatible =
-      attachment_list_is_subset(subpass->color_attachments,
-                                subpass->color_count,
-                                prev_subpass->color_attachments,
-                                prev_subpass->color_count);
-   if (!compatible)
-      return false;
+   for (uint32_t i = 0; i < subpass->color_count; i++) {
+      if (subpass->color_attachments[i].attachment !=
+          prev_subpass->color_attachments[i].attachment) {
+         return false;
+      }
+   }
 
-   if (subpass->ds_attachment.attachment !=
-       prev_subpass->ds_attachment.attachment)
+   /* Don't merge if the subpasses have different view masks, since in that
+    * case the framebuffer setup is different and we need to emit different
+    * RCLs.
+    */
+   if (subpass->view_mask != prev_subpass->view_mask)
       return false;
 
    /* FIXME: Since some attachment formats can't be resolved using the TLB we



More information about the mesa-commit mailing list