A resource that holds formatted image data.
- iOS 8.0+
- macOS 10.11+
- Mac Catalyst 13.0+
- tvOS 9.0+
Don’t implement this protocol yourself; instead, use one of the following methods to create a
To create a texture that uses an existing
IOSurfaceto hold the texture data, create an
MTLTextureobject to describe the image data in the surface and then call the
newmethod to create the texture.
Texture With Descriptor: iosurface: plane:
To create a texture that reinterprets another texture's data as if it had a different format, call the
Texture View With Pixel Format:
newmethod on a texture object. You must choose a pixel format for the new texture compatible with the source texture's pixel format. The new texture shares the same storage allocation as the source texture. If you make changes to the new texture, those changes are reflected in the source texture, and vice versa.
Texture View With Pixel Format: texture Type: levels: slices:
To create a texture that uses an
MTLBufferobject's contents to hold pixel data, create an
MTLTextureobject to describe the texture's properties and then call the
newmethod on the buffer object. The new texture object shares the storage allocation of the source buffer object. If you make changes to the texture, those changes are reflected in the buffer, and vice versa.
Texture With Descriptor: offset: bytes Per Row:
After you create a
MTLTexture object, most of its characteristics, such as its size, type, and pixel format, are all immutable and can't be changed. Only the texture's pixel data is mutable.
To copy pixel data from system memory into the texture, call
To copy pixel data back into system memory, call