copy(from:sourceOffset:to:destinationOffset:size:)
Encodes a command that copies data from one buffer into another.
Declaration
func copy(from sourceBuffer: any MTLBuffer, sourceOffset: Int, to destinationBuffer: any MTLBuffer, destinationOffset: Int, size: Int)Parameters
- sourceBuffer:
A buffer the command copies data from.
- sourceOffset:
A byte offset within
sourceBufferthe command copies from. In macOS,sourceOffsetneeds to be a multiple of4, but can be any value in iOS and tvOS. - destinationBuffer:
The destination buffer for the copy operation.
- destinationOffset:
A byte offset within
destinationBufferthe command copies to. In macOS,destinationOffsetneeds to be a multiple of4, but can be any value in iOS and tvOS. - size:
The number of bytes the command copies from
sourceBuffertodestinationBuffer. In macOS,sizeneeds to be a multiple of4, but can be any value in iOS and tvOS.
Mentioned in
Discussion
You can pass the same buffer to the sourceBuffer and destinationBuffer parameters if size is less than the distance between sourceOffset and destinationOffset.