ac/nir/taskmesh: Preserve workgroup ID Y and Z when applying firstTask.
authorTimur Kristóf <timur.kristof@gmail.com>
Mon, 28 Feb 2022 13:22:09 +0000 (14:22 +0100)
committerMarge Bot <emma+marge@anholt.net>
Wed, 15 Jun 2022 18:28:58 +0000 (18:28 +0000)
NV_mesh_shader workgroups are only 1 dimensional, so it's OK to
only add firstTask to the X dimension.
However, let's keep the Y and Z dimensions so this doesn't mess up
the workgroup ID for future 3 dimensional task shader dispatches.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17023>

src/amd/common/ac_nir_lower_taskmesh_io_to_mem.c

index 5bcb97a..fa4f53b 100644 (file)
@@ -124,10 +124,12 @@ ac_nir_apply_first_task_to_task_shader(nir_shader *shader)
    nir_pop_if(b, if_stride);
    first_task = nir_if_phi(b, first_task, zero);
 
-   /* NV_mesh_shader workgroups are 1 dimensional so we only care about X here. */
+   /* NV_mesh_shader workgroups are 1 dimensional.
+    * Apply firstTask to the X dimension, but leave Y and Z intact.
+    */
    nir_ssa_def *hw_workgroup_id = nir_load_workgroup_id(b, 32);
    nir_ssa_def *api_workgroup_id_x = nir_iadd(b, nir_channel(b, hw_workgroup_id, 0), first_task);
-   nir_ssa_def *api_workgroup_id = nir_vec3(b, api_workgroup_id_x, zero, zero);
+   nir_ssa_def *api_workgroup_id = nir_vector_insert_imm(b, hw_workgroup_id, api_workgroup_id_x, 0);
 
    add_first_task_to_workgroup_id_state state = {
       .hw_workgroup_id = hw_workgroup_id,