From 1dd7bb17c7331f9ecd0bc830b61ada235a56fe6d Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 4 Aug 2009 12:09:52 +0100 Subject: llvmpipe: Optimize blend swizzles by using bitmasks instead of shuffles for ubytes. --- src/gallium/drivers/llvmpipe/lp_bld_const.c | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/gallium/drivers/llvmpipe/lp_bld_const.c') diff --git a/src/gallium/drivers/llvmpipe/lp_bld_const.c b/src/gallium/drivers/llvmpipe/lp_bld_const.c index 44fcc467f4..fe1c627eee 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_const.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_const.c @@ -143,3 +143,38 @@ lp_build_const_aos(union lp_type type, return LLVMConstVector(elems, type.length); } + + +LLVMValueRef +lp_build_const_shift(union lp_type type, + int c) +{ + LLVMTypeRef elem_type = LLVMIntType(type.width); + LLVMValueRef elems[LP_MAX_VECTOR_LENGTH]; + unsigned i; + + assert(type.length <= LP_MAX_VECTOR_LENGTH); + + for(i = 0; i < type.length; ++i) + elems[i] = LLVMConstInt(elem_type, c, 0); + + return LLVMConstVector(elems, type.length); +} + + +LLVMValueRef +lp_build_const_mask_aos(union lp_type type, + boolean cond[4]) +{ + LLVMTypeRef elem_type = LLVMIntType(type.width); + LLVMValueRef masks[LP_MAX_VECTOR_LENGTH]; + unsigned i, j; + + assert(type.length <= LP_MAX_VECTOR_LENGTH); + + for(j = 0; j < type.length; j += 4) + for(i = 0; i < 4; ++i) + masks[j + i] = LLVMConstInt(elem_type, cond[i] ? ~0 : 0, 0); + + return LLVMConstVector(masks, type.length); +} -- cgit v1.2.3