Encodes a compute command using a grid aligned to threadgroup boundaries.
- iOS 8.0+
- macOS 10.11+
- Mac Catalyst 13.0+
- tvOS 9.0+
The number of threadgroups in the grid, in each dimension.
The number of threads in one threadgroup, in each dimension.
Metal calculates the number of threads in a grid by multiplying the size of a threadgroup (
threads) by the number of threadgroups (
If the size of your data doesn't match the size of the grid, you may have to perform boundary checks in your compute function. See Calculating Threadgroup and Grid Sizes for an example.
When the compute command is encoded, any necessary references to parameters or resources previously set on the encoder are recorded as part of the command. After encoding a command, you can safely change the encoding state to set up parameters needed to encode other commands.