Some builtins have both 3D and 1D variants, e.g., local_invocation_id and local_invocation_index. The latter is a linearized function of the former. Both are useful. They relieve the programmer from manually computing one from the other (usually 3D -> 1D), a computation that is unfortunately (in my experience) error-prone.
Two builtins have 3D but not 1D variants. I would like to see two 1D variants added as builtins:
global_invocation_index (from global_invocation_id). I should add here that from a teaching perspective, this is a very useful builtin as it allows a simpler WGSL 101 kernel (“one million threads each fetch one u32, add 1 to it, and write it back”). (But of course we shouldn’t add builtins for strictly pedagogical reasons.)
workgroup_index (from workgroup_id)
I expect these could be easily polyfilled, correctly, once, by the compiler team, and not many times, sometimes incorrectly, by WGSL programmers. :)
Some builtins have both 3D and 1D variants, e.g.,
local_invocation_idandlocal_invocation_index. The latter is a linearized function of the former. Both are useful. They relieve the programmer from manually computing one from the other (usually 3D -> 1D), a computation that is unfortunately (in my experience) error-prone.Two builtins have 3D but not 1D variants. I would like to see two 1D variants added as builtins:
global_invocation_index(fromglobal_invocation_id). I should add here that from a teaching perspective, this is a very useful builtin as it allows a simpler WGSL 101 kernel (“one million threads each fetch one u32, add 1 to it, and write it back”). (But of course we shouldn’t add builtins for strictly pedagogical reasons.)workgroup_index(fromworkgroup_id)I expect these could be easily polyfilled, correctly, once, by the compiler team, and not many times, sometimes incorrectly, by WGSL programmers. :)