---
title: "memoryBarrier(resources:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlcomputecommandencoder/memorybarrier(resources:)"
---

# memoryBarrier(resources:)

Creates a memory barrier that enforces the order of write and read operations for specific resources.

## Declaration

```swift
func memoryBarrier(resources: [any MTLResource])
```

## Parameters

- `resources`: An array of doc://com.apple.metal/documentation/Metal/MTLResource instances the barrier applies to.

## Discussion

Discussion Memory barriers ensure the relevant passes 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).

## See Also

### Preventing resource access conflicts

- [waitForFence(_:)](metal/mtlcomputecommandencoder/waitforfence(_:).md)
- [updateFence(_:)](metal/mtlcomputecommandencoder/updatefence(_:).md)
- [memoryBarrier(scope:)](metal/mtlcomputecommandencoder/memorybarrier(scope:).md)
