]> git.tdb.fi Git - libs/gl.git/commitdiff
Add a subpass dependency to ensure the rendering result is available
authorMikko Rasa <tdb@tdb.fi>
Sun, 21 Nov 2021 12:52:38 +0000 (14:52 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 21 Nov 2021 23:44:36 +0000 (01:44 +0200)
source/backends/vulkan/pipelinecache.cpp

index 425be40ab776478ecab88df4ed636c9f09fef960..8cc447aedbf91c2bf8f68cb302483637d2aaaa8a 100644 (file)
@@ -100,6 +100,7 @@ VkRenderPass PipelineCache::get_render_pass(const FrameFormat &format, bool clea
        subpass.pColorAttachments = color_refs;
        subpass.pDepthStencilAttachment = &depth_stencil_ref;
 
+       VkSubpassDependency dependency = { };
        VkRenderPassCreateInfo render_pass_info = { };
        render_pass_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
        render_pass_info.attachmentCount = format.size();
@@ -107,6 +108,19 @@ VkRenderPass PipelineCache::get_render_pass(const FrameFormat &format, bool clea
        render_pass_info.subpassCount = 1;
        render_pass_info.pSubpasses = &subpass;
 
+       if(to_present)
+       {
+               dependency.srcSubpass = 0;
+               dependency.dstSubpass = VK_SUBPASS_EXTERNAL;
+               dependency.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+               dependency.srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT;
+               dependency.dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
+               dependency.dstAccessMask = 0;
+
+               render_pass_info.dependencyCount = 1;
+               render_pass_info.pDependencies = &dependency;
+       }
+
        VkRenderPass render_pass;
        vk.CreateRenderPass(render_pass_info, render_pass);