Mesa (master): glsl: reject memory qualifiers with uniform blocks

Samuel Pitoiset hakzsam at kemper.freedesktop.org
Thu May 4 12:02:57 UTC 2017


Module: Mesa
Branch: master
Commit: 9db9b2e8cd0a0d250c6251a2fef17198616519e7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9db9b2e8cd0a0d250c6251a2fef17198616519e7

Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date:   Wed May  3 18:37:28 2017 +0200

glsl: reject memory qualifiers with uniform blocks

The spec allows memory qualifiers to be used with image variables,
buffers variables and shader storage blocks. This patch also fixes
validate_memory_qualifier_for_type().

Fixes the following ARB_uniform_buffer_object test:

uniform-block-memory-qualifier.frag

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

---

 src/compiler/glsl/ast_to_hir.cpp | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index e5604a10ac..0f79cd6084 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -3298,14 +3298,21 @@ validate_memory_qualifier_for_type(struct _mesa_glsl_parse_state *state,
                                    const struct ast_type_qualifier *qual,
                                    const glsl_type *type)
 {
-   if (!type->is_image()) {
+   /* From Section 4.10 (Memory Qualifiers) of the GLSL 4.50 spec:
+    *
+    * "Memory qualifiers are only supported in the declarations of image
+    *  variables, buffer variables, and shader storage blocks; it is an error
+    *  to use such qualifiers in any other declarations.
+    */
+   if (!type->is_image() && !qual->flags.q.buffer) {
       if (qual->flags.q.read_only ||
           qual->flags.q.write_only ||
           qual->flags.q.coherent ||
           qual->flags.q._volatile ||
           qual->flags.q.restrict_flag) {
          _mesa_glsl_error(loc, state, "memory qualifiers may only be applied "
-                          "to images");
+                          "in the declarations of image variables, buffer "
+                          "variables, and shader storage blocks");
          return false;
       }
    }
@@ -6894,6 +6901,7 @@ ast_process_struct_or_iface_block_members(exec_list *instructions,
                           "to struct or interface block members");
       }
 
+      validate_memory_qualifier_for_type(state, &loc, qual, decl_type);
       validate_image_format_qualifier_for_type(state, &loc, qual, decl_type);
 
       /* From Section 4.4.2.3 (Geometry Outputs) of the GLSL 4.50 spec:




More information about the mesa-commit mailing list