What if I specify an unused pipeline stage in a barrier/external subpass dependency?
Let’s assume I synchronize two shaders (either via pipeline barrier or external subpass dependency, which should not make a difference for the sake of this example) using the following stages masks:
srcStageMask = VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT,
dstStageMask = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
What happens if the pipeline used in the first command does NOT include tessellation shaders (but only vertex+fragment shaders)? Would no synchronization happen at all because there are no active commands in the pipeline that have tessellation shader stages?
Wouldn’t it also be a viable strategy to execute all previous commands up to stages “less than or equal to tessellation evaluation shader stages” before establishing the barrier?
If I’m not mistaken, I would have to specify
srcStageMask = VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT
for my example to work (assuming that there could be shaders consisting of vert+frag only, but also vert+tesc+tese+frag before the barrier), right? Or are there other options as well (besides from VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT
or VK_PIPELINE_STAGE_ALL_COMMANDS_BIT
)?
What about BOTTOM_OF_PIPE?
Furthermore, I am a bit confused about VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT
. The specification states that it can not be used with memory access flags because there is no memory access associated with these stages.
When defining a memory dependency, using only
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT
orVK_PIPELINE_STAGE_TOP_OF_PIPE_BIT
would never make any accesses available and/or visible because these stages do not access memory.
But what about execution dependencies? Could I synchronize only the execution of my example from above with the following stages masks?
srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
dstStageMask = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
The specifications state:
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT
specifies the final stage in the pipeline where operations generated by all commands complete execution.
So that sounds like it could be used for an execution barrier. However, I am a bit confused about that “all commands”. Doesn’t it refer to each specific command’s pipeline run-through, i.e. until each command has completely finished its work?
In general, I’d like to know: Is there any meaningful way, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT
can be used with the srcStageMask
? I’ve often seen it being used in the dstStageMask
, meaning that nothing shall be synchronized, but what about srcStageMask
?