ac/nir: When task->mesh dispatch Y or Z are 0, also set X to 0.
authorTimur Kristóf <timur.kristof@gmail.com>
Thu, 30 Mar 2023 20:41:45 +0000 (22:41 +0200)
committerMarge Bot <emma+marge@anholt.net>
Sat, 1 Apr 2023 14:46:50 +0000 (14:46 +0000)
AMD recommends doing this to speed up the CP when it processes
the draw ring entries. LLPC also does this.

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/22211>

src/amd/common/ac_nir_lower_taskmesh_io_to_mem.c

index e88088f..590232a 100644 (file)
@@ -186,6 +186,11 @@ lower_task_launch_mesh_workgroups(nir_builder *b,
       nir_ssa_def *y = nir_channel(b, dimensions, 1);
       nir_ssa_def *z = nir_channel(b, dimensions, 2);
 
+      /* When either Y or Z are 0, also set X to 0.
+       * Not necessary, but speeds up the job of the CP.
+       */
+      x = nir_bcsel(b, nir_ieq_imm(b, nir_ior(b, y, z), 0), nir_imm_int(b, 0), x);
+
       /* Dispatch dimensions of mesh shader workgroups. */
       task_write_draw_ring(b, nir_vec3(b, x, y, z), 0, s);
       /* Prevent the two stores from being reordered. */