From: Mikko Rasa Date: Sun, 21 Nov 2021 12:52:38 +0000 (+0200) Subject: Add a subpass dependency to ensure the rendering result is available X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=7d83470885ed35852c15568bd56ece1a638b2670;p=libs%2Fgl.git Add a subpass dependency to ensure the rendering result is available --- diff --git a/source/backends/vulkan/pipelinecache.cpp b/source/backends/vulkan/pipelinecache.cpp index 425be40a..8cc447ae 100644 --- a/source/backends/vulkan/pipelinecache.cpp +++ b/source/backends/vulkan/pipelinecache.cpp @@ -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);