nir_to_tgsi: Add a workaround for virglrenderer TG4.

I've tried to keep virglrenderer workarounds out of ntt, but this one
would be bothersome to do with tgsi_translate and TG4 is pretty low-stakes
for NTT consumers.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16043>
This commit is contained in:
Emma Anholt 2022-02-14 11:57:37 -08:00 committed by Marge Bot
parent a3a43e5fa8
commit 4850dbb3f9

View file

@ -2580,7 +2580,23 @@ ntt_push_tex_arg(struct ntt_compile *c,
if (tex_src < 0)
return;
s->srcs[s->i++] = ntt_get_src(c, instr->src[tex_src].src);
nir_src *src = &instr->src[tex_src].src;
/* virglrenderer workaround that's hard to do in tgsi_translate: Make sure
* that TG4's immediate offset arg is float-typed.
*/
if (instr->op == nir_texop_tg4 && tex_src_type == nir_tex_src_backend2 &&
nir_src_is_const(*src)) {
nir_const_value *consts = nir_src_as_const_value(*src);
s->srcs[s->i++] = ureg_imm4f(c->ureg,
consts[0].f32,
consts[1].f32,
consts[2].f32,
consts[3].f32);
return;
}
s->srcs[s->i++] = ntt_get_src(c, *src);
}
static void