Contents

concurrentDispatchThreadgroups(_:threadsPerThreadgroup:)

Encodes a compute command using a grid aligned to threadgroup boundaries.

Declaration

func concurrentDispatchThreadgroups(_ threadgroupsPerGrid: MTLSize, threadsPerThreadgroup: MTLSize)

Parameters

  • threadgroupsPerGrid:

    The number of threadgroups in the grid, in each dimension.

  • threadsPerThreadgroup:

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

Discussion

The command generated by this method is equivalent to calling dispatchThreadgroups(_:threadsPerThreadgroup:).

Compute commands encoded into an indirect command buffer don’t automatically serialize access to resources with other commands in the indirect command buffer. Use barriers to serialize access to resources within a range of commands. See setBarrier().

When you execute the commands in an indirect command buffer, the dispatchType property of the compute command encoder determines whether the compute command encoder adds additional barriers. If dispatchType is MTLDispatchType.serial, the compute command encoder adds a barrier before and after the range of commands. If dispatchType is MTLDispatchType.concurrent, then the compute command encoder does nothing, and you are responsible for synchronizing access to resources.

See Also

Encoding a compute command