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

Author: Caio Oliveira <[email protected]>
Date:   Fri Feb 17 22:36:11 2023 -0800

glsl: Account for unsized arrays in NIR linker

Follow the same approach as the pre-NIR linker.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5891
Reviewed-by: Alejandro PiƱeiro <[email protected]>
Acked-by: Timothy Arceri <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21401>

---

 src/compiler/glsl/gl_nir_link_uniform_blocks.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/compiler/glsl/gl_nir_link_uniform_blocks.c 
b/src/compiler/glsl/gl_nir_link_uniform_blocks.c
index e18100e85ff..86c769e511f 100644
--- a/src/compiler/glsl/gl_nir_link_uniform_blocks.c
+++ b/src/compiler/glsl/gl_nir_link_uniform_blocks.c
@@ -326,7 +326,7 @@ iterate_type_count_variables(const struct glsl_type *type,
       else
          field_type = glsl_get_array_element(type);
 
-      if (glsl_type_is_leaf(field_type))
+      if (glsl_type_is_leaf(field_type) || 
glsl_type_is_unsized_array(field_type))
          (*num_variables)++;
       else
          iterate_type_count_variables(field_type, num_variables);
@@ -374,17 +374,13 @@ iterate_type_fill_variables(const struct glsl_type *type,
                             struct gl_shader_program *prog,
                             struct gl_uniform_block *block)
 {
-   unsigned length = glsl_get_length(type);
-   if (length == 0)
-      return;
-
    unsigned struct_base_offset;
 
    bool struct_or_ifc = glsl_type_is_struct_or_ifc(type);
    if (struct_or_ifc)
       struct_base_offset = *offset;
 
-   for (unsigned i = 0; i < length; i++) {
+   for (unsigned i = 0; i < glsl_get_length(type); i++) {
       const struct glsl_type *field_type;
 
       if (struct_or_ifc) {
@@ -395,7 +391,7 @@ iterate_type_fill_variables(const struct glsl_type *type,
          field_type = glsl_get_array_element(type);
       }
 
-      if (glsl_type_is_leaf(field_type)) {
+      if (glsl_type_is_leaf(field_type) || 
glsl_type_is_unsized_array(field_type)) {
          fill_individual_variable(field_type, variables, variable_index,
                                   offset, prog, block);
       } else {

Reply via email to