i965: Add support for swizzling arbitrary immediates to (brw_)swizzle().
authorFrancisco Jerez <currojerez@riseup.net>
Sat, 27 Feb 2016 01:12:27 +0000 (17:12 -0800)
committerFrancisco Jerez <currojerez@riseup.net>
Sun, 6 Mar 2016 20:22:40 +0000 (12:22 -0800)
commitff7a2b489e6a8f3f63f71f36cd63d91cd81c326d
treeff3803b21036c877bc9be5f8d3cbd0442da43b49
parent537d3df97466835ad6438fe2c9121283e0da1bcd
i965: Add support for swizzling arbitrary immediates to (brw_)swizzle().

Scalar immediates used to be handled correctly by swizzle() (as the
identity) but since commit 58fa9d47b536403c4e3ca5d6a2495691338388fd it
will corrupt the contents of the immediate.  Vector immediates were
never handled correctly, but we had ad-hoc code to swizzle VF
immediates in the vec4 copy propagation pass.  This takes care of
swizzling V and UV in addition.

v2: Don't implement swizzling of V/UV immediates (Matt).  If you need
    to swizzle an integer vector immediate in the future apply the
    following diff to go back to v1:

--- a/src/mesa/drivers/dri/i965/brw_eu.c
+++ b/src/mesa/drivers/dri/i965/brw_eu.c
@@ -119,11 +119,10 @@ brw_swap_cmod(uint32_t cmod)
 static unsigned
 imm_shift(enum brw_reg_type type, unsigned i)
 {
-   assert(type != BRW_REGISTER_TYPE_UV && type != BRW_REGISTER_TYPE_V &&
-          "Not implemented.");
-
    if (type == BRW_REGISTER_TYPE_VF)
       return 8 * (i & 3);
+   else if (type == BRW_REGISTER_TYPE_UV || type == BRW_REGISTER_TYPE_V)
+      return 4 * (i & 7);
    else
       return 0;
 }

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
src/mesa/drivers/dri/i965/brw_eu.c
src/mesa/drivers/dri/i965/brw_ir_vec4.h
src/mesa/drivers/dri/i965/brw_reg.h