Mesa (staging/20.0): nir: fix lowering to scratch with boolean access

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue May 26 22:30:36 UTC 2020


Module: Mesa
Branch: staging/20.0
Commit: e1e05dc4632e6074d4e7cf45b2578418f8e1fedc
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e1e05dc4632e6074d4e7cf45b2578418f8e1fedc

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Tue May 26 18:08:17 2020 +0100

nir: fix lowering to scratch with boolean access

Backport of 8e2009c4481434f1b97713d8a0ec193fdccb65a6 for 20.0

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5215>

---

 src/compiler/nir/nir_lower_scratch.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/compiler/nir/nir_lower_scratch.c b/src/compiler/nir/nir_lower_scratch.c
index aacc2ddca08..efc20c76f25 100644
--- a/src/compiler/nir/nir_lower_scratch.c
+++ b/src/compiler/nir/nir_lower_scratch.c
@@ -57,24 +57,25 @@ lower_load_store(nir_builder *b,
       load->num_components = intrin->num_components;
       load->src[0] = nir_src_for_ssa(offset);
       nir_intrinsic_set_align(load, align, 0);
+      unsigned bit_size = intrin->dest.ssa.bit_size;
       nir_ssa_dest_init(&load->instr, &load->dest,
                         intrin->dest.ssa.num_components,
-                        intrin->dest.ssa.bit_size, NULL);
+                        bit_size == 1 ? 32 : bit_size, NULL);
       nir_builder_instr_insert(b, &load->instr);
 
       nir_ssa_def *value = &load->dest.ssa;
-      if (glsl_type_is_boolean(deref->type))
-         value = nir_b2i32(b, value);
+      if (bit_size == 1)
+         value = nir_i2b1(b, value);
 
       nir_ssa_def_rewrite_uses(&intrin->dest.ssa,
-                               nir_src_for_ssa(&load->dest.ssa));
+                               nir_src_for_ssa(value));
    } else {
       assert(intrin->intrinsic == nir_intrinsic_store_deref);
 
       assert(intrin->src[1].is_ssa);
       nir_ssa_def *value = intrin->src[1].ssa;
-      if (glsl_type_is_boolean(deref->type))
-         value = nir_i2b(b, value);
+      if (value->bit_size == 1)
+         value = nir_b2i32(b, value);
 
       nir_intrinsic_instr *store =
          nir_intrinsic_instr_create(b->shader, nir_intrinsic_store_scratch);



More information about the mesa-commit mailing list