From e0c6ad1ce5cefd4a68d5d0c538fbed95fb4e4f95 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Fri, 17 Feb 2023 22:36:11 -0800 Subject: [PATCH] glsl: Account for unsized arrays in NIR linker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow the same approach as the pre-NIR linker. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5891 Reviewed-by: Alejandro PiƱeiro Acked-by: Timothy Arceri Part-of: --- 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 {