---
title: "synchronize(resource:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlblitcommandencoder/synchronize(resource:)"
---

# synchronize(resource:)

Encodes a command that synchronizes the CPU’s copy of a managed resource, such as a buffer or texture, so that it matches the GPU’s copy.

## Declaration

```swift
func synchronize(resource: any MTLResource)
```

## Parameters

- `resource`: An doc://com.apple.metal/documentation/Metal/MTLResource instance — such as an doc://com.apple.metal/documentation/Metal/MTLBuffer or doc://com.apple.metal/documentation/Metal/MTLTexture — with a doc://com.apple.metal/documentation/Metal/MTLResource/storageMode property that’s equal to doc://com.apple.metal/documentation/Metal/MTLStorageMode/managed.

## Mentioned in

Synchronizing a managed resource in macOS

## Discussion

Discussion This method ensures the CPU can correctly read all the changes a GPU makes to a resource that uses the managed storage mode. For the resources you create with MTLStorageMode.managed, the CPU and GPU each have a copy of that resource. As the GPU modifies its copy, the CPU’s copy remains unchanged until you synchronize with a command, such as this one. The CPU can access the updated content from its copy of the resources after the synchronization command completes. note: You can encode a command that selectively synchronizes parts of an MTLTexture by calling the synchronize(texture:slice:level:) method.

## See Also

### Synchronizing managed resources

- [synchronize(texture:slice:level:)](metal/mtlblitcommandencoder/synchronize(texture:slice:level:).md)
