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