[Mesa-dev] [PATCH 1/3] i965/vec4: add a byte_offset helper

Francisco Jerez currojerez at riseup.net
Wed Oct 26 20:12:04 UTC 2016


Iago Toral Quiroga <itoral at igalia.com> writes:

> ---
>  src/mesa/drivers/dri/i965/brw_ir_vec4.h | 46 +++++++++++++++++++++++++++++++++
>  1 file changed, 46 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_ir_vec4.h b/src/mesa/drivers/dri/i965/brw_ir_vec4.h
> index a8e5f4a..ef79e33 100644
> --- a/src/mesa/drivers/dri/i965/brw_ir_vec4.h
> +++ b/src/mesa/drivers/dri/i965/brw_ir_vec4.h
> @@ -60,6 +60,45 @@ retype(src_reg reg, enum brw_reg_type type)
>     return reg;
>  }
>  
> +static inline void
> +add_byte_offset(backend_reg *reg, unsigned bytes)
> +{
> +   switch (reg->file) {
> +      case BAD_FILE:
> +         break;
> +      case VGRF:
> +      case ATTR:
> +      case UNIFORM:
> +         reg->offset += bytes;
> +         assert(reg->offset % 16 == 0);
> +         break;
> +      case MRF: {
> +         const unsigned suboffset = reg->offset + bytes;
> +         reg->nr += suboffset / REG_SIZE;
> +         reg->offset = suboffset % REG_SIZE;
> +         assert(reg->offset % 16 == 0);
> +         break;
> +      }
> +      case ARF:
> +      case FIXED_GRF: {
> +         const unsigned suboffset = reg->subnr + bytes;
> +         reg->nr += suboffset / REG_SIZE;
> +         reg->subnr = suboffset % REG_SIZE;
> +         assert(reg->subnr % 16 == 0);
> +         break;
> +      }
> +      default:
> +         assert(bytes == 0);
> +   }
> +}
> +

I suggest you wrap this helper in 'namespace detail { ... }' to make
clear that this is an implementation detail of the byte_offset()
functions below not intended to be used independently.  With that
changed:

Reviewed-by: Francisco Jerez <currojerez at riseup.net>

> +static inline src_reg
> +byte_offset(src_reg reg, unsigned bytes)
> +{
> +   add_byte_offset(&reg, bytes);
> +   return reg;
> +}
> +
>  static inline src_reg
>  offset(src_reg reg, unsigned delta)
>  {
> @@ -130,6 +169,13 @@ retype(dst_reg reg, enum brw_reg_type type)
>  }
>  
>  static inline dst_reg
> +byte_offset(dst_reg reg, unsigned bytes)
> +{
> +   add_byte_offset(&reg, bytes);
> +   return reg;
> +}
> +
> +static inline dst_reg
>  offset(dst_reg reg, unsigned delta)
>  {
>     assert(delta == 0 ||
> -- 
> 2.7.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20161026/ee236c74/attachment.sig>


More information about the mesa-dev mailing list