[Mesa-dev] [PATCH 2/4] i965/vec4: make the offset() operate in terms of width and type

Michael Schellenberger Costa mschellenbergercosta at googlemail.com
Mon Aug 22 10:10:12 UTC 2016


Hi Iago,

Am 22.08.2016 um 11:53 schrieb Iago Toral Quiroga:
> This will make it more consistent with the FS implementation of the same
> helper and will provide more flexibility that will come in handy, for
> example, when we add a SIMD lowering pass in the vec4 backend.
> ---
>  src/mesa/drivers/dri/i965/brw_ir_vec4.h | 47 ++++++++++++++++++++++++++++++---
>  1 file changed, 43 insertions(+), 4 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_ir_vec4.h b/src/mesa/drivers/dri/i965/brw_ir_vec4.h
> index 81b6a13..058ffbb 100644
> --- a/src/mesa/drivers/dri/i965/brw_ir_vec4.h
> +++ b/src/mesa/drivers/dri/i965/brw_ir_vec4.h
> @@ -60,13 +60,37 @@ retype(src_reg reg, enum brw_reg_type type)
>     return reg;
>  }
>  
> +static inline void
> +add_byte_offset(backend_reg *reg, unsigned delta)
> +{
> +   const unsigned suboffset = reg->subreg_offset + delta;
> +   reg->reg_offset += suboffset / REG_SIZE;
> +   reg->subreg_offset += suboffset % REG_SIZE;
> +   assert(reg->subreg_offset % 16 == 0);
> +}
> +
>  static inline src_reg
> -offset(src_reg reg, unsigned delta)
> +offset(src_reg reg, unsigned width, unsigned delta)
>  {
>     assert(delta == 0 ||
>            (reg.file != ARF && reg.file != FIXED_GRF && reg.file != IMM));
> -   reg.reg_offset += delta;
Isnt that assert superfluous with the switch below, as you cover the
second condition in the explicit cases?
> +
> +   switch (reg.file) {
> +   case BAD_FILE:
> +      break;
> +   case MRF:
> +   case VGRF:
> +   case ATTR:
> +   case UNIFORM: {
> +      unsigned byte_offset = delta * width * type_sz(reg.type);
> +      add_byte_offset(&reg, byte_offset);
> +      break;
> +   }
> +   default:
> +      assert(delta = 0);
delta == 0 ?

Same below.
--Michael
> +   }
>     return reg;
> +
>  }
>  
>  /**
> @@ -130,12 +154,27 @@ retype(dst_reg reg, enum brw_reg_type type)
>  }
>  
>  static inline dst_reg
> -offset(dst_reg reg, unsigned delta)
> +offset(dst_reg reg, unsigned width, unsigned delta)
>  {
>     assert(delta == 0 ||
>            (reg.file != ARF && reg.file != FIXED_GRF && reg.file != IMM));
> -   reg.reg_offset += delta;
> +
> +   switch (reg.file) {
> +   case BAD_FILE:
> +      break;
> +   case MRF:
> +   case VGRF:
> +   case ATTR:
> +   case UNIFORM: {
> +      unsigned byte_offset = delta * width * type_sz(reg.type);
> +      add_byte_offset(&reg, byte_offset);
> +      break;
> +   }
> +   default:
> +      assert(delta = 0);
> +   }
>     return reg;
> +
>  }
>  
>  static inline dst_reg
> 


More information about the mesa-dev mailing list