From a3fa8eed4c943ceaa63f18f07ca91c285efb9d19 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Tue, 18 Feb 2025 18:57:30 +0100 Subject: [PATCH] radv: implement VK_KHR_unified_image_layouts Signed-off-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/radv_cmd_buffer.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index c1c2d886761..d00eb1a2c88 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -9172,6 +9172,17 @@ attachment_initial_layout(const VkRenderingAttachmentInfo *att) return att->imageLayout; } +static VkImageLayout +get_image_layout(const VkRenderingAttachmentInfo *att) +{ + const VkAttachmentFeedbackLoopInfoEXT *feedback_loop_info = + vk_find_struct_const(att->pNext, ATTACHMENT_FEEDBACK_LOOP_INFO_EXT); + if (feedback_loop_info && feedback_loop_info->feedbackLoopEnable) + return VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT; + + return att->imageLayout; +} + VKAPI_ATTR void VKAPI_CALL radv_CmdBeginRendering(VkCommandBuffer commandBuffer, const VkRenderingInfo *pRenderingInfo) { @@ -9215,9 +9226,10 @@ radv_CmdBeginRendering(VkCommandBuffer commandBuffer, const VkRenderingInfo *pRe continue; VK_FROM_HANDLE(radv_image_view, iview, att_info->imageView); + color_att[i].format = iview->vk.format; color_att[i].iview = iview; - color_att[i].layout = att_info->imageLayout; + color_att[i].layout = get_image_layout(att_info); radv_initialise_color_surface(device, &color_att[i].cb, iview); if (att_info->resolveMode != VK_RESOLVE_MODE_NONE && att_info->resolveImageView != VK_NULL_HANDLE) { @@ -9263,7 +9275,7 @@ radv_CmdBeginRendering(VkCommandBuffer commandBuffer, const VkRenderingInfo *pRe if (d_att_info != NULL && d_att_info->imageView != VK_NULL_HANDLE) { d_iview = radv_image_view_from_handle(d_att_info->imageView); initial_depth_layout = attachment_initial_layout(d_att_info); - ds_att.layout = d_att_info->imageLayout; + ds_att.layout = get_image_layout(d_att_info); if (d_att_info->resolveMode != VK_RESOLVE_MODE_NONE && d_att_info->resolveImageView != VK_NULL_HANDLE) { d_res_iview = radv_image_view_from_handle(d_att_info->resolveImageView); @@ -9275,7 +9287,7 @@ radv_CmdBeginRendering(VkCommandBuffer commandBuffer, const VkRenderingInfo *pRe if (s_att_info != NULL && s_att_info->imageView != VK_NULL_HANDLE) { s_iview = radv_image_view_from_handle(s_att_info->imageView); initial_stencil_layout = attachment_initial_layout(s_att_info); - ds_att.stencil_layout = s_att_info->imageLayout; + ds_att.stencil_layout = get_image_layout(s_att_info); if (s_att_info->resolveMode != VK_RESOLVE_MODE_NONE && s_att_info->resolveImageView != VK_NULL_HANDLE) { s_res_iview = radv_image_view_from_handle(s_att_info->resolveImageView);