summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIago Toral Quiroga <itoral@igalia.com>2015-08-05 10:30:46 +0200
committerSamuel Iglesias Gonsalvez <siglesias@igalia.com>2015-09-25 08:39:23 +0200
commit995a719499d4bd97b27f1e8c7b506202257007b6 (patch)
tree4a7c21658df1ec37becf639cab20d4ae51bf60b3 /src
parent6ef82f039c6fc82dc0910e842a47c4a69ab44e12 (diff)
downloadexternal_mesa3d-995a719499d4bd97b27f1e8c7b506202257007b6.zip
external_mesa3d-995a719499d4bd97b27f1e8c7b506202257007b6.tar.gz
external_mesa3d-995a719499d4bd97b27f1e8c7b506202257007b6.tar.bz2
glsl: Do not allow assignments to read-only buffer variables
v2: - Merge the error check for the readonly qualifier with the already existing check for variables flagged as readonly (Timothy). - Limit the check to buffer variables, image variables have different semantics involved (Curro). Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Diffstat (limited to 'src')
-rw-r--r--src/glsl/ast_to_hir.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 0b8b401..cad4c03 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -820,7 +820,16 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,
"assignment to %s",
non_lvalue_description);
error_emitted = true;
- } else if (lhs_var != NULL && lhs_var->data.read_only) {
+ } else if (lhs_var != NULL && (lhs_var->data.read_only ||
+ (lhs_var->data.mode == ir_var_shader_storage &&
+ lhs_var->data.image_read_only))) {
+ /* We can have image_read_only set on both images and buffer variables,
+ * but in the former there is a distinction between assignments to
+ * the variable itself (read_only) and to the memory they point to
+ * (image_read_only), while in the case of buffer variables there is
+ * no such distinction, that is why this check here is limited to
+ * buffer variables alone.
+ */
_mesa_glsl_error(&lhs_loc, state,
"assignment to read-only variable '%s'",
lhs_var->name);