i965/vec4: Fix confusion between SWIZZLE and BRW_SWIZZLE macros.

Most of the VEC4 back-end agrees on src_reg::swizzle being one of the
BRW_SWIZZLE macros defined in brw_reg.h, except in two places where we
use Mesa's SWIZZLE macros.  There is even a doxygen comment saying
that Mesa's macros are the right ones.  They are incompatible swizzle
representations (3 bits vs. 2 bits per component), and the code using
Mesa's works by pure luck.  Fix it.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
This commit is contained in:
Francisco Jerez 2013-11-27 22:21:45 -08:00
parent a3a55067bd
commit b424da4be0
3 changed files with 4 additions and 4 deletions

View file

@ -76,7 +76,7 @@ src_reg::src_reg(register_file file, int reg, const glsl_type *type)
if (type && (type->is_scalar() || type->is_vector() || type->is_matrix()))
this->swizzle = swizzle_for_size(type->vector_elements);
else
this->swizzle = SWIZZLE_XYZW;
this->swizzle = BRW_SWIZZLE_XYZW;
}
/** Generic unset register constructor. */

View file

@ -135,7 +135,7 @@ public:
explicit src_reg(dst_reg reg);
GLuint swizzle; /**< SWIZZLE_XYZW swizzles from Mesa. */
GLuint swizzle; /**< BRW_SWIZZLE_XYZW macros from brw_reg.h. */
bool negate;
bool abs;

View file

@ -473,14 +473,14 @@ vec4_visitor::emit_pack_half_2x16(dst_reg dst, src_reg src0)
/* Give the write-channels of dst the form:
* 0xhhhh0000
*/
tmp_src.swizzle = SWIZZLE_Y;
tmp_src.swizzle = BRW_SWIZZLE_YYYY;
emit(SHL(dst, tmp_src, src_reg(16u)));
/* Finally, give the write-channels of dst the form of packHalf2x16's
* output:
* 0xhhhhllll
*/
tmp_src.swizzle = SWIZZLE_X;
tmp_src.swizzle = BRW_SWIZZLE_XXXX;
emit(OR(dst, src_reg(dst), tmp_src));
}