An encoder that encodes commands that modify resource configurations.


protocol MTLResourceStateCommandEncoder


Use a resource state command encoder to manage memory mappings for sparse textures.

Your app does not define classes that implement this protocol. To create a MTLResourceStateCommandEncoder object, call the makeResourceStateCommandEncoder() method of the MTLCommandBuffer object into which you want to encode blit commands. Next, call methods on the MTLResourceStateCommandEncoder object to enqueue state updates. Finally, call endEncoding() to finish the encoding process.


Updating Texture Memory Assignments

func updateTextureMapping(MTLTexture, mode: MTLSparseTextureMappingMode, region: MTLRegion, mipLevel: Int, slice: Int)

Encodes a command to update the texture mappings for a region in a single texture mipmap.


enum MTLSparseTextureMappingMode

Options for sparse texture mapping.

Updating Texture Memory Assignments Indirectly

func updateTextureMapping(MTLTexture, mode: MTLSparseTextureMappingMode, indirectBuffer: MTLBuffer, indirectBufferOffset: Int)

Encodes a command to update a texture's memory mappings, specifying the parameters indirectly.


struct MTLMapIndirectArguments

The data layout for mapping sparse texture regions when using indirect commands.

Performing Fence Operations

func update(MTLFence)

Updates the given fence to capture all GPU work that the command encoder has enqueued up to this point.


func wait(for: MTLFence)

Prevents the command encoder from enqueuing further GPU commands until the given fence is reached.



Inherits From

See Also


Setting Resource Storage Modes

Set a storage mode that defines the memory location and access permissions of a resource.

Copying Data to a Private Resource

Use a blit command encoder to copy buffer or texture data to a private resource.

Synchronizing a Managed Resource

Synchronize the contents of a managed resource for the CPU or GPU.

Transferring Data Between Connected GPUs

Use high-speed connections between GPUs to transfer data quickly.

Reducing the Memory Footprint of Metal Apps

Learn best practices for using memory efficiently in iOS and tvOS.

protocol MTLResource

An allocation of memory that is accessible to a GPU.

protocol MTLBlitCommandEncoder

An encoder that encodes memory copying, filtering, and fill commands.


Create and manipulate unstructured GPU resources.


Create and manipulate structured GPU resources.

Indirect Command Buffers

Recoup encoding time by reusing commands, or create a GPU-driven rendering pipeline by generating commands on the GPU.


Create a single allocation of memory from which you can suballocate resources.


Manage access to resources in your app to avoid data hazards.