[Mesa-dev] [PATCH] glsl: Do not call lhs->variable_referenced() multiple times

Kenneth Graunke kenneth at whitecape.org
Fri May 9 17:44:00 PDT 2014


On 05/08/2014 11:50 PM, Iago Toral Quiroga wrote:
> Instead take the result from the first call and use it where needed.
> ---
>  src/glsl/ast_to_hir.cpp | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
> index 7516c33..0128b3f 100644
> --- a/src/glsl/ast_to_hir.cpp
> +++ b/src/glsl/ast_to_hir.cpp
> @@ -792,25 +792,24 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,
>     ir_variable *lhs_var = lhs->variable_referenced();
>     if (lhs_var)
>        lhs_var->data.assigned = true;
>  
>     if (!error_emitted) {
>        if (non_lvalue_description != NULL) {
>           _mesa_glsl_error(&lhs_loc, state,
>                            "assignment to %s",
>                            non_lvalue_description);
>           error_emitted = true;
> -      } else if (lhs->variable_referenced() != NULL
> -                 && lhs->variable_referenced()->data.read_only) {
> +      } else if (lhs_var != NULL && lhs_var->data.read_only) {
>           _mesa_glsl_error(&lhs_loc, state,
>                            "assignment to read-only variable '%s'",
> -                          lhs->variable_referenced()->name);
> +                          lhs_var->name);
>           error_emitted = true;
>        } else if (lhs->type->is_array() &&
>                   !state->check_version(120, 300, &lhs_loc,
>                                         "whole array assignment forbidden")) {
>           /* From page 32 (page 38 of the PDF) of the GLSL 1.10 spec:
>            *
>            *    "Other binary or unary expressions, non-dereferenced
>            *     arrays, function names, swizzles with repeated fields,
>            *     and constants cannot be l-values."
>            *
> 

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

By the way, if you'd like to apply for push access, the procedure is
documented here:

http://www.freedesktop.org/wiki/AccountRequests/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140509/dbe760eb/attachment-0001.sig>


More information about the mesa-dev mailing list