diff options
author | Marek Olšák <[email protected]> | 2010-11-25 04:34:31 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2010-11-26 02:23:13 +0100 |
commit | ea2f56b49026dce4f0e507b587fd58b18b5de1ec (patch) | |
tree | 4386053e28ebd06ef5162226b928656f328cec4d /src | |
parent | 7c294462324fd3dc1951fc003290b926fbc0b07e (diff) |
r300/compiler: add a function for swizzling a mask
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/r300/compiler/radeon_optimize.c | 7 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/compiler/radeon_program.h | 14 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c b/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c index 27b10ffbd61..44f4c0fbdc7 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c +++ b/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c @@ -54,12 +54,7 @@ static struct rc_src_register chain_srcregs(struct rc_src_register outer, struct combine.Negate = outer.Negate; } else { combine.Abs = inner.Abs; - combine.Negate = 0; - for(unsigned int chan = 0; chan < 4; ++chan) { - unsigned int swz = GET_SWZ(outer.Swizzle, chan); - if (swz < 4) - combine.Negate |= GET_BIT(inner.Negate, swz) << chan; - } + combine.Negate = swizzle_mask(outer.Swizzle, inner.Negate); combine.Negate ^= outer.Negate; } combine.Swizzle = combine_swizzles(inner.Swizzle, outer.Swizzle); diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_program.h b/src/mesa/drivers/dri/r300/compiler/radeon_program.h index 913815b24d0..772ea14df34 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_program.h +++ b/src/mesa/drivers/dri/r300/compiler/radeon_program.h @@ -204,6 +204,20 @@ static inline rc_swizzle rc_mask_to_swizzle(unsigned int mask) } return RC_SWIZZLE_UNUSED; } + +/* Reorder mask bits according to swizzle. */ +static inline unsigned swizzle_mask(unsigned swizzle, unsigned mask) +{ + unsigned ret = 0; + for (unsigned chan = 0; chan < 4; ++chan) { + unsigned swz = GET_SWZ(swizzle, chan); + if (swz < 4) + ret |= GET_BIT(mask, swz) << chan; + } + return ret; +} + + struct rc_src_register lmul_swizzle(unsigned int swizzle, struct rc_src_register srcreg); static inline void reset_srcreg(struct rc_src_register* reg) |