makeTextureView(pixelFormat:textureType:levels:slices:)
Creates a new view of the texture, reinterpreting a subset of its data using a different type and pixel format.
Declaration
func makeTextureView(pixelFormat: MTLPixelFormat, textureType: MTLTextureType, levels levelRange: Range<Int>, slices sliceRange: Range<Int>) -> (any MTLTexture)?Parameters
- pixelFormat:
A new pixel format, which needs to be compatible with the original pixel format.
- textureType:
A new texture type, which can be cast according to the original texture type as listed the table below.
- levelRange:
A new base level range that restricts which mipmap levels are visible in the new texture.
- sliceRange:
A new base slice range that restricts which array slices are visible in the new texture.
Return Value
A new texture object that shares the same storage allocation of the calling texture object.
Discussion
The texture type can be cast between the targets listed in the following table.
Original texture type | New texture type |
|---|---|
The length value of the sliceRange parameter needs to be 6 if the new texture type value is MTLTextureType.typeCube, or a multiple of 6 if the new texture type value is MTLTextureType.typeCubeArray.
For more information on pixel format restrictions, see makeTextureView(pixelFormat:)