3
votes

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?

1
This is not really an answer to your question, but do you have a good reason for using two command buffers? Can you not encode all the work into the same command buffer? - Matthijs Hollemans

1 Answers

2
votes

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.