Creates a new view of the texture, reinterpreting its data using a different pixel format.
- iOS 8.0+
- macOS 10.11+
- Mac Catalyst 13.0+
- tvOS 9.0+
A new pixel format, which must be compatible with the original pixel format.
A new texture object that shares the same storage allocation of the texture.
When you create a texture normally, Metal allocates memory for the textureʼs pixel data. These storage allocations can be quite large. You can reduce memory use and avoid copying texture data by using a texture view—a texture object that shares another textureʼs storage allocation, reinterpreting the pixel data in some other format.
Not all pixel formats are compatible with one another. Reinterpretation of image data between pixel formats is supported within the following groups:
All 8-, 16-, 32-, 64-, and 128-bit color formats are compatible with other formats with the same bit length.
This method doesn't change the original texture image data in any way, but it may drastically change how the data is interpreted. For example, given a texture with the
MTLPixel pixel format that contains image data for Red
0x and Green
0x0001, this method would reinterpret that data in an
MTLPixel format as Red
Some format reinterpretations are supported but may not be useful. For example, this method considers the 32-bit packed color formats
MTLData to be compatible, but it's unlikely that the same data can be interpreted by both formats in a meaningful way.
Some format reinterpretations require you to create the source texture with a special usage flag. Set that flag only when necessary, as it can affect performance. For more details, see