<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLResourceStateCommandEncoder/updateTextureMapping(_:mode:region:mipLevel:slice:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLResourceStateCommandEncoder(im)updateTextureMapping:mode:region:mipLevel:slice:"
  },
  "title" : "updateTextureMapping(_:mode:region:mipLevel:slice:)"
}
-->

# updateTextureMapping(_:mode:region:mipLevel:slice:)

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

```
optional func updateTextureMapping(_ texture: any MTLTexture, mode: MTLSparseTextureMappingMode, region: MTLRegion, mipLevel: Int, slice: Int)
```

## Parameters

`texture`

The sparse texture to update.

`mode`

A mode that indicates whether the method allocates or frees a memory tile in the texture.

`region`

A region, in tile coordinates, that describes the part of the mipmap to update.

`mipLevel`

The mipmap to update.

`slice`

The slice in the texture to update.

## Discussion

When the GPU executes the command that updates the texture’s memory mapping, the GPU gets details about the region from the `region` parameter.

To allocate tiles from the heap, pass [`MTLSparseTextureMappingMode.map`](/documentation/Metal/MTLSparseTextureMappingMode/map) as the `mode` parameter, and to free files back to the heap, pass [`MTLSparseTextureMappingMode.unmap`](/documentation/Metal/MTLSparseTextureMappingMode/unmap).

If you encode other commands that use the texture’s contents, such as rendering to the texture or sampling from a texture, synchronize the texture’s mapping updates with those commands to avoid race conditions. See [Resource synchronization](/documentation/Metal/resource-synchronization).

If you encode commands with multiple resource state passes, synchronize the resources to run the commands in the passes sequentially. See the [`MTLResourceStateCommandEncoder`](/documentation/Metal/MTLResourceStateCommandEncoder) protocol.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)