memoryBarrier(resources:after:before:)
Creates a memory barrier that enforces the order of write and read operations for specific resources.
Declaration
func memoryBarrier(resources: [any MTLResource], after: MTLRenderStages, before: MTLRenderStages)Parameters
- resources:
An array of Mtlresource instances the barrier applies to.
- after:
The render stages of previous draw commands that modify
resources. - before:
The render stages of subsequent draw commands that read or modify
resources.
Discussion
Memory barriers ensure the relevant stages of prior draw commands finish modifying 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).