Module: Mesa Branch: main Commit: 0369fdbe94efcbcc6a21c5b692e06d90c24d9e7f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0369fdbe94efcbcc6a21c5b692e06d90c24d9e7f
Author: Chad Versace <[email protected]> Date: Mon Jul 25 13:09:16 2022 -0700 venus: Track subpass properties Needed to fix the ignore rules for VkGraphicsPipelineCreateInfo::pColorBlendState and ::pDepthStencilState. Signed-off-by: Chad Versace <[email protected]> Reviewed-by: Yiwei Zhang <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16681> --- src/virtio/vulkan/vn_render_pass.c | 28 ++++++++++++++++++++++++---- src/virtio/vulkan/vn_render_pass.h | 8 ++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/virtio/vulkan/vn_render_pass.c b/src/virtio/vulkan/vn_render_pass.c index f8bdf89ea3a..2084c38a02a 100644 --- a/src/virtio/vulkan/vn_render_pass.c +++ b/src/virtio/vulkan/vn_render_pass.c @@ -50,6 +50,16 @@ } \ } while (false) +#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); \ + } \ + } while (false) + static void vn_render_pass_count_present_src(const VkRenderPassCreateInfo *create_info, uint32_t *initial_count, @@ -117,16 +127,19 @@ static struct vn_render_pass * vn_render_pass_create(struct vn_device *dev, uint32_t present_acquire_count, uint32_t present_release_count, + uint32_t subpass_count, const VkAllocationCallbacks *alloc) { uint32_t present_count = present_acquire_count + present_release_count; struct vn_render_pass *pass; struct vn_present_src_attachment *present_atts; + struct vn_subpass *subpasses; VK_MULTIALLOC(ma); vk_multialloc_add(&ma, &pass, __typeof__(*pass), 1); vk_multialloc_add(&ma, &present_atts, __typeof__(*present_atts), present_count); + vk_multialloc_add(&ma, &subpasses, __typeof__(*subpasses), subpass_count); if (!vk_multialloc_zalloc(&ma, alloc, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT)) return NULL; @@ -136,6 +149,7 @@ vn_render_pass_create(struct vn_device *dev, pass->present_count = present_count; pass->present_acquire_count = present_acquire_count; pass->present_release_count = present_release_count; + pass->subpass_count = subpass_count; /* For each array pointer, set it only if its count != 0. This allows code * elsewhere to intuitively use either condition, `foo_atts == NULL` or @@ -148,6 +162,8 @@ vn_render_pass_create(struct vn_device *dev, if (present_release_count) pass->present_release_attachments = present_atts + present_acquire_count; + if (subpass_count) + pass->subpasses = subpasses; return pass; } @@ -169,11 +185,13 @@ vn_CreateRenderPass(VkDevice device, vn_render_pass_count_present_src(pCreateInfo, &acquire_count, &release_count); - struct vn_render_pass *pass = - vn_render_pass_create(dev, acquire_count, release_count, alloc); + struct vn_render_pass *pass = vn_render_pass_create( + dev, acquire_count, release_count, pCreateInfo->subpassCount, alloc); if (!pass) return vn_error(dev->instance, VK_ERROR_OUT_OF_HOST_MEMORY); + INIT_SUBPASSES(pass, pCreateInfo); + VkRenderPassCreateInfo local_pass_info; if (pass->present_count) { VkAttachmentDescription *temp_atts = @@ -219,11 +237,13 @@ vn_CreateRenderPass2(VkDevice device, vn_render_pass_count_present_src2(pCreateInfo, &acquire_count, &release_count); - struct vn_render_pass *pass = - vn_render_pass_create(dev, acquire_count, release_count, alloc); + struct vn_render_pass *pass = vn_render_pass_create( + dev, acquire_count, release_count, pCreateInfo->subpassCount, alloc); if (!pass) return vn_error(dev->instance, VK_ERROR_OUT_OF_HOST_MEMORY); + INIT_SUBPASSES(pass, pCreateInfo); + VkRenderPassCreateInfo2 local_pass_info; if (pass->present_count) { VkAttachmentDescription2 *temp_atts = diff --git a/src/virtio/vulkan/vn_render_pass.h b/src/virtio/vulkan/vn_render_pass.h index 5fa9a1ae8d8..9ae77155979 100644 --- a/src/virtio/vulkan/vn_render_pass.h +++ b/src/virtio/vulkan/vn_render_pass.h @@ -23,6 +23,11 @@ struct vn_present_src_attachment { VkAccessFlags dst_access_mask; }; +struct vn_subpass { + bool has_color_attachment; + bool has_depth_stencil_attachment; +}; + struct vn_render_pass { struct vn_object_base base; @@ -31,6 +36,7 @@ struct vn_render_pass { uint32_t present_count; uint32_t present_acquire_count; uint32_t present_release_count; + uint32_t subpass_count; /* Attachments where initialLayout or finalLayout was * VK_IMAGE_LAYOUT_PRESENT_SRC_KHR. @@ -46,6 +52,8 @@ struct vn_render_pass { * VK_IMAGE_LAYOUT_PRESENT_SRC_KHR. */ struct vn_present_src_attachment *present_release_attachments; + + struct vn_subpass *subpasses; }; VK_DEFINE_NONDISP_HANDLE_CASTS(vn_render_pass,
