memoryBarrier(scope:after:before:)
Creates a memory barrier that enforces the order of write and read operations for specific resource types.
Declaration
func memoryBarrier(scope: MTLBarrierScope, after: MTLRenderStages, before: MTLRenderStages)Parameters
- scope:
An Mtlbarrierscope instance that represents the resource types the barrier synchronizes operations on.
- after:
The render stages of previous draw commands that modify resources of the types that
scopedefines. - before:
The render stages of subsequent draw commands that read or modify resources of the types that
scopedefines.
Discussion
Memory barriers ensure the relevant stages of prior draw commands finish updating resources before starting the stages of subsequent commands that depend on those resources.
To determine whether a GPU supports memory barriers, see the Metal feature set tables (PDF).