Mesa (main): nir: Use proper macro to set bits of variable correctly

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Feb 10 18:14:46 UTC 2022


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

Author: Otavio Pontes <otavio.pontes at intel.com>
Date:   Thu Feb  3 15:38:34 2022 -0800

nir: Use proper macro to set bits of variable correctly

When slots is 64 only the first bit was being set, instead of setting
all 64 bits of the variable, so for that case the function
get_variable_io_mask() always returned 0.

This behaviour caused variables that are being used both on producer and
consumer to be considered unused and thus being removed on
nir_remove_unused_io_vars().

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14955>

---

 src/compiler/nir/nir_linking_helpers.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_linking_helpers.c b/src/compiler/nir/nir_linking_helpers.c
index 872eb205692..9a60e45d47c 100644
--- a/src/compiler/nir/nir_linking_helpers.c
+++ b/src/compiler/nir/nir_linking_helpers.c
@@ -47,6 +47,7 @@ get_variable_io_mask(nir_variable *var, gl_shader_stage stage)
    assert(var->data.mode == nir_var_shader_in ||
           var->data.mode == nir_var_shader_out);
    assert(var->data.location >= 0);
+   assert(location < 64);
 
    const struct glsl_type *type = var->type;
    if (nir_is_arrayed_io(var, stage) || var->data.per_view) {
@@ -55,7 +56,7 @@ get_variable_io_mask(nir_variable *var, gl_shader_stage stage)
    }
 
    unsigned slots = glsl_count_attribute_slots(type, false);
-   return ((1ull << slots) - 1) << location;
+   return BITFIELD64_MASK(slots) << location;
 }
 
 static bool



More information about the mesa-commit mailing list