nir_to_tgsi: Force the TXQ LOD argument to be scalar.
authorEmma Anholt <emma@anholt.net>
Mon, 2 Aug 2021 23:17:08 +0000 (16:17 -0700)
committerMarge Bot <eric+marge@anholt.net>
Wed, 6 Oct 2021 03:44:17 +0000 (03:44 +0000)
Otherwise, older virglrenderer fails all the texturesize tests.

Acked-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12800>

src/gallium/auxiliary/nir/nir_to_tgsi.c

index 01bf035..50b55a6 100644 (file)
@@ -2157,7 +2157,13 @@ ntt_emit_texture(struct ntt_compile *c, nir_tex_instr *instr)
    ntt_push_tex_arg(c, instr, nir_tex_src_backend2, &s);
 
    /* non-coord arg for TXQ */
-   ntt_push_tex_arg(c, instr, nir_tex_src_lod, &s);
+   if (tex_opcode == TGSI_OPCODE_TXQ) {
+      ntt_push_tex_arg(c, instr, nir_tex_src_lod, &s);
+      /* virglrenderer mistakenly looks at .w instead of .x, so make sure it's
+       * scalar
+       */
+      s.srcs[s.i - 1] = ureg_scalar(s.srcs[s.i - 1], 0);
+   }
 
    if (s.i > 1) {
       if (tex_opcode == TGSI_OPCODE_TEX)