[Mesa-dev] [PATCH v4 (part2) 47/59] glsl: Apply memory qualifiers to buffer variables
Iago Toral Quiroga
itoral at igalia.com
Wed Aug 5 01:30:44 PDT 2015
---
src/glsl/ast_to_hir.cpp | 25 +++++++++++++++++++++++++
src/glsl/glsl_types.h | 11 +++++++++++
2 files changed, 36 insertions(+)
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 40fa664..37ad571 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -5832,6 +5832,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_shader_storage) {
+ 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++;
}
}
@@ -6422,6 +6439,14 @@ ast_interface_block::hir(exec_list *instructions,
var->data.stream = this->layout.stream;
+ if (var->data.mode == ir_var_shader_storage) {
+ 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 a9e363a..36a8057 100644
--- a/src/glsl/glsl_types.h
+++ b/src/glsl/glsl_types.h
@@ -800,6 +800,17 @@ struct glsl_struct_field {
*/
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;
+
glsl_struct_field(const struct glsl_type *_type, const char *_name)
: type(_type), name(_name), location(-1), interpolation(0), centroid(0),
sample(0), matrix_layout(GLSL_MATRIX_LAYOUT_INHERITED), patch(0),
--
1.9.1
More information about the mesa-dev
mailing list