Mesa (main): nir_to_tgsi: Declare immediates as float on non-native-ints hardware.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jul 7 23:56:25 UTC 2021


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

Author: Emma Anholt <emma at anholt.net>
Date:   Tue Jul  6 12:29:58 2021 -0700

nir_to_tgsi: Declare immediates as float on non-native-ints hardware.

Makes the values more legible on i915g, and may keep us from tripping
asserts on nouveau's non-native-integer HW.

Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11744>

---

 src/gallium/auxiliary/nir/nir_to_tgsi.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi.c b/src/gallium/auxiliary/nir/nir_to_tgsi.c
index 9bc9e575cb2..fbeadd935bc 100644
--- a/src/gallium/auxiliary/nir/nir_to_tgsi.c
+++ b/src/gallium/auxiliary/nir/nir_to_tgsi.c
@@ -460,22 +460,32 @@ ntt_setup_registers(struct ntt_compile *c, struct exec_list *list)
 static struct ureg_src
 ntt_get_load_const_src(struct ntt_compile *c, nir_load_const_instr *instr)
 {
-   uint32_t values[4];
    int num_components = instr->def.num_components;
 
-   if (instr->def.bit_size == 32) {
+   if (!c->native_integers) {
+      float values[4];
+      assert(instr->def.bit_size == 32);
       for (int i = 0; i < num_components; i++)
-         values[i] = instr->value[i].u32;
+         values[i] = uif(instr->value[i].u32);
+
+      return ureg_DECL_immediate(c->ureg, values, num_components);
    } else {
-      assert(num_components <= 2);
-      for (int i = 0; i < num_components; i++) {
-         values[i * 2 + 0] = instr->value[i].u64 & 0xffffffff;
-         values[i * 2 + 1] = instr->value[i].u64 >> 32;
+      uint32_t values[4];
+
+      if (instr->def.bit_size == 32) {
+         for (int i = 0; i < num_components; i++)
+            values[i] = instr->value[i].u32;
+      } else {
+         assert(num_components <= 2);
+         for (int i = 0; i < num_components; i++) {
+            values[i * 2 + 0] = instr->value[i].u64 & 0xffffffff;
+            values[i * 2 + 1] = instr->value[i].u64 >> 32;
+         }
+         num_components *= 2;
       }
-      num_components *= 2;
-   }
 
-   return ureg_DECL_immediate_uint(c->ureg, values, num_components);
+      return ureg_DECL_immediate_uint(c->ureg, values, num_components);
+   }
 }
 
 static struct ureg_src



More information about the mesa-commit mailing list