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

# memoryBarrier(scope:)

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

## Declaration

```swift
func memoryBarrier(scope: MTLBarrierScope)
```

## Parameters

- `scope`: An doc://com.apple.metal/documentation/Metal/MTLBarrierScope instance that represents the resource types the barrier synchronizes operations on.

## 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(resources:)](metal/mtlcomputecommandencoder/memorybarrier(resources:).md)
