[Mesa-dev] [PATCH 63/74] glsl: Apply memory qualifiers to buffer variables

Iago Toral Quiroga itoral at igalia.com
Thu May 14 07:07:06 PDT 2015


---
 src/glsl/ast_to_hir.cpp | 25 +++++++++++++++++++++++++
 src/glsl/glsl_types.h   | 10 ++++++++++
 2 files changed, 35 insertions(+)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index f1f2546..e7d50e1 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -5496,6 +5496,23 @@ ast_process_structure_or_interface_block(exec_list *instructions,
                    || fields[i].matrix_layout == GLSL_MATRIX_LAYOUT_COLUMN_MAJOR);
          }
 
+         /* Image qualifiers are allowed on buffer variables, which can only
+          * be defined inside shader storage buffer objects
+          */
+         if (var_mode == ir_var_buffer) {
+            fields[i].image_read_only = qual->flags.q.read_only;
+            fields[i].image_write_only = qual->flags.q.write_only;
+            fields[i].image_coherent = qual->flags.q.coherent;
+            fields[i].image_volatile = qual->flags.q._volatile;
+            fields[i].image_restrict = qual->flags.q.restrict_flag;
+
+            if (fields[i].image_read_only && fields[i].image_write_only) {
+               _mesa_glsl_error(&loc, state,
+                                "buffer variable `%s' can't be "
+                                "readonly and writeonly.", fields[i].name);
+            }
+         }
+
          i++;
       }
    }
@@ -6004,6 +6021,14 @@ ast_interface_block::hir(exec_list *instructions,
 
          var->data.stream = this->layout.stream;
 
+         if (var->data.mode == ir_var_buffer) {
+            var->data.image_read_only = fields[i].image_read_only;
+            var->data.image_write_only = fields[i].image_write_only;
+            var->data.image_coherent = fields[i].image_coherent;
+            var->data.image_volatile = fields[i].image_volatile;
+            var->data.image_restrict = fields[i].image_restrict;
+         }
+
          /* Examine var name here since var may get deleted in the next call */
          bool var_is_gl_id = is_gl_identifier(var->name);
 
diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
index 8d1b1be..a62fbed 100644
--- a/src/glsl/glsl_types.h
+++ b/src/glsl/glsl_types.h
@@ -786,6 +786,16 @@ struct glsl_struct_field {
     * streams (as in ir_variable::stream). -1 otherwise.
     */
    int stream;
+
+   /**
+    * Image qualifiers, applicable to buffer variables defined in shader
+    * storage buffer objects (SSBOs)
+    */
+   unsigned image_read_only:1;
+   unsigned image_write_only:1;
+   unsigned image_coherent:1;
+   unsigned image_volatile:1;
+   unsigned image_restrict:1;
 };
 
 static inline unsigned int
-- 
1.9.1



More information about the mesa-dev mailing list