Instance Property

usage

Options that determine how you can use the texture.

Declaration

@property(readwrite, nonatomic) MTLTextureUsage usage;

Discussion

The default value for this property is MTLTextureUsageShaderRead. If the given texture has multiple uses in your app, you can combine multiple usage options for that texture. After you set a 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

See Also

Specifying Texture Attributes

textureType

The dimension and arrangement of texture image data.

pixelFormat

The size and bit layout of all pixels in the texture.

width

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

height

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

depth

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

mipmapLevelCount

The number of mipmap levels for this texture.

sampleCount

The number of samples in each fragment.

arrayLength

The number of array elements for this texture.

resourceOptions

The behavior of a new memory allocation.

cpuCacheMode

The CPU cache mode used for the CPU mapping of the texture.

storageMode

The location and access permissions of the texture.

hazardTrackingMode

The texture's hazard tracking mode.

allowGPUOptimizedContents

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

swizzle

The pattern you want the GPU to apply to pixels when you read or sample pixels from the texture.

MTLTextureSwizzleChannels

A pattern that modifies the data read or sampled from a texture by rearranging or duplicating the elements of a vector.

MTLTextureSwizzleChannelsMake

Creates a new swizzle pattern.

MTLTextureSwizzle

A set of options to choose from when creating a texture swizzle pattern.