Contents

synchronize(texture:slice:level:)

Encodes a command that synchronizes a part of the CPU’s copy of a texture so that it matches the GPU’s copy.

Declaration

func synchronize(texture: any MTLTexture, slice: Int, level: Int)

Parameters

  • texture:

    An Mtltexture instance with a Storagemode property that’s equal to Managed.

  • slice:

    A slice within texture.

  • level:

    A mipmap level within texture.

Mentioned in

Discussion

This method ensures the CPU can correctly read the changes a GPU makes to a slice of a texture 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 texture after the synchronization command completes.

See Also

Synchronizing managed resources