8

I was recently learning the Vulkan API but just cannot understand what VK_SUBPASS_EXTERNAL (assigned to VkSubpassDependency::srcSubpass or VkSubpassDependency::dstSubpass) means. The official documentation states: "If srcSubpass is equal to VK_SUBPASS_EXTERNAL, the first synchronization scope includes commands that occur earlier in submission order than the vkCmdBeginRenderPass used to begin the render pass instance."

Does it imply that a subpass can depend on another subpass residing in other render passes? Or anything else?

ph3rin
  • 4,426
  • 1
  • 18
  • 42

1 Answers1

8

VK_SUBPASS_EXTERNAL means anything outside of a given render pass scope. When used for srcSubpass it specifies anything that happened before the render pass. And when used for dstSubpass it specifies anything that happens after the render pass.

Does it imply that a subpass can depend on another subpass residing in other render passes?

It means that synchronization mechanisms need to include operations that happen before or after the render pass. It may be another render pass, but it also may be some other operations, not necessarily render pass-related.

Ekzuzy
  • 3,193
  • 1
  • 16
  • 14
  • Great thanks! Another question is: if the previous operations the subpass depends doesn't belong to a render pass (which means it has no pipeline stage), then the srcStageMask (or the dstStageMask) is not necessary, right? – ph3rin Dec 31 '18 at 14:16
  • 1
    @FawkesFlammer: "*which means it has no pipeline stage*" There are plenty of pipeline stages not created in render passes. – Nicol Bolas Dec 31 '18 at 14:19
  • @NicolBolas Could you give me some examples? As a newbie, I only know that subpasses have pipeline stages, as they use shaders, render to attachments, etc. Thanks. – ph3rin Dec 31 '18 at 14:39
  • @FawkesFlammer: Look at the `PIPELINE_STAGE` enumerators in Vulkan. Or as an incomplete list, "compute" and "transfer". – Nicol Bolas Dec 31 '18 at 14:41
  • @NicolBolas I now have a loop that constantly submits just a simple render pass with only "vkCmdBindPipeline" and "vkCmdDraw" commands. I specify a semaphore to wait at the color attachment output stage. I also specify a subpass dependency for that render pass to depend on VK_SUBPASS_EXTERNAL's color attachment stage. Now what exactly does it depend on? (What exactly is the "VK_SUBPASS_EXTERNAL's color attachment stage"?) – ph3rin Dec 31 '18 at 14:56
  • @FawkesFlammer: As Ekzuzy said, it means "anything outside of a given render pass scope". A source external color attachment dependency means any color attachment stages before the render pass. – Nicol Bolas Dec 31 '18 at 15:43
  • Thank you, guys! I have finally come up with an understanding of what's happening in vulkan's synchronization mechanisms! A useful link I used: [https://github.com/KhronosGroup/Vulkan-Docs/issues/812](https://github.com/KhronosGroup/Vulkan-Docs/issues/812) – ph3rin Jan 01 '19 at 08:24