Skip to content

Commit

Permalink
Examples: Vulkan: Fix missing subpass dependency
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cforfang authored and ocornut committed Mar 19, 2018
1 parent a73f6d0 commit 4485e56
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/vulkan_example/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 4485e56

Please sign in to comment.