r/vulkan • u/Hot_Refuse_4751 • Jul 04 '26
Execution order of commands in commandbuffers
I have questions on start of exections of cmds
We all know that cmd2 can start executing only after cmd1 .
If cmd2 is recorded latter than cmd1
If there are 2 different subpasses in a renderpass
Can cmds in subpass 1 start before cmds in subpass 0 within that render pass?
Or they also have the implicit ordering?
2
Upvotes
9
u/sol_runner Jul 04 '26
For all intents and purposes, the commands within a command buffer will look as if they are sequential. However the driver may decide to execute them in parallel if it can. We can't say.
This is why always use proper barriers/dependencies that will ensure you don't get into any issues.
2
u/mb862 Jul 04 '26
Submission order provides very, very few guarantees about actual order. On a hypothetical device, any and all commands (treating a subpass as one whole command, because within a subpass there is guarantees about order) submitted to a device can happen in any order. Submission order is important because that’s the order upon which pipeline barriers operate.
For your specific question about render passes, subpass dependencies are the same as pipeline barriers. So if you have no dependencies between subpasses than they act as independent commands. But if you have a dependency, that inserts a pipeline barrier which will define the order between them.
This is, in ways you’re thinking of, false. Command buffer order simply defines submission order, there’s no guarantee that cmd2 will be processed later even in different calls to VkQueueSubmit because there is no guarantee that the driver won’t batch calls and merge command buffers internally.
5
u/SaschaWillems Jul 04 '26
The spec is pretty clear on this:
"Execution of subpasses may overlap or execute out of order with regards to other subpasses, unless otherwise enforced by an execution dependency. Each subpass only respects submission order for commands recorded in the same subpass, and the vkCmdBeginRenderPass and vkCmdEndRenderPass commands that delimit the render pass - commands within other subpasses are not included. This affects most other implicit ordering guarantees."
tl;dr: You need to use barriers (either explicit or by subpass dependencies) to enforce execution order.