venus: Fix subpass attachments
authorLina Versace <linyaa@google.com>
Fri, 9 Jun 2023 23:08:04 +0000 (16:08 -0700)
committerLina Versace <linyaa@google.com>
Wed, 18 Oct 2023 19:12:17 +0000 (12:12 -0700)
We must check for VK_ATTACHMENT_UNUSED.

Signed-off-by: Lina Versace <linyaa@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22419>

src/virtio/vulkan/vn_render_pass.c

index f4edce9..4e796e7 100644 (file)
 #define INIT_SUBPASSES(_pass, _pCreateInfo)                                  \
    do {                                                                      \
       for (uint32_t i = 0; i < _pCreateInfo->subpassCount; i++) {            \
-         _pass->subpasses[i].has_color_attachment =                          \
-            (_pCreateInfo->pSubpasses[i].colorAttachmentCount > 0);          \
-         _pass->subpasses[i].has_depth_stencil_attachment =                  \
-            (_pCreateInfo->pSubpasses[i].pDepthStencilAttachment != NULL);   \
+         __auto_type subpass_desc = &_pCreateInfo->pSubpasses[i];            \
+         struct vn_subpass *subpass = &_pass->subpasses[i];                  \
+                                                                             \
+         for (uint32_t j = 0; j < subpass_desc->colorAttachmentCount; j++) { \
+            if (subpass_desc->pColorAttachments[j].attachment !=             \
+                VK_ATTACHMENT_UNUSED) {                                      \
+               subpass->has_color_attachment = true;                         \
+               break;                                                        \
+            }                                                                \
+         }                                                                   \
+                                                                             \
+         if (subpass_desc->pDepthStencilAttachment &&                        \
+             subpass_desc->pDepthStencilAttachment->attachment !=            \
+                VK_ATTACHMENT_UNUSED) {                                      \
+            subpass->has_depth_stencil_attachment = true;                    \
+         }                                                                   \
       }                                                                      \
    } while (false)