[Mesa-dev] [PATCH] glsl: set mask via initialization list rather than in constructor body

Samuel Pitoiset samuel.pitoiset at gmail.com
Sat May 20 15:23:07 UTC 2017



On 05/20/2017 07:05 AM, Timothy Arceri wrote:
> Potentially more efficient as is may avoid the struct being initialised
> twice.
> ---
>   src/compiler/glsl/ir.cpp | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
> index 123de99..e55635b 100644
> --- a/src/compiler/glsl/ir.cpp
> +++ b/src/compiler/glsl/ir.cpp
> @@ -1583,24 +1583,23 @@ ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z,
>   }
>   
>   ir_swizzle::ir_swizzle(ir_rvalue *val, const unsigned *comp,
>   		       unsigned count)
>      : ir_rvalue(ir_type_swizzle), val(val)
>   {
>      this->init_mask(comp, count);
>   }
>   
>   ir_swizzle::ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask)
> -   : ir_rvalue(ir_type_swizzle)
> +   : ir_rvalue(ir_type_swizzle), mask(mask)
>   {
>      this->val = val;
> -   this->mask = mask;

'val' could also be initialized through the list.

With that fixed, patch is:

Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>

>      this->type = glsl_type::get_instance(val->type->base_type,
>   					mask.num_components, 1);
>   }
>   
>   #define X 1
>   #define R 5
>   #define S 9
>   #define I 13
>   
>   ir_swizzle *
> 


More information about the mesa-dev mailing list