Contents

dispatchThreadgroups(indirectBuffer:indirectBufferOffset:threadsPerThreadgroup:)

Encodes a dispatch call for a compute pass, using an indirect buffer that defines the size of a grid that aligns to threadgroup boundaries.

Declaration

func dispatchThreadgroups(indirectBuffer: any MTLBuffer, indirectBufferOffset: Int, threadsPerThreadgroup: MTLSize)

Parameters

  • indirectBuffer:

    An Mtlbuffer instance providing compute parameters. Lay out the data in this buffer as described in the Mtldispatchthreadgroupsindirectarguments structure.

  • indirectBufferOffset:

    Where the data begins, in bytes, from the start of the buffer. This value needs to be a multiple of 4.

  • threadsPerThreadgroup:

    The number of threads in one threadgroup, in each dimension.

Discussion

The GPU fetches parameters from the indirect buffer just before the thread grid starts. This process lets the compute function run based on GPU feedback, without latency from data transfer between the CPU and the GPU.

See Also

Dispatching from indirect command buffers