nir,anv,intel/compiler: optimizations for gl_WorkGroupID lowering in mesh shaders

Merged Marcin Ślusarz requested to merge mslusarz/mesa:mesh-wgs into main

Use constant arguments of EmitMeshTasksEXT to:

  • lower some dimensions of NumWorkGroups to constants
  • simplify lowering of WorkGroupID to WorkGroupIndex
nir: extract try_lower_id_to_index_short
nir: use wg id to wg idx shortcut if two dims of num_workgroups are 1
nir: use constant components of num_workgroups in wg id to wg idx lowering
nir: lower num_workgroups to constants
intel/compiler: pass num_workgroups from task to mesh shaders

Avoid expensive computation of WorkGroupId from WorkGroupIndex if NumWorkgroups[1..2] are 1, at runtime.

nir: add cheap shortcut for wg id to wg idx lowering
anv,intel/compiler: enable shortcut in wg id to wg idx lowering on >= gfx12.5

Simplification, without any impact on performance.

intel/compiler: simplify reading of gl_NumWorkGroups in task/mesh
Edited by Marcin Ślusarz

Merge request reports