Examples: Vulkan: Fix missing subpass dependency

Without a dependency between pWaitDstStageMask (COLOR_ATTACHMENT_OUTPUT)
and the render-pass, the UNDEFINED -> COLOR_ATTACHMENT_OPTIMAL transition
might happen before the image is ready to be used.
This commit is contained in:
Christian Forfang 2018-03-19 15:01:00 +01:00 committed by omar
parent a73f6d06e0
commit 4485e56e02

View File

@ -142,12 +142,21 @@ static void resize_vulkan(int w, int h)
subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
subpass.colorAttachmentCount = 1;
subpass.pColorAttachments = &color_attachment;
VkSubpassDependency dependency = {};
dependency.srcSubpass = VK_SUBPASS_EXTERNAL;
dependency.dstSubpass = 0;
dependency.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
dependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
dependency.srcAccessMask = 0;
dependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
VkRenderPassCreateInfo info = {};
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
info.attachmentCount = 1;
info.pAttachments = &attachment;
info.subpassCount = 1;
info.pSubpasses = &subpass;
info.dependencyCount = 1;
info.pDependencies = &dependency;
err = vkCreateRenderPass(g_Device, &info, g_Allocator, &g_RenderPass);
check_vk_result(err);
}