copy(sourceBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:destinationTexture:destinationSlice:destinationLevel:destinationOrigin:options:)
Encodes a command to copy image data from a buffer into a texture with options for special texture formats.
Declaration
func copy(sourceBuffer: any MTLBuffer, sourceOffset: Int, sourceBytesPerRow: Int, sourceBytesPerImage: Int, sourceSize: MTLSize, destinationTexture: any MTLTexture, destinationSlice: Int, destinationLevel: Int, destinationOrigin: MTLOrigin, options: MTLBlitOption = [])Parameters
- sourceBuffer:
An Mtlbuffer instance the command copies data from.
- sourceOffset:
A byte offset within
sourceBufferthe command copies from. Set this value to a multiple ofdestinationTexture'spixel size, in bytes. - sourceBytesPerRow:
The number of bytes between adjacent rows of pixels in
sourceBuffer. Set this value to a multiple ofdestinationTexture'spixel size, in bytes, and less than or equal to the product ofdestinationTexture'spixel size, in bytes, and the largest pixel widthdestinationTexture'stype allows. IfdestinationTextureuses a compressed pixel format, setsourceBytesPerRowto the number of bytes between the starts of two row blocks. - sourceBytesPerImage:
The number of bytes between each 2D image of a 3D texture. Set this value to a multiple of
destinationTexture'spixel size, in bytes, or0ifsourceSize'sDepth value is1. - sourceSize:
An Mtlsize instance that represents the size of the region in
destinationTexture, in pixels, that the command copies data to, starting atdestinationOrigin. Assign1to each dimension that’s not relevant todestinationTexture. IfdestinationTextureuses a compressed pixel format, setsourceSizeto a multiple ofdestinationTexture'sPixelformat block size. If the block extends outside the bounds of the texture, clampsourceSizeto the edge of the texture. - destinationTexture:
An Mtltexture instance the command copies data to. In order to copy the contents into the destination texture, set its Isframebufferonly property to False and don’t use a combined depth/stencil Pixelformat.
- destinationSlice:
A slice within
destinationTexturethe command uses as its starting point for copying data to. Set this to0ifdestinationTextureisn’t a texture array or a cube texture. - destinationLevel:
A mipmap level within
destinationTexturethe command copies data to. - destinationOrigin:
An Mtlorigin instance that represents a location within
destinationTexturethat the command begins copying data to. Assign0to each dimension that’s not relevant todestinationTexture. - options:
An Mtlblitoption value that applies to textures with applicable pixel formats, such as combined depth/stencil or PVRTC formats. If
destinationTexture'sPixelformat is a combined depth/stencil format, setoptionsto either Depthfromdepthstencil or Stencilfromdepthstencil, but not both. IfdestinationTexture'sPixelformat is a PVRTC format, setoptionsto Rowlinearpvrtc.