Contents

setBytes(_:length:attributeStride:index:)

Copies data with a given stride directly to the GPU to populate an entry in the buffer argument table.

Declaration

func setBytes(_ bytes: UnsafeRawPointer, length: Int, attributeStride stride: Int, index: Int)

Parameters

  • bytes:

    A pointer to the memory where the data to copy starts.

  • length:

    The number of bytes to copy.

  • stride:

    The number of bytes between the start of one element and the start of the next.

  • index:

    The index the data binds to in the argument table.

Discussion

This method allows Metal to copy data directly onto the GPU, rather than creating a new MTLBuffer instance and binding it. Binding data directly can improve performance, especially when making many small allocations.

See Also

Binding raw bytes