Contents

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

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

Declaration

func updateTextureMapping(_ texture: any MTLTexture, mode: MTLSparseTextureMappingMode, region: MTLRegion, mipLevel: Int, slice: Int)
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 as the mode parameter, and to free files back to the heap, pass 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.

If you encode commands with multiple resource state passes, synchronize the resources to run the commands in the passes sequentially. See the MTLResourceStateCommandEncoder protocol.

See Also

Updating texture memory assignments