diff options
author | José Fonseca <[email protected]> | 2009-08-03 02:06:42 +0100 |
---|---|---|
committer | José Fonseca <[email protected]> | 2009-08-29 09:21:22 +0100 |
commit | 9e922444403d704f9ed0cf50e510fba53c736b57 (patch) | |
tree | 7b2d1758340c5bcc778713da0b995aa583199416 | |
parent | ede73258a7604109b257bddb029b5f4dad5eb09d (diff) |
llvmpipe: Improve generated 8bit blending code.
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_bld_blend.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend.c b/src/gallium/drivers/llvmpipe/lp_bld_blend.c index ce8408b79bd..552e3bfd987 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_blend.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_blend.c @@ -188,6 +188,35 @@ lp_build_blend_swizzle(struct lp_build_blend_context *bld, alpha = bld->base.undef; } + if(rgb_swizzle == LP_BUILD_BLEND_SWIZZLE_RGBA && + !bld->base.type.floating) { +#if 0 + /* Use a select */ + /* FIXME: Unfortunetaly select of vectors do not work */ + + for(j = 0; j < n; j += 4) + for(i = 0; i < 4; ++i) + swizzles[j + i] = LLVMConstInt(LLVMInt1Type(), i == alpha_swizzle ? 0 : 1, 0); + + return LLVMBuildSelect(bld->base.builder, LLVMConstVector(swizzles, n), rgb, alpha, ""); +#else + /* XXX: Use a bitmask, as byte shuffles often end up being translated + * into many PEXTRB. Ideally LLVM X86 code generation should pick this + * automatically for us. */ + + for(j = 0; j < n; j += 4) + for(i = 0; i < 4; ++i) + swizzles[j + i] = LLVMConstInt(LLVMIntType(bld->base.type.width), i == alpha_swizzle ? 0 : ~0, 0); + + /* TODO: Unfortunately constant propagation prevents from using PANDN. And + * on SSE4 we have even better -- PBLENDVB */ + return LLVMBuildOr(bld->base.builder, + LLVMBuildAnd(bld->base.builder, rgb, LLVMConstVector(swizzles, n), ""), + LLVMBuildAnd(bld->base.builder, alpha, LLVMBuildNot(bld->base.builder, LLVMConstVector(swizzles, n), ""), ""), + ""); +#endif + } + for(j = 0; j < n; j += 4) { for(i = 0; i < 4; ++i) { unsigned swizzle; |