[Mesa-dev] [PATCH v4 (part2) 49/59] glsl: Do not allow assignments to read-only variables

Timothy Arceri t_arceri at yahoo.com.au
Wed Aug 5 03:04:54 PDT 2015


On Wed, 2015-08-05 at 10:30 +0200, Iago Toral Quiroga wrote:
> ---
>  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 e834a46..518612d 100644
> --- a/src/glsl/ast_to_hir.cpp
> +++ b/src/glsl/ast_to_hir.cpp
> @@ -811,8 +811,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) {

It looks like data.read_only is always set to true for images so wouldn't this
already be caught already by the existing read-only check?

      else if (lhs_var != NULL && lhs_var->data.read_only) {
         _mesa_glsl_error(&lhs_loc, state,
                          "assignment to read-only variable '%s'",
                          lhs_var->name);


> +         _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) {


More information about the mesa-dev mailing list