From: José Fonseca Date: Mon, 3 Aug 2009 01:06:42 +0000 (+0100) Subject: llvmpipe: Improve generated 8bit blending code. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9e922444403d704f9ed0cf50e510fba53c736b57;p=mesa.git llvmpipe: Improve generated 8bit blending code. --- 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;