Class

MTLTextureDescriptor

An object that you use to configure new Metal texture objects.

Declaration

@interface MTLTextureDescriptor : NSObject

Overview

To create a new texture, first create a MTLTextureDescriptor object and set its property values. Then, call either the newTextureWithDescriptor: or newTextureWithDescriptor:iosurface:plane: method of a MTLDevice object, or the newTextureWithDescriptor:offset:bytesPerRow: method of a MTLBuffer object.

When you create a texture, Metal copies property values from the descriptor into the new texture. You can reuse a MTLTextureDescriptor object, modifying its property values as needed, to create more MTLTexture objects, without affecting any textures you already created.

Topics

Creating Texture Descriptors

+ texture2DDescriptorWithPixelFormat:width:height:mipmapped:

Creates a texture descriptor object for a 2D texture.

+ textureCubeDescriptorWithPixelFormat:size:mipmapped:

Creates a texture descriptor object for a cube texture.

+ textureBufferDescriptorWithPixelFormat:width:resourceOptions:usage:

Creates a texture descriptor object for a texture buffer.

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.

usage

Options that determine how you can use the texture.

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.

Relationships

Inherits From

Conforms To

See Also

Working with Textures

Creating and Sampling Textures

Load image data into a texture and apply it to a quadrangle.

Understanding Color-Renderable Pixel Format Sizes

Know the size limits of pixel formats used by color render targets in iOS and tvOS GPUs.

Optimizing Texture Data

Optimize a texture’s data to improve GPU or CPU access.

Improving Filtering Quality and Sampling Performance

Provide multiple levels of detail for your textures by using mipmaps.

Managing Texture Memory

Take direct control of memory allocation for texture data by using sparse textures.

MTLTexture

A resource that holds formatted image data.

MTKTextureLoader

An object that decodes common image formats into Metal textures for use in your app.

MTLSharedTextureHandle

A texture handle that can be shared across process address space boundaries.

MTLPixelFormat

The data formats that describe the organization and characteristics of individual pixels in a texture.