* We store all factors in a table in order to eliminate redundant
* multiplications later.
*/
- LLVMValueRef factor[2][8];
+ LLVMValueRef factor[2][2][4];
/**
* Table with all terms.
*/
- LLVMValueRef term[8];
+ LLVMValueRef term[2][4];
};
LLVMValueRef res[4])
{
struct lp_build_blend_soa_context bld;
- unsigned i, j;
-
- if(!blend->blend_enable) {
- for (i = 0; i < 4; ++i)
- res[i] = src[i];
- return;
- }
-
- /* It makes no sense to blend unless values are normalized */
- assert(type.norm);
+ unsigned i, j, k;
/* Setup build context */
memset(&bld, 0, sizeof bld);
bld.con[i] = con[i];
}
- /*
- * Compute src/dst factors.
- */
for (i = 0; i < 4; ++i) {
- unsigned src_factor = i < 3 ? blend->rgb_src_factor : blend->alpha_src_factor;
- unsigned dst_factor = i < 3 ? blend->rgb_dst_factor : blend->alpha_dst_factor;
- bld.factor[0][0 + i] = src[i];
- bld.factor[1][0 + i] = lp_build_blend_soa_factor(&bld, src_factor, i);
- bld.factor[0][4 + i] = dst[i];
- bld.factor[1][4 + i] = lp_build_blend_soa_factor(&bld, dst_factor, i);
- }
-
- /*
- * Compute src/dst terms
- */
- for (i = 0; i < 8; ++i) {
-
- /* See if this multiplication has been previously computed */
- for(j = 0; j < i; ++j) {
- if((bld.factor[0][j] == bld.factor[0][i] &&
- bld.factor[1][j] == bld.factor[1][i]) ||
- (bld.factor[0][j] == bld.factor[1][i] &&
- bld.factor[1][j] == bld.factor[0][i]))
- break;
+ if (blend->colormask & (1 << i)) {
+ if (blend->blend_enable) {
+ unsigned src_factor = i < 3 ? blend->rgb_src_factor : blend->alpha_src_factor;
+ unsigned dst_factor = i < 3 ? blend->rgb_dst_factor : blend->alpha_dst_factor;
+ unsigned func = i < 3 ? blend->rgb_func : blend->alpha_func;
+ boolean func_commutative = lp_build_blend_func_commutative(func);
+
+ /* It makes no sense to blend unless values are normalized */
+ assert(type.norm);
+
+ /*
+ * Compute src/dst factors.
+ */
+
+ bld.factor[0][0][i] = src[i];
+ bld.factor[0][1][i] = lp_build_blend_soa_factor(&bld, src_factor, i);
+ bld.factor[1][0][i] = dst[i];
+ bld.factor[1][1][i] = lp_build_blend_soa_factor(&bld, dst_factor, i);
+
+ /*
+ * Compute src/dst terms
+ */
+
+ for(k = 0; k < 2; ++k) {
+ /* See if this multiplication has been previously computed */
+ for(j = 0; j < i; ++j) {
+ if((bld.factor[k][0][j] == bld.factor[k][0][i] &&
+ bld.factor[k][1][j] == bld.factor[k][1][i]) ||
+ (bld.factor[k][0][j] == bld.factor[k][1][i] &&
+ bld.factor[k][1][j] == bld.factor[k][0][i]))
+ break;
+ }
+
+ if(j < i)
+ bld.term[k][i] = bld.term[k][j];
+ else
+ bld.term[k][i] = lp_build_mul(&bld.base, bld.factor[k][0][i], bld.factor[k][1][i]);
+ }
+
+ /*
+ * Combine terms
+ */
+
+ /* See if this function has been previously applied */
+ for(j = 0; j < i; ++j) {
+ unsigned prev_func = j < 3 ? blend->rgb_func : blend->alpha_func;
+ unsigned func_reverse = lp_build_blend_func_reverse(func, prev_func);
+
+ if((!func_reverse &&
+ bld.term[0][j] == bld.term[0][i] &&
+ bld.term[1][j] == bld.term[1][i]) ||
+ ((func_commutative || func_reverse) &&
+ bld.term[0][j] == bld.term[1][i] &&
+ bld.term[1][j] == bld.term[0][i]))
+ break;
+ }
+
+ if(j < i)
+ res[i] = res[j];
+ else
+ res[i] = lp_build_blend_func(&bld.base, func, bld.term[0][i], bld.term[1][i]);
+ }
+ else {
+ res[i] = src[i];
+ }
}
-
- if(j < i)
- bld.term[i] = bld.term[j];
- else
- bld.term[i] = lp_build_mul(&bld.base, bld.factor[0][i], bld.factor[1][i]);
- }
-
- /*
- * Combine terms
- */
- for (i = 0; i < 4; ++i) {
- unsigned func = i < 3 ? blend->rgb_func : blend->alpha_func;
- boolean func_commutative = lp_build_blend_func_commutative(func);
-
- /* See if this function has been previously applied */
- for(j = 0; j < i; ++j) {
- unsigned prev_func = j < 3 ? blend->rgb_func : blend->alpha_func;
- unsigned func_reverse = lp_build_blend_func_reverse(func, prev_func);
-
- if((!func_reverse &&
- bld.factor[0 + j] == bld.factor[0 + i] &&
- bld.factor[4 + j] == bld.factor[4 + i]) ||
- ((func_commutative || func_reverse) &&
- bld.factor[0 + j] == bld.factor[4 + i] &&
- bld.factor[4 + j] == bld.factor[0 + i]))
- break;
+ else {
+ res[i] = dst[i];
}
-
- if(j < i)
- res[i] = res[j];
- else
- res[i] = lp_build_blend_func(&bld.base, func, bld.term[i + 0], bld.term[i + 4]);
}
}
}
-static void
-colormask_quad(struct quad_stage *qs,
- float (*quadColor)[4],
- float (*dest)[4])
-{
- struct llvmpipe_context *llvmpipe = qs->llvmpipe;
-
- /* R */
- if (!(llvmpipe->blend->base.colormask & PIPE_MASK_R))
- COPY_4V(quadColor[0], dest[0]);
-
- /* G */
- if (!(llvmpipe->blend->base.colormask & PIPE_MASK_G))
- COPY_4V(quadColor[1], dest[1]);
-
- /* B */
- if (!(llvmpipe->blend->base.colormask & PIPE_MASK_B))
- COPY_4V(quadColor[2], dest[2]);
-
- /* A */
- if (!(llvmpipe->blend->base.colormask & PIPE_MASK_A))
- COPY_4V(quadColor[3], dest[3]);
-}
-
-
static void blend_begin(struct quad_stage *qs)
{
}
blend->jit_function( quadColor, dest, llvmpipe->blend_color, quadColor );
}
- if (blend->base.colormask != 0xf)
- colormask_quad( qs, quadColor, dest );
-
/* Output color values
*/
for (j = 0; j < QUAD_SIZE; j++) {