jh100
jh100

Reputation: 426

How to guarantee ordering for vkCmdPushConstants?

My understanding of Vulkan is that (with a few exceptions) there's basically no ordering guarantees for command execution within a command buffer: Commands are submitted in-order but they do not complete in-order.

Suppose a program issues these three commands in sequence:

vkCmdDraw

vkCmdPushConstants

vkCmdDraw

If I understand this correctly, the GPU is free to reorder these so the push constants get updated before both draws or after both draws. Is that correct? And if so, does that mean that updating things like push constants or descriptor bindings requires a synchronization object (like an event or pipeline barrier)?

Upvotes: 1

Views: 410

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473352

There are several kinds of recorded commands. Among them are state commands and action commands. State commands set state to be used later. Action commands:

consume the current state of the command buffer when they are recorded, and will execute state changes on the device as required to match the recorded state.

More specifically:

The work involved in performing action commands is often allowed to overlap or to be reordered, but doing so must not alter the state to be used by each action command.

vkCmd/PushConstants is a state command; it sets state into the command buffer. Therefore, subsequent action commands like vkCmdDraw will look at the state currently in the command buffer. Reordering is not allowed to affect this.

Upvotes: 3

Related Questions