From: Mikko Rasa Date: Sat, 20 Nov 2021 22:42:26 +0000 (+0200) Subject: Use PRESENT_SRC as the initial layout for swapchain images X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=026b0ea00684868f3ddb6650b5fbffc95fa7ec63;p=libs%2Fgl.git Use PRESENT_SRC as the initial layout for swapchain images This makes the layout transition work if for some reason a clear command is not used for the swapchain. --- diff --git a/source/backends/vulkan/pipelinecache.cpp b/source/backends/vulkan/pipelinecache.cpp index 3f8e5500..22356c73 100644 --- a/source/backends/vulkan/pipelinecache.cpp +++ b/source/backends/vulkan/pipelinecache.cpp @@ -62,6 +62,7 @@ VkRenderPass PipelineCache::get_render_pass(const FrameFormat &format, bool clea depth_stencil_ref.attachment = VK_ATTACHMENT_UNUSED; VkSampleCountFlagBits vk_samples = static_cast(get_vulkan_samples(format.get_samples())); + VkImageLayout default_layout = (to_present ? VK_IMAGE_LAYOUT_PRESENT_SRC_KHR : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); unsigned i = 0; unsigned color_count = 0; @@ -73,8 +74,8 @@ VkRenderPass PipelineCache::get_render_pass(const FrameFormat &format, bool clea attachments[i].storeOp = VK_ATTACHMENT_STORE_OP_STORE; attachments[i].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD; attachments[i].stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE; - attachments[i].initialLayout = (clear ? VK_IMAGE_LAYOUT_UNDEFINED : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); - attachments[i].finalLayout = (to_present ? VK_IMAGE_LAYOUT_PRESENT_SRC_KHR : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); + attachments[i].initialLayout = (clear ? VK_IMAGE_LAYOUT_UNDEFINED : default_layout); + attachments[i].finalLayout = default_layout; unsigned attach_pt = get_attach_point(a); if(attach_pt==get_attach_point(COLOR_ATTACHMENT))