Instance Method

copy(from:sourceOffset:to:destinationOffset:size:)

Encodes a command to copy data from a source buffer into a destination buffer.

Required.

Declaration

func copy(from sourceBuffer: MTLBuffer, sourceOffset: Int, to destinationBuffer: MTLBuffer, destinationOffset: Int, size: Int)

Parameters

sourceBuffer

The source buffer for the copy operation.

sourceOffset

The byte location in the source buffer where the copying starts. The value must be a multiple of 4 bytes in macOS, and 1 byte in iOS and tvOS.

destinationBuffer

The destination buffer for the copy operation.

destinationOffset

The byte location in the destination buffer where the copying starts. The value must be a multiple of 4 bytes in macOS, and 1 byte in iOS and tvOS.

size

The number of bytes to copy. The value must be a multiple of 4 bytes in macOS, and 1 byte in iOS and tvOS.

Discussion

Use sourceOffset to start copying data from somewhere within the source buffer, and use destinationOffset to start copying data to somewhere within the destination buffer.

If the source and destination are the same buffer, and the range of copied data overlaps, the results are undefined.