Hristo
Hristo

Reputation: 6540

iOS Metal: command buffer execution order

Suppose I commit two commands buffers modifying the same texture, generated from the same queue:

var a: MTLCommandBuffer
var b: MTLCommandBuffer
...
a.commit()
b.commit()

Then, suppose I wait for the second one to complete:

b.waitUntilCompleted()

Is it possible that b gets completed before a? According to the documentation for commit(),

The command buffer is executed after any command buffers enqueued before it on the same command queue

Does this imply that b will finish executing after a finishes or that it will just begin executing after a begins executing?

Upvotes: 4

Views: 1665

Answers (1)

Sami Kuhmonen
Sami Kuhmonen

Reputation: 31153

From the documentation of commit, assuming here the buffers are in the same queue:

The command buffer is executed after any command buffers enqueued before it on the same command queue.

This is logical since one MTLCommandQueue will only execute one buffer at a time. So b will start executing after a has executed and waiting for it means both will have finished when it has finished.

Upvotes: 1

Related Questions