From: Francisco Jerez Date: Wed, 19 Feb 2014 14:20:27 +0000 (+0100) Subject: i965/vec4: Add non-mutating helper functions to modify src_reg::swizzle and ::negate. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=98306e727b8291507ff4fd5dd5c4806f3fed9202;p=mesa.git i965/vec4: Add non-mutating helper functions to modify src_reg::swizzle and ::negate. Reviewed-by: Paul Berry --- diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h index 3be17d890cf..a592af2f128 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_vec4.h @@ -148,6 +148,30 @@ offset(src_reg reg, unsigned delta) return reg; } +/** + * Reswizzle a given source register. + * \sa brw_swizzle(). + */ +static inline src_reg +swizzle(src_reg reg, unsigned swizzle) +{ + assert(reg.file != HW_REG); + reg.swizzle = BRW_SWIZZLE4( + BRW_GET_SWZ(reg.swizzle, BRW_GET_SWZ(swizzle, 0)), + BRW_GET_SWZ(reg.swizzle, BRW_GET_SWZ(swizzle, 1)), + BRW_GET_SWZ(reg.swizzle, BRW_GET_SWZ(swizzle, 2)), + BRW_GET_SWZ(reg.swizzle, BRW_GET_SWZ(swizzle, 3))); + return reg; +} + +static inline src_reg +negate(src_reg reg) +{ + assert(reg.file != HW_REG && reg.file != IMM); + reg.negate = !reg.negate; + return reg; +} + class dst_reg : public reg { public: