Mesa (main): nir_to_tgsi: Lower FS input array indexing since we don't declare input arrays.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 21 19:24:30 UTC 2022


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

Author: Emma Anholt <emma at anholt.net>
Date:   Fri Apr  8 12:24:22 2022 -0700

nir_to_tgsi: Lower FS input array indexing since we don't declare input arrays.

We can't declare input arrays because mesa/st lowers NIR VS output
declarations to elements no matter what, and virgl has depended on
matching array sizes of declarations between producers and consumers.  So,
we have to lower it away (which is fine because hardware drivers will
generally be lowering anyway).

Reviewed-by: Gert Wollny <gert.wollny at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13295>

---

 src/gallium/auxiliary/nir/nir_to_tgsi.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi.c b/src/gallium/auxiliary/nir/nir_to_tgsi.c
index d0ca7f5fc86..8ddbf8a250c 100644
--- a/src/gallium/auxiliary/nir/nir_to_tgsi.c
+++ b/src/gallium/auxiliary/nir/nir_to_tgsi.c
@@ -3743,6 +3743,18 @@ const void *nir_to_tgsi_options(struct nir_shader *s,
 
    ntt_fix_nir_options(screen, s, options);
 
+   /* Lower array indexing on FS inputs.  Since we don't set
+    * ureg->supports_any_inout_decl_range, the TGSI input decls will be split to
+    * elements by ureg, and so dynamically indexing them would be invalid.
+    * Ideally we would set that ureg flag based on
+    * PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE, but can't due to mesa/st
+    * splitting NIR VS outputs to elements even if the FS doesn't get the
+    * corresponding splitting, and virgl depends on TGSI across link boundaries
+    * having matching declarations.
+    */
+   if (s->info.stage == MESA_SHADER_FRAGMENT)
+      NIR_PASS_V(s, nir_lower_indirect_derefs, nir_var_shader_in, UINT32_MAX);
+
    NIR_PASS_V(s, nir_lower_io, nir_var_shader_in | nir_var_shader_out,
               type_size, (nir_lower_io_options)0);
    NIR_PASS_V(s, nir_lower_regs_to_ssa);



More information about the mesa-commit mailing list