diff options
Diffstat (limited to 'src/gallium/auxiliary/gallivm/lp_bld_swizzle.c')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_swizzle.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c index 20cf96ca66..d4d2f2b307 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c @@ -95,10 +95,13 @@ lp_build_broadcast_scalar(struct lp_build_context *bld, } +/** + * Swizzle one channel into all other three channels. + */ LLVMValueRef -lp_build_broadcast_aos(struct lp_build_context *bld, - LLVMValueRef a, - unsigned channel) +lp_build_swizzle_scalar_aos(struct lp_build_context *bld, + LLVMValueRef a, + unsigned channel) { const struct lp_type type = bld->type; const unsigned n = type.length; @@ -139,13 +142,10 @@ lp_build_broadcast_aos(struct lp_build_context *bld, { 1, -2}, {-1, -2} }; - boolean cond[4]; unsigned i; - memset(cond, 0, sizeof cond); - cond[channel] = 1; - - a = LLVMBuildAnd(bld->builder, a, lp_build_const_mask_aos(type, cond), ""); + a = LLVMBuildAnd(bld->builder, a, + lp_build_const_mask_aos(type, 1 << channel), ""); /* * Build a type where each element is an integer that cover the four @@ -206,7 +206,7 @@ lp_build_swizzle_aos(struct lp_build_context *bld, case PIPE_SWIZZLE_GREEN: case PIPE_SWIZZLE_BLUE: case PIPE_SWIZZLE_ALPHA: - return lp_build_broadcast_aos(bld, a, swizzles[0]); + return lp_build_swizzle_scalar_aos(bld, a, swizzles[0]); case PIPE_SWIZZLE_ZERO: return bld->zero; case PIPE_SWIZZLE_ONE: @@ -282,7 +282,7 @@ lp_build_swizzle_aos(struct lp_build_context *bld, */ LLVMValueRef res; struct lp_type type4; - boolean cond[4]; + unsigned cond = 0; unsigned chan; int shift; @@ -290,9 +290,11 @@ lp_build_swizzle_aos(struct lp_build_context *bld, * Start with a mixture of 1 and 0. */ for (chan = 0; chan < 4; ++chan) { - cond[chan] = swizzles[chan] == PIPE_SWIZZLE_ONE ? TRUE : FALSE; + if (swizzles[chan] == PIPE_SWIZZLE_ONE) { + cond |= 1 << chan; + } } - res = lp_build_select_aos(bld, bld->one, bld->zero, cond); + res = lp_build_select_aos(bld, cond, bld->one, bld->zero); /* * Build a type where each element is an integer that cover the four |