From c626be82f469fd5aa72417d5d33b21a3d048abdb Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Wed, 4 Sep 2024 12:17:34 -0500 Subject: [PATCH] vulkan: Add a helper for getting VkRenderingAttachmentLocaiontInfoKHR Reviewed-by: Alyssa Rosenzweig Part-of: --- src/vulkan/runtime/vk_render_pass.c | 49 +++++++++++++++++++++++++++++ src/vulkan/runtime/vk_render_pass.h | 4 +++ 2 files changed, 53 insertions(+) diff --git a/src/vulkan/runtime/vk_render_pass.c b/src/vulkan/runtime/vk_render_pass.c index fcee56d7ce2..121f9b1f85c 100644 --- a/src/vulkan/runtime/vk_render_pass.c +++ b/src/vulkan/runtime/vk_render_pass.c @@ -1041,6 +1041,55 @@ vk_get_command_buffer_inheritance_as_rendering_resume( return &data->rendering; } +const VkRenderingAttachmentLocationInfoKHR * +vk_get_command_buffer_rendering_attachment_location_info( + VkCommandBufferLevel level, + const VkCommandBufferBeginInfo *pBeginInfo) +{ + /* From the Vulkan 1.3.295 spec: + * + * "VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT specifies that a + * secondary command buffer is considered to be entirely inside a render + * pass. If this is a primary command buffer, then this bit is ignored." + * + * Since we're only concerned with the continue case here, we can ignore + * any primary command buffers. + */ + if (level == VK_COMMAND_BUFFER_LEVEL_PRIMARY) + return NULL; + + /* From the Vulkan 1.3.295 spec: + * + * "This structure can be included in the pNext chain of a + * VkCommandBufferInheritanceInfo structure to specify inherited state + * from the primary command buffer. If + * VkCommandBufferInheritanceInfo::renderPass is not VK_NULL_HANDLE, or + * VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT is not specified in + * VkCommandBufferBeginInfo::flags, members of this structure are + * ignored." + * + * For the case where a render pass is provided and we're emulating it on + * behalf of the driver, the default NULL behavior is sufficient: + * + * "If this structure is not included in the pNext chain of + * VkCommandBufferInheritanceInfo, it is equivalent to specifying this + * structure with the following properties: + * + * - colorAttachmentCount set to + * VkCommandBufferInheritanceRenderingInfo::colorAttachmentCount. + * + * - pColorAttachmentLocations set to NULL." + */ + if (!(pBeginInfo->flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT)) + return NULL; + + if (pBeginInfo->pInheritanceInfo->renderPass != VK_NULL_HANDLE) + return NULL; + + return vk_find_struct_const(pBeginInfo, + RENDERING_ATTACHMENT_LOCATION_INFO_KHR); +} + VKAPI_ATTR void VKAPI_CALL vk_common_DestroyRenderPass(VkDevice _device, VkRenderPass renderPass, diff --git a/src/vulkan/runtime/vk_render_pass.h b/src/vulkan/runtime/vk_render_pass.h index 7775834d3cd..93a6b55f043 100644 --- a/src/vulkan/runtime/vk_render_pass.h +++ b/src/vulkan/runtime/vk_render_pass.h @@ -415,6 +415,10 @@ vk_get_command_buffer_inheritance_as_rendering_resume( const VkCommandBufferBeginInfo *pBeginInfo, void *stack_data); +const VkRenderingAttachmentLocationInfoKHR * +vk_get_command_buffer_rendering_attachment_location_info( + VkCommandBufferLevel level, + const VkCommandBufferBeginInfo *pBeginInfo); /** * Return true if the subpass dependency is framebuffer-local. */