diff options
author | Iago Toral Quiroga <[email protected]> | 2016-10-03 13:24:22 +0200 |
---|---|---|
committer | Iago Toral Quiroga <[email protected]> | 2016-10-27 10:59:31 +0200 |
commit | 5a4ce9f9a79934e4cfc2034c7d181a671e2563bf (patch) | |
tree | ff9da384013bf661e454378b1cbbb30909e2afd1 /src/mesa | |
parent | 173558445dce26ce641faf260a17696221acf23d (diff) |
i965/vec4: add a byte_offset helper
v2: wrap the helper in a namespace to make clear that it is an
implementation detail of byte_offset() and is not intended
to be used independently (Curro).
Reviewed-by: Francisco Jerez <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_ir_vec4.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_ir_vec4.h b/src/mesa/drivers/dri/i965/brw_ir_vec4.h index a8e5f4a18f0..1633c4ce0d5 100644 --- a/src/mesa/drivers/dri/i965/brw_ir_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_ir_vec4.h @@ -60,6 +60,49 @@ retype(src_reg reg, enum brw_reg_type type) return reg; } +namespace detail { + +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); + } +} + +} /* namepace detail */ + +static inline src_reg +byte_offset(src_reg reg, unsigned bytes) +{ + detail::add_byte_offset(®, bytes); + return reg; +} + static inline src_reg offset(src_reg reg, unsigned delta) { @@ -130,6 +173,13 @@ retype(dst_reg reg, enum brw_reg_type type) } static inline dst_reg +byte_offset(dst_reg reg, unsigned bytes) +{ + detail::add_byte_offset(®, bytes); + return reg; +} + +static inline dst_reg offset(dst_reg reg, unsigned delta) { assert(delta == 0 || |