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
func synchronize(resource: any MTLResource)Parameters
- resource:
An Mtlresource instance — such as an Mtlbuffer or Mtltexture — with a Storagemode property that’s equal to Managed.
Mentioned in
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.