Mesa (main): nir: Fix flat new_var assignment in create_new_io_vars()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 10 09:06:47 UTC 2022


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

Author: Boris Brezillon <boris.brezillon at collabora.com>
Date:   Wed Feb 16 16:55:36 2022 +0100

nir: Fix flat new_var assignment in create_new_io_vars()

If the type is not an array, glsl_get_length() returns 0 and we don't
update the new_vars[]/flat_vars[] entries.

Fixes: bcd14756eec ("nir/lower_io_to_vector: add flat mode")
Reviewed-by: Jason Ekstrand <jason.ekstrand at collabora.com>
Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16960>

---

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

diff --git a/src/compiler/nir/nir_lower_io_to_vector.c b/src/compiler/nir/nir_lower_io_to_vector.c
index e17f6ddb158..27913b507e9 100644
--- a/src/compiler/nir/nir_lower_io_to_vector.c
+++ b/src/compiler/nir/nir_lower_io_to_vector.c
@@ -304,7 +304,8 @@ create_new_io_vars(nir_shader *shader, nir_variable_mode mode,
             var->type = flat_type;
 
          nir_shader_add_variable(shader, var);
-         for (unsigned i = 0; i < glsl_get_length(flat_type); i++) {
+         unsigned num_slots = MAX2(glsl_get_length(flat_type), 1);
+         for (unsigned i = 0; i < num_slots; i++) {
             for (unsigned j = 0; j < 4; j++)
                new_vars[loc + i][j] = var;
             flat_vars[loc + i] = true;



More information about the mesa-commit mailing list