barrier(afterStages:beforeQueueStages:visibilityOptions:)
Encodes a producer barrier on work committed to the same command queue.
Declaration
func barrier(afterStages: MTLStages, beforeQueueStages: MTLStages, visibilityOptions: MTL4VisibilityOptions = [ .device ])Parameters
- afterStages:
Mtlstages mask that represents the stages of work to wait for. This argument applies to work corresponding to these stages you encode in the current command encoder prior to this barrier command.
- beforeQueueStages:
Mtlstages mask that represents the stages of work that need to wait. This argument applies to subsequent encoders and not to work in the current command encoder.
- visibilityOptions:
Mtl4visibilityoptions of the barrier, controlling cache flush behavior.
Mentioned in
Discussion
This method encodes a barrier that guarantees that any work you encode using subsequent command encoders, corresponding to beforeQueueStages, don’t begin until all commands you previously encode in the current encoder (and prior encoders), corresponding to afterStages, complete.
When calling this method, you can pass any MTLStages to parameters afterStages and beforeQueueStages, even stages that don’t relate to the current or prior command encoders.