1
votes

I'm studying Vulkan RenderPasses, for hobby.

I have the following descriptions for members of VkSubpassDependency struct. The verbiage is a combination of language from sources(books, spec, internet), and my own word-smithing. The descriptions might be wrong because of my messing with them.

// .srcSubpass: 
//      The subpass index from which "producing" operations should be finished before the second set of "consuming" operations executes.
//      If there are no dependencies on previous subpasses(eg: first subpass), use VK_SUBPASS_EXTERNAL.
// .srcStageMask:
//      A bitmask of the pipeline stages which produce the data read by the "consuming" commands.
// .srcAccessMask:
//      The types of memory operations that occurred during the "producing" commands.
// ----------
// .dstSubpass:
//      The index of the first subpass whose operations depend the output of this subpass; or VK_SUBPASS_EXTERNAL, if 
//      there are no destination subpasses dependencies.
// .dstStageMask:
//      A bitmask of the pipeline stages which depend on the data generated by the "producing" commands.
// .dstAccessMask:
//      The types of memory operations that will be performed in "consuming" commands.

I have some questions

Lets say that a RenderPass has 3 subpasses -- S1, S2, S3 -- which are "logically" executed in sequence, but which may be executed out of order by the GPU.

    1. srcSubpass:
  • 1.1. Is it possible for there to be a scenario in which S3 does not depend on either S1 nor S2? Or do subsequent subpasses always depend on some previous pass?
  • 1.2. If 1.1 is true, then srcSubpass would be VK_SUBPASS_EXTERNAL, correct?
  • 1.3. Or, does VK_SUBPASS_EXTERNAL only ever apply to S1?

  • 2. dstSubpass:
  • 2.1. Is this simply always the index of the next logical subpass (ie: S1->S2)? Or is it possible for it to be S1->S3?
  • 2.2. Similar to question 1.1, is it possible for S3 not to depend on S2, and thus this value would be VK_SUBPASS_EXTERNAL for S2?

  • 3. srcStageMask:
  • 3.1. Is it the case that the earlier the pipeline stage is, the less the dependency between the 2 sets of operations would be? That is, a srcStageMask of VK_PIPELINE_STAGE_VERTEX_INPUT_BIT would have a smaller dependency time than VK_PIPELINE_STAGE_VERTEX_SHADER_BIT.
  • 3.2. If 3.1 is true, then this means that the ideal pipeline stage would be VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, correct?

  • 4. dstStageMask:
  • 4.1. For a smaller dependency time between 2 sets of operations, the farther down the pipeline, the better?
  • 4.2. If 4.1 is true, then VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT would be the ideal stage, for minimum dependency. Yeah?

Thanks

1

1 Answers

1
votes

1.1 Anything that is not impossible\invalid is by definition possible. Might make sense to render to two independent color attachments using the same vertex buffer. Might save on binning, which need only be done once.

1.2 Not necessarily. For example a subpass might have no color attachments and instead output via Storage Images. Therefore it needs no VK_SUBPASS_EXTERNAL dependecy, explict nor implicit.

1.3 No it applies to whichever subpass uses given attachment first, as that one executes the LoadOp for that attachment.

2.1 Yes, it is a dependency DAG, so it might have S1→S3, S2→S3 (and no S1→S2).

2.2 It might be VK_SUBPASS_EXTERNAL. Note you can have more dependencies; one can be VK_SUBPASS_EXTERNAL and other may have another subpass. One attachment in S2 might be finished and have early StoreOp here, and therefore VK_SUBPASS_EXTERNAL would be appropriate for it.

3.1 Yes, the more logically-earlier stage is used in srcStageMask, the restriction imposed by such dependency is lesser or equal.

3.2 Yes, that would be a no-op dependency. Coincidentally this is how the implicit subpass dependency is specified.

4.1 Yea, same logic. The more logically-later stage is used in `dstStageMask, the restriction imposed by such dependency is lesser or equal.

4.2 That is the no-op dependency. And coincidentally this is how the implicit subpass dependency is specified.