A resource that holds formatted image data.
SDKs
- iOS 8.0+
- macOS 10.11+
- Mac Catalyst 13.0+
- tvOS 9.0+
Framework
- Metal
Declaration
protocol MTLTexture
Overview
Don’t implement this protocol yourself; instead, use one of the following methods to create a MTLTexture
object:
Create an
MTLTexture
object to describe the texture's properties and then call theDescriptor make
method of theTexture(descriptor:) MTLDevice
protocol to create the texture.To create a texture that uses an existing
IOSurface
to hold the texture data, create anMTLTexture
object to describe the image data in the surface and then call theDescriptor make
method to create the texture.Texture(descriptor: iosurface: plane:) To create a texture that reinterprets another texture's data as if it had a different format, call the
make
orTexture View(pixel Format:) make
method 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(pixel Format: texture Type: levels: slices:) To create a texture that uses an
MTLBuffer
object's contents to hold pixel data, create anMTLTexture
object to describe the texture's properties and then call theDescriptor make
method 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(descriptor: offset: bytes Per Row:)
To copy pixel data from system memory into the texture, call replace(region:
or replace(region:
.
To copy pixel data back into system memory, call get
or get
.