From 111e4be698a1940b05c1a9d0d8b269b96be75e1d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 6 Jan 2021 16:05:59 -0800 Subject: [PATCH] gallium/ntt: Work around virglrenderer UIF handling bug. Until just recently ("vrend: Fix TGSI UIF/IF behavior"), virgl does "if (any(bvec4(src0)))" instead of "if (src0.x != 0)", despite the tgsi.rst documentation and tgsi_exec agreeing on the second form. It's harmless to work around it, since apparently NTT was the only one to not have scalar swizzled the if condition. Reviewed-by: Gert Wollny Part-of: --- src/gallium/auxiliary/nir/nir_to_tgsi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi.c b/src/gallium/auxiliary/nir/nir_to_tgsi.c index 414bac858a2..88ba7d4bec2 100644 --- a/src/gallium/auxiliary/nir/nir_to_tgsi.c +++ b/src/gallium/auxiliary/nir/nir_to_tgsi.c @@ -2137,10 +2137,13 @@ ntt_emit_block(struct ntt_compile *c, nir_block *block) /* Set up the if condition for ntt_emit_if(), which we have to do before * freeing up the temps (the "if" is treated as inside the block for liveness * purposes, despite not being an instruction) + * + * Note that, while IF and UIF are supposed to look at only .x, virglrenderer + * looks at all of .xyzw. No harm in working around the bug. */ nir_if *nif = nir_block_get_following_if(block); if (nif) - c->if_cond = ntt_get_src(c, nif->condition); + c->if_cond = ureg_scalar(ntt_get_src(c, nif->condition), TGSI_SWIZZLE_X); /* Free up any SSA temps that are unused at the end of the block. */ unsigned index;