turnip: Skip emitting empty CP_COND_REG_EXEC.
authorEmma Anholt <emma@anholt.net>
Tue, 30 Aug 2022 22:30:27 +0000 (15:30 -0700)
committerMarge Bot <emma+marge@anholt.net>
Wed, 16 Aug 2023 16:02:51 +0000 (16:02 +0000)
If we ended up emitting no code to be conditionally run, then drop the
whole conditional exec packet.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20994>

src/freedreno/vulkan/tu_cs.h

index 2a4a298..3d6a503 100644 (file)
@@ -471,8 +471,13 @@ tu_cond_exec_end(struct tu_cs *cs)
 
    cs->cond_flags[cs->cond_stack_depth] = 0;
    /* Subtract one here to account for the DWORD field itself. */
-   *cs->cond_dwords[cs->cond_stack_depth] =
-      cs->cur - cs->cond_dwords[cs->cond_stack_depth] - 1;
+   uint32_t cond_len = cs->cur - cs->cond_dwords[cs->cond_stack_depth] - 1;
+   if (cond_len) {
+      *cs->cond_dwords[cs->cond_stack_depth] = cond_len;
+   } else {
+      /* rewind the CS to drop the empty cond reg packet. */
+      cs->cur = cs->cur - 3;
+   }
 }
 
 /* Temporary struct for tracking a register state to be written, used by