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 <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8373>
This commit is contained in:
Eric Anholt 2021-01-06 16:05:59 -08:00 committed by Marge Bot
parent 470d806cc2
commit 111e4be698
1 changed files with 4 additions and 1 deletions

View File

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