Mesa (master): st/mesa: handle lowered IO in st_nir_assign_vs_in_locations

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 24 19:25:32 UTC 2020


Module: Mesa
Branch: master
Commit: 2519472845a7eccd9ff2bfc8a3061ec2ae00de06
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2519472845a7eccd9ff2bfc8a3061ec2ae00de06

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Fri Aug 14 01:32:00 2020 -0400

st/mesa: handle lowered IO in st_nir_assign_vs_in_locations

There are piglit failures without this.

Reviewed-by: Eric Anholt <eric at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6442>

---

 src/mesa/state_tracker/st_glsl_to_nir.cpp | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index b4d78c86d6c..442f1ffeeb8 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -105,9 +105,36 @@ st_nir_assign_vs_in_locations(struct nir_shader *nir)
    if (nir->info.stage != MESA_SHADER_VERTEX)
       return;
 
+   nir->num_inputs = util_bitcount64(nir->info.inputs_read);
+
+   if (nir->info.io_lowered) {
+      /* Adjust the locations in load_input intrinsics. */
+      nir_foreach_function(f, nir) {
+         if (f->impl) {
+            nir_foreach_block(block, f->impl) {
+               nir_foreach_instr_safe(instr, block) {
+                  if (instr->type == nir_instr_type_intrinsic) {
+                     nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
+
+                     if (intrin->intrinsic == nir_intrinsic_load_input) {
+                        unsigned base = nir_intrinsic_base(intrin);
+                        unsigned loc = nir_intrinsic_io_semantics(intrin).location;
+
+                        assert(nir->info.inputs_read & BITFIELD64_BIT(loc));
+                        base = util_bitcount64(nir->info.inputs_read &
+                                               BITFIELD64_MASK(loc));
+                        nir_intrinsic_set_base(intrin, base);
+                     }
+                  }
+               }
+            }
+         }
+      }
+      return;
+   }
+
    bool removed_inputs = false;
 
-   nir->num_inputs = util_bitcount64(nir->info.inputs_read);
    nir_foreach_shader_in_variable_safe(var, nir) {
       /* NIR already assigns dual-slot inputs to two locations so all we have
        * to do is compact everything down.



More information about the mesa-commit mailing list