summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorJames Benton <[email protected]>2012-07-11 15:39:53 +0100
committerJosé Fonseca <[email protected]>2012-11-28 19:14:36 +0000
commit1d3789bccbbcc814fd7b339e9f5b5631e30d9f0e (patch)
treeddddaade4fc5884e3a33b2195a160a45868bc869 /src/gallium/auxiliary
parentd03d29a0442e8c1bfb1567f33abc83373a203220 (diff)
gallivm: Updated lp_build_const_mask_aos to input number of channels.
Also updated lp_build_const_mask_aos_swizzled to reflect this. Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_const.c29
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_const.h10
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_logic.c2
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_swizzle.c2
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c1
5 files changed, 26 insertions, 18 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_const.c b/src/gallium/auxiliary/gallivm/lp_bld_const.c
index 24ed23adc35..0f5a8f8e851 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_const.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_const.c
@@ -394,7 +394,8 @@ lp_build_const_aos(struct gallivm_state *gallivm,
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];
@@ -402,8 +403,8 @@ lp_build_const_mask_aos(struct gallivm_state *gallivm,
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);
@@ -419,17 +420,21 @@ lp_build_const_mask_aos(struct gallivm_state *gallivm,
*/
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);
}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_const.h b/src/gallium/auxiliary/gallivm/lp_bld_const.h
index 2205616274f..b17c41931f4 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_const.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_const.h
@@ -108,14 +108,16 @@ lp_build_const_aos(struct gallivm_state *gallivm, struct lp_type type,
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
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_logic.c b/src/gallium/auxiliary/gallivm/lp_bld_logic.c
index 7a4a5bb11d3..8a77a43dae8 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_logic.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_logic.c
@@ -603,7 +603,7 @@ lp_build_select_aos(struct lp_build_context *bld,
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);
}
}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c
index 3d70252e75a..4ae4f3752a8 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c
@@ -210,7 +210,7 @@ lp_build_swizzle_scalar_aos(struct lp_build_context *bld,
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
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
index 625aac2697b..44f684a1d01 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
@@ -329,6 +329,7 @@ lp_emit_store_aos(
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) {