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

Author: Faith Ekstrand <faith.ekstr...@collabora.com>
Date:   Fri Apr 28 11:29:51 2023 -0500

vc4: Stop assuming glsl_get_length() returns 0 for vectors

Instead, check if it's a vector or scalar and use 1 explicitly.  In FS
output case where we were only using it assert we don't have any arrays,
assert that directly.

Reviewed-by: Alyssa Rosenzweig <aly...@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22580>

---

 src/gallium/drivers/vc4/vc4_program.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/vc4/vc4_program.c 
b/src/gallium/drivers/vc4/vc4_program.c
index 46f16e445c5..611cf3e100e 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -1565,11 +1565,9 @@ ntq_setup_inputs(struct vc4_compile *c)
 
         for (unsigned i = 0; i < num_entries; i++) {
                 nir_variable *var = vars[i];
-                unsigned array_len = MAX2(glsl_get_length(var->type), 1);
+                assert(glsl_type_is_vector_or_scalar(var->type));
                 unsigned loc = var->data.driver_location;
 
-                assert(array_len == 1);
-                (void)array_len;
                 resize_qreg_array(c, &c->inputs, &c->inputs_array_size,
                                   (loc + 1) * 4);
 
@@ -1593,12 +1591,9 @@ static void
 ntq_setup_outputs(struct vc4_compile *c)
 {
         nir_foreach_shader_out_variable(var, c->s) {
-                unsigned array_len = MAX2(glsl_get_length(var->type), 1);
+                assert(glsl_type_is_vector_or_scalar(var->type));
                 unsigned loc = var->data.driver_location * 4;
 
-                assert(array_len == 1);
-                (void)array_len;
-
                 for (int i = 0; i < 4; i++)
                         add_output(c, loc + i, var->data.location, i);
 
@@ -2428,7 +2423,9 @@ precompile_all_fs_inputs(nir_shader *s,
         /* Assume all VS outputs will actually be used by the FS and output
          * them (the two sides have to match exactly) */
         nir_foreach_shader_out_variable(var, s) {
-                const int array_len = MAX2(glsl_get_length(var->type), 1);
+                const int array_len =
+                        glsl_type_is_vector_or_scalar(var->type) ?
+                        1 : glsl_get_length(var->type);
                 for (int j = 0; j < array_len; j++) {
                         const int slot = var->data.location + j;
                         const int num_components =

Reply via email to