copy(from:sourceSlice:sourceLevel:sourceOrigin:sourceSize:to:destinationSlice:destinationLevel:destinationOrigin:)
Encodes a command that copies image data from a texture’s slice into another slice.
Declaration
func copy(from sourceTexture: any MTLTexture, sourceSlice: Int, sourceLevel: Int, sourceOrigin: MTLOrigin, sourceSize: MTLSize, to destinationTexture: any MTLTexture, destinationSlice: Int, destinationLevel: Int, destinationOrigin: MTLOrigin)Parameters
- sourceTexture:
A texture with an Isframebufferonly property value of False that the command copies data from.
For a texture that uses a compressed pixel format, align the copy region (
sourceOriginandsourceSize) to the pixel format’s block size. - sourceSlice:
A slice within
sourceTexture. - sourceLevel:
A mipmap level within
sourceTexture. - sourceOrigin:
A location within
sourceTexturethat the command begins copying data from.Assign
0to each dimension that’s not relevant tosourceTexture. For example: - sourceSize:
An Mtlsize instance, which can represent a 3D region, that instructs the command how many pixels to copy from
sourceTexture, starting atsourceOrigin.Assign
1to each dimension that’s not relevant tosourceTexture. For example:If the source texture is a 2D texture, set the size’s Depth property to
1.If the source texture is a 1D texture, set the size’s Height and Depth properties to
1.
If
sourceTextureuses a compressed pixel format, setsourceSizeto a multiple of the pixel format’s block size. If the block extends outside the bounds of the texture, clampsourceSizeto the edge of the texture. - destinationTexture:
A texture the command copies data to that has the following configuration:
The Isframebufferonly property value is False.
The pixel format is the same as
sourceTexture.The sample count is the same as
sourceTexture.
For a texture that uses a compressed pixel format, align the copy region (
destinationOrigin) to the pixel format’s block size. - destinationSlice:
A slice within
destinationTexture. - destinationLevel:
A mipmap level within
destinationTexture. - destinationOrigin:
A location within
destinationTexturethat the command begins copying data to.Assign
0to each dimension that’s not relevant todestinationTexture. For example:
Mentioned in
Discussion
For textures that use a PVRTC pixel format, you can use this method to copy the entire texture, but not a subregion of the texture.