Creates a new texture object that shares the texture's storage allocation, reinterpreting the texture image data using a different pixel format.
- iOS 9.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 type, which can be cast according to the original texture type as listed in Table 1.
A new base level range that restricts which mipmap levels are visible in the new texture.
A new base slice range that restricts which array slices are visible in the new texture.
A new texture object that shares the same storage allocation of the calling texture object.
Not all pixel formats are compatible with one another; for example, you can't use this method between color pixel formats of different sizes. Reinterpretation of image data between pixel formats is supported within the following groups:
All 8-bit color formats
All 16-bit color formats
All 32-bit color formats
All 64-bit color formats
All 128-bit color formats
sRGB and non-sRGB forms of the same compressed format; for example:
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 0xFFFE and Green 0x0001, this method would reinterpret that data in an
MTLPixel format as Red 0x0001FFFE.
Some format reinterpretations are supported but may not be useful. For example, this method considers the 32-bit packed color formats MTLPixelFormatA2BGR10Uint and MTLPixelFormatB10GR11Float to be compatible, but it's unlikely that the same data can be interpreted by both formats in a meaningful way.
The texture type can be cast between the targets listed in Table 1.
Original texture type
New texture type