setBuffers(_:offsets:attributeStrides:range:)
Binds multiple buffers with data in stride to the buffer argument table at once, allowing compute kernels to access their data on the GPU.
Declaration
func setBuffers(_ buffers: [(any MTLBuffer)?], offsets: [Int], attributeStrides: [Int], range: Range<Int>)Parameters
- buffers:
The Mtlbuffer instances to bind to the buffer argument table.
- offsets:
An array of offsets, each of which specifies where the data begins, in bytes, from the start of its corresponding buffer.
- attributeStrides:
An array of strides, each of which specifies the number of bytes between the start of one element and the start of the next for its corresponding buffer.
- range:
The argument table indicies to bind each of the
buffersto, in the order they appear.
Discussion
For buffers binding to an argument using the device address space, align the offset to the data type’s size. The maximum size for an offset is 16 bytes.
For buffers in the constant address space, the minimum alignment depends on the hardware running your app. See the Metal feature set tables (PDF) for information on each Apple GPU family.
Rebinding an already bound buffer causes a Metal error.