Mesa (main): nir_to_tgsi: Add a workaround for virglrenderer TG4.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Apr 19 20:44:23 UTC 2022


Module: Mesa
Branch: main
Commit: 4850dbb3f93f4bf9b886921be14722b5e9c581df
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4850dbb3f93f4bf9b886921be14722b5e9c581df

Author: Emma Anholt <emma at anholt.net>
Date:   Mon Feb 14 11:57:37 2022 -0800

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 at itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16043>

---

 src/gallium/auxiliary/nir/nir_to_tgsi.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi.c b/src/gallium/auxiliary/nir/nir_to_tgsi.c
index ffbaaae4be5..50e53e4a350 100644
--- a/src/gallium/auxiliary/nir/nir_to_tgsi.c
+++ b/src/gallium/auxiliary/nir/nir_to_tgsi.c
@@ -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



More information about the mesa-commit mailing list