A memory allocation for storing formatted image data that is accessible to the GPU.
- iOS 8.0+
- macOS 10.11+
- tvOS 9.0+
MTLTexture protocol defines the interface for an object that represents an allocation of formatted image data. Textures are used as source data for a vertex shader, a fragment shader, or a compute kernel. They are also used as an attachment that acts as a rendering destination.
Do not use standard allocation and initialization techniques to create a
MTLTexture object. The following methods create and return a
newmethod of the
Texture With Descriptor:
MTLDeviceprotocol creates a texture object with a new storage allocation for the texture image data, using a
MTLTextureobject to describe the texture’s properties. To further specify an
IOSurfacefrom which to create the texture, use the
Texture With Descriptor: iosurface: plane:
Texture View With Pixel Format:
newmethods of the
Texture View With Pixel Format: texture Type: levels: slices:
MTLTextureprotocol create and return a new texture object that shares the same storage allocation as the source texture object. Because they share the same storage, any changes to the pixels of the new texture are reflected in the source texture, and vice versa. For the newly created texture, these methods reinterpret the existing texture image data in the storage allocation of the source texture as if this data were stored in the new specified pixel format. The pixel format of the new texture must be compatible with the pixel format of the source texture.
In iOS, the
newmethod of the
Texture With Descriptor: offset: bytes Per Row:
MTLBufferprotocol creates and returns a new texture object that shares the storage allocation of the source buffer object as its texture image data. Because they share the same storage, any changes to the pixels of the new texture are reflected in the source buffer, and vice versa.
texture property identifies how the image data is organized. Image data is arranged in one or more slices, and each slice is a single
MTLTexture texture type image and all its mipmaps.
MTLTexture texture types have a single slice. A
MTLTexture texture always has six slices, one for each face. For a texture array object, such as
MTLTexture, every array element is one slice.
After you create a texture, you can call
replace to populate the storage allocation of the texture object with image data from system memory. Call
get to copy image data from a texture object and store the copied data into system memory.