i965/vec4: Add non-mutating helper functions to modify src_reg::swizzle and ::negate.
authorFrancisco Jerez <currojerez@riseup.net>
Wed, 19 Feb 2014 14:20:27 +0000 (15:20 +0100)
committerFrancisco Jerez <currojerez@riseup.net>
Wed, 19 Feb 2014 15:27:25 +0000 (16:27 +0100)
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/mesa/drivers/dri/i965/brw_vec4.h

index 3be17d890cf1c21633d34d4842d4eed320d79f8c..a592af2f128e32b6b35e4430aff19acdba2f19ed 100644 (file)
@@ -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: