Also updated lp_build_const_mask_aos_swizzled to reflect this.
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
LLVMValueRef
lp_build_const_mask_aos(struct gallivm_state *gallivm,
struct lp_type type,
- unsigned mask)
+ unsigned mask,
+ unsigned channels)
{
LLVMTypeRef elem_type = LLVMIntTypeInContext(gallivm->context, type.width);
LLVMValueRef masks[LP_MAX_VECTOR_LENGTH];
assert(type.length <= LP_MAX_VECTOR_LENGTH);
- for (j = 0; j < type.length; j += 4) {
- for( i = 0; i < 4; ++i) {
+ for (j = 0; j < type.length; j += channels) {
+ for( i = 0; i < channels; ++i) {
masks[j + i] = LLVMConstInt(elem_type,
mask & (1 << i) ? ~0ULL : 0,
1);
*/
LLVMValueRef
lp_build_const_mask_aos_swizzled(struct gallivm_state *gallivm,
- struct lp_type type,
- unsigned mask,
- const unsigned char *swizzle)
+ struct lp_type type,
+ unsigned mask,
+ unsigned channels,
+ const unsigned char *swizzle)
{
- mask =
- ((mask & (1 << swizzle[0])) >> swizzle[0])
- | (((mask & (1 << swizzle[1])) >> swizzle[1]) << 1)
- | (((mask & (1 << swizzle[2])) >> swizzle[2]) << 2)
- | (((mask & (1 << swizzle[3])) >> swizzle[3]) << 3);
+ unsigned i, mask_swizzled;
+ mask_swizzled = 0;
+
+ for (i = 0; i < channels; ++i) {
+ if (swizzle[i] < 4) {
+ mask_swizzled |= ((mask & (1 << swizzle[i])) >> swizzle[i]) << i;
+ }
+ }
- return lp_build_const_mask_aos(gallivm, type, mask);
+ return lp_build_const_mask_aos(gallivm, type, mask_swizzled, channels);
}
LLVMValueRef
lp_build_const_mask_aos(struct gallivm_state *gallivm,
struct lp_type type,
- unsigned mask);
+ unsigned mask,
+ unsigned channels);
LLVMValueRef
lp_build_const_mask_aos_swizzled(struct gallivm_state *gallivm,
- struct lp_type type,
- unsigned mask,
- const unsigned char *swizzle);
+ struct lp_type type,
+ unsigned mask,
+ unsigned channels,
+ const unsigned char *swizzle);
static INLINE LLVMValueRef
return LLVMBuildShuffleVector(builder, a, b, LLVMConstVector(shuffles, n), "");
}
else {
- LLVMValueRef mask_vec = lp_build_const_mask_aos(bld->gallivm, type, mask);
+ LLVMValueRef mask_vec = lp_build_const_mask_aos(bld->gallivm, type, mask, 4);
return lp_build_select(bld, mask_vec, a, b);
}
}
a = LLVMBuildAnd(builder, a,
lp_build_const_mask_aos(bld->gallivm,
- type, 1 << channel), "");
+ type, 1 << channel, 4), "");
/*
* Build a type where each element is an integer that cover the four
writemask = lp_build_const_mask_aos_swizzled(bld->bld_base.base.gallivm,
bld->bld_base.base.type,
reg->Register.WriteMask,
+ TGSI_NUM_CHANNELS,
bld->swizzles);
if (mask) {
const unsigned char swizzle[4])
{
const struct pipe_rt_blend_state * state = &blend->rt[rt];
+ const struct util_format_description * desc;
struct lp_build_blend_aos_context bld;
LLVMValueRef src_factor, dst_factor;
LLVMValueRef result;
unsigned alpha_swizzle = swizzle[3];
boolean fullcolormask;
+ desc = util_format_description(cbuf_format[rt]);
+
/* Setup build context */
memset(&bld, 0, sizeof bld);
lp_build_context_init(&bld.base, gallivm, type);
if (!fullcolormask) {
LLVMValueRef color_mask;
- color_mask = lp_build_const_mask_aos_swizzled(gallivm, bld.base.type, state->colormask, swizzle);
+ color_mask = lp_build_const_mask_aos_swizzled(gallivm, bld.base.type, state.colormask, desc->nr_channels, swizzle);
lp_build_name(color_mask, "color_mask");
/* Combine with input mask if necessary */
/* Constants */
pos_half = lp_build_const_vec(gallivm, type, +0.5f);
neg_half = lp_build_const_vec(gallivm, type, -0.5f);
- cyl_mask = lp_build_const_mask_aos(gallivm, type, cyl_wrap);
+ cyl_mask = lp_build_const_mask_aos(gallivm, type, cyl_wrap, 4);
one = lp_build_const_vec(gallivm, type, 1.0f);
one = LLVMBuildBitCast(builder, one, lp_build_int_vec_type(gallivm, type), "");