I am trying to understand the specification of the VkSubpassDependency structure.
Link to VkSubpassDependency structure is on the specification page
The part that confuses me a lot is the relationship between (srcSubpass, dstSubpass) and (srcStageMask, dstStageMask).
The case where srcSubpass is equal to dstSubpass is the same as a pipeline barrier and doesn't raise any questions for me. However, other cases are quite questionnable.
The specification says:
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. Otherwise, the first set of commands includes all commands submitted as part of the subpass instance identified by srcSubpass and any load, store or multisample resolve operations on attachments used in srcSubpass. In either case, the first synchronization scope is limited to operations on the pipeline stages determined by the source stage mask specified by srcStageMask.
By using the definition of syncronisation scopes given by the specification in synchronization-dependencies I interpret the specification this way:
- If srcSubpass and dstSubpass are equal to the same actual subpass numbers and srcStageMask, dstStageMask are equal to some Pipeline stage, for example VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT.
I interpret in this case that the dependency works in the following way: srcSubpass executes freely over the pipeline stages until it reaches the stage given in srcStageMask parameter and stalls until the dstSubpass reaches the stage described in dstStageMask.
- If srcSubpass is equal to VK_SUBPASS_EXTERNAL, dstSubpass is equal to the actual existing subpass number and srcStageMask, dstStageMask is equal to the same Pipeline stage.
In that case I am getting confused about determining the first syncronisation scope.
Because the srcSubpass is equal to VK_SUBPASS_EXTERNAL then the first synchronisation scope includes commands that occur earlier in the submission order than the vkCmdBeginRenderPass used to begin the render pass instance as the specification says. Because the external commands may not have any interaction with the pipeline stages, it makes the interpretation of srcStageMask quite ambiguous. Because nothing relates to the pipeline stage may not be outside the render pass: Does the line from the specification: "In either case, the first synchronization scope is limited to operations on the pipeline stages determined by the source stage mask specified by srcStageMask." refers to the pipeline stages inside dstSubpass and that extends the first syncronistaion scope down to srcStageMask stage in dstSubpass?