Enumeration

MTLTextureUsage

An enumeration for the various options that determine how you can use a texture.

Declaration

typedef enum MTLTextureUsage : NSUInteger {
    ...
} MTLTextureUsage;

Overview

If a texture has multiple uses in your app, you can combine multiple usage options for that texture. After you set the texture’s usage options, you can use it only in the ways that you specified.

Metal can optimize operations for a given texture, based on its intended use. Set explicit usage options for a texture, if you know them in advance, before you use the texture. Only set usage options that correspond to a texture’s intended use.

In iOS devices with GPU family 5, Metal doesn’t apply lossless compression to a given texture if you set any of these options:

  • MTLTextureUsageUnknown

  • MTLTextureUsageShaderWrite

  • MTLTextureUsagePixelFormatView

Topics

Specifying Texture Usage Options

MTLTextureUsageUnknown

An option for a texture whose usage is unknown.

MTLTextureUsageShaderRead

An option for reading or sampling from the texture in a shader.

MTLTextureUsageShaderWrite

An option for writing to the texture in a shader.

MTLTextureUsageRenderTarget

An option for rendering to the texture in a render pass.

MTLTextureUsagePixelFormatView

An option for creating texture views.

See Also

Querying Texture Attributes

textureType

The dimension and arrangement of the texture image data.

Required.

pixelFormat

The format of pixels in the texture.

Required.

width

The width of the texture image for the base level mipmap, in pixels.

Required.

height

The height of the texture image for the base level mipmap, in pixels.

Required.

depth

The depth of the texture image for the base level mipmap, in pixels.

Required.

mipmapLevelCount

The number of mipmap levels in the texture.

Required.

arrayLength

The number of slices in the texture array.

Required.

sampleCount

The number of samples in each pixel.

Required.

framebufferOnly

A Boolean value that indicates whether the texture can only be used as a render target.

Required.

usage

Options that determine how you can use the texture.

Required.

allowGPUOptimizedContents

A Boolean value indicating whether the GPU is allowed to adjust the contents of the texture to improve GPU performance.

Required.

shareable

A Boolean indicating whether this texture can be shared with other processes.

Required.

swizzle

The pattern that the GPU applies to pixels when you read or sample pixels from the texture.

Required.

MTLTextureType

The dimension of each image, including whether multiple images are arranged into an array or a cube.