Order
What "Order" Actually Means
Consider command flow A --> B.
Even if commands are executed in order, you can still get wrong results.
Because order alone doesn't guarantee:
- That
Ahas finished - That
A's memory writes are visible - That
A's results are usable byB
You can expect three different categories:
- Execution order
- Completion
- Memory visibility
and GL only guarantees the first one by default.
Quick mental model check:
Code snippet:
javaGL.uploadData(); GL.draw(); // based on the data we just uploadedIs it safe?
Yes. This is a CPU-to-GPU memory copy which is implicitly protected by GL. The data is visible to the draw command.
Note:
To illustrate, CPU data is gathered at thereturnstage ofGL.uploadData()but GPU side data copy completes later. The draw command is guaranteed to run when everything is ready; the draw action, however, doesn't wait for the data to upload, because a draw call isn't merely about the data and isn't even an action completed in one shot.
