glsl: Disallow unsized array of atomic_uint
authorIago Toral Quiroga <itoral@igalia.com>
Mon, 11 Sep 2017 12:19:41 +0000 (14:19 +0200)
committerIago Toral Quiroga <itoral@igalia.com>
Tue, 12 Sep 2017 07:16:05 +0000 (09:16 +0200)
This was a bugfix to the spec addressed in OpenGL 4.5 (revision
7 of the spec) and there is a CTS test to check this.

Fixes:
KHR-GL45.shader_atomic_counters.negative-unsized-array

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/compiler/glsl/ast_to_hir.cpp

index 98d2f94e12991b7f68f4c9068f6d79e341ae6dd7..9ded2cbda7f8948fd58450698578a05e634117f4 100644 (file)
@@ -5542,6 +5542,17 @@ ast_declarator_list::hir(exec_list *instructions,
                              "GLSL ES");
       }
 
+      /* Section 4.4.6.1 Atomic Counter Layout Qualifiers of the GLSL 4.60 spec:
+       *
+       *    "It is a compile-time error to declare an unsized array of
+       *     atomic_uint"
+       */
+      if (var->type->is_unsized_array() &&
+          var->type->without_array()->base_type == GLSL_TYPE_ATOMIC_UINT) {
+         _mesa_glsl_error(& loc, state,
+                          "Unsized array of atomic_uint is not allowed");
+      }
+
       /* If the declaration is not a redeclaration, there are a few additional
        * semantic checks that must be applied.  In addition, variable that was
        * created for the declaration should be added to the IR stream.