From the ARB_shader_storage_buffer_object spec:

"In a shader storage block, the last member may be declared without an explicit
 size.  In this case, the effective array size is inferred at run-time from
 the size of the data store backing the interface block.  Such unsized
 arrays may be indexed with general integer expressions, but may not be
 passed as an argument to a function or indexed with a negative constant

dEQP tests that shaders with SSBOs that declare field members after an
unsized array declaration fail to compile.

Fixes the remaining subcase of the following dEQP tests:

 src/compiler/glsl/ast_to_hir.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index c3c8cef..2d9d92d 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -6645,6 +6645,7 @@ ast_process_struct_or_iface_block_members(exec_list 
    bool first_member = true;
    bool first_member_has_explicit_location = false;
+   bool has_unsized_array = false;
    unsigned i = 0;
    foreach_list_typed (ast_declarator_list, decl_list, link, declarations) {
@@ -6840,6 +6841,13 @@ ast_process_struct_or_iface_block_members(exec_list 
          const struct glsl_type *field_type =
             process_array_type(&loc, decl_type, decl->array_specifier, state);
+         if (has_unsized_array && var_mode == ir_var_shader_storage)
+            _mesa_glsl_error(&loc, state, "SSBO member declared "
+                             "after unsized array.");
+         else
+            has_unsized_array = field_type->is_unsized_array();
          validate_array_dimensions(field_type, state, &loc);
          fields[i].type = field_type;
          fields[i].name = decl->identifier;

mesa-dev mailing list

Reply via email to