]> git.tdb.fi Git - libs/gl.git/commitdiff
Use PRESENT_SRC as the initial layout for swapchain images
authorMikko Rasa <tdb@tdb.fi>
Sat, 20 Nov 2021 22:42:26 +0000 (00:42 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 20 Nov 2021 22:42:26 +0000 (00:42 +0200)
This makes the layout transition work if for some reason a clear command
is not used for the swapchain.

source/backends/vulkan/pipelinecache.cpp

index 3f8e55008223484036b3e5c4760ae5c5bd09d047..22356c7388248937179196b93cb5e55211f20567 100644 (file)
@@ -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<VkSampleCountFlagBits>(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))