[Mesa-dev] [PATCH v3 (part2) 47/56] glsl: Do not allow assignments to read-only variables

Iago Toral Quiroga itoral at igalia.com
Tue Jul 14 00:46:49 PDT 2015


---
 src/glsl/ast_to_hir.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index ab62599..92391a0 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -762,8 +762,15 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,
    }
 
    ir_variable *lhs_var = lhs->variable_referenced();
-   if (lhs_var)
+   if (lhs_var) {
+      if (lhs_var->data.image_read_only) {
+         _mesa_glsl_error(&lhs_loc, state,
+                          "assignment to read-only variable `%s'",
+                          lhs_var->name);
+         error_emitted = true;
+      }
       lhs_var->data.assigned = true;
+   }
 
    if (!error_emitted) {
       if (non_lvalue_description != NULL) {
-- 
1.9.1



More information about the mesa-dev mailing list