aco: Skip waitcnt insertion in the discard early exit block
authorVitaliy Triang3l Kuzmin <triang3l@yandex.ru>
Sat, 15 Apr 2023 18:45:12 +0000 (21:45 +0300)
committerMarge Bot <emma+marge@anholt.net>
Mon, 26 Jun 2023 15:58:04 +0000 (15:58 +0000)
Waits are needed for early exits from inside a Primitive Ordered Pixel
Shading ordered section, but that code doesn't insert them reliably anyway
because it doesn't obtain the counters for the exact locations of the
jumps, which may be anywhere inside the predecessor blocks.

Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Signed-off-by: Vitaliy Triang3l Kuzmin <triang3l@yandex.ru>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22250>

src/amd/compiler/aco_insert_waitcnt.cpp

index 985a8e1..64fdd87 100644 (file)
@@ -1037,6 +1037,15 @@ insert_wait_states(Program* program)
 
    for (unsigned i = 0; i < program->blocks.size();) {
       Block& current = program->blocks[i++];
+
+      if (current.kind & block_kind_discard_early_exit) {
+         /* Because the jump to the discard early exit block may happen anywhere in a block, it's
+          * not possible to join it with its predecessors this way.
+          * We emit all required waits when emitting the discard block.
+          */
+         continue;
+      }
+
       wait_ctx ctx = in_ctx[current.index];
 
       if (current.kind & block_kind_loop_header) {