From: José Fonseca Date: Tue, 18 Aug 2009 12:30:04 +0000 (+0100) Subject: llvmpipe: Code generate logic ops. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4a414d8f876031ffd299e8e0417da1ea7bf9b96b;p=mesa.git llvmpipe: Code generate logic ops. --- diff --git a/src/gallium/drivers/llvmpipe/lp_bld.h b/src/gallium/drivers/llvmpipe/lp_bld.h index a725cbb4740..c2dea1036f6 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld.h +++ b/src/gallium/drivers/llvmpipe/lp_bld.h @@ -118,17 +118,5 @@ lp_build_loop_end(LLVMBuilderRef builder, struct lp_build_loop_state *state); -/** - * Apply a logic op. - * - * src/dst parameters are packed values. It should work regardless the inputs - * are scalars, or a vector. - */ -LLVMValueRef -lp_build_logicop(LLVMBuilderRef builder, - unsigned logicop_func, - LLVMValueRef src, - LLVMValueRef dst); - #endif /* !LP_BLD_H */ diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend.h b/src/gallium/drivers/llvmpipe/lp_bld_blend.h index 36f53dae935..d19e18846c2 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_blend.h +++ b/src/gallium/drivers/llvmpipe/lp_bld_blend.h @@ -91,4 +91,17 @@ lp_build_blend_soa(LLVMBuilderRef builder, LLVMValueRef res[4]); +/** + * Apply a logic op. + * + * src/dst parameters are packed values. It should work regardless the inputs + * are scalars, or a vector. + */ +LLVMValueRef +lp_build_logicop(LLVMBuilderRef builder, + unsigned logicop_func, + LLVMValueRef src, + LLVMValueRef dst); + + #endif /* !LP_BLD_BLEND_H */ diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c b/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c index 37253a6ba22..1e8a035d78e 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c @@ -178,7 +178,14 @@ lp_build_blend_soa(LLVMBuilderRef builder, for (i = 0; i < 4; ++i) { if (blend->colormask & (1 << i)) { - if (blend->blend_enable) { + if (blend->logicop_enable) { + if(!type.floating) { + res[i] = lp_build_logicop(builder, blend->logicop_func, src[i], dst[i]); + } + else + res[i] = dst[i]; + } + else 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; diff --git a/src/gallium/drivers/llvmpipe/lp_bld_logicop.c b/src/gallium/drivers/llvmpipe/lp_bld_logicop.c index a04544d3651..f9202d1a838 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_logicop.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_logicop.c @@ -28,7 +28,7 @@ #include "pipe/p_state.h" -#include "lp_bld.h" +#include "lp_bld_blend.h" LLVMValueRef diff --git a/src/gallium/drivers/llvmpipe/lp_quad_blend.c b/src/gallium/drivers/llvmpipe/lp_quad_blend.c index 976994f4e87..966ac628a95 100644 --- a/src/gallium/drivers/llvmpipe/lp_quad_blend.c +++ b/src/gallium/drivers/llvmpipe/lp_quad_blend.c @@ -45,88 +45,6 @@ #include "lp_quad_pipe.h" -static void -logicop_quad(struct quad_stage *qs, - uint8_t src[][16], - uint8_t dst[][16]) -{ - struct llvmpipe_context *llvmpipe = qs->llvmpipe; - uint32_t *src4 = (uint32_t *) src; - uint32_t *dst4 = (uint32_t *) dst; - uint32_t *res4 = (uint32_t *) src; - uint j; - - switch (llvmpipe->blend->base.logicop_func) { - case PIPE_LOGICOP_CLEAR: - for (j = 0; j < 4; j++) - res4[j] = 0; - break; - case PIPE_LOGICOP_NOR: - for (j = 0; j < 4; j++) - res4[j] = ~(src4[j] | dst4[j]); - break; - case PIPE_LOGICOP_AND_INVERTED: - for (j = 0; j < 4; j++) - res4[j] = ~src4[j] & dst4[j]; - break; - case PIPE_LOGICOP_COPY_INVERTED: - for (j = 0; j < 4; j++) - res4[j] = ~src4[j]; - break; - case PIPE_LOGICOP_AND_REVERSE: - for (j = 0; j < 4; j++) - res4[j] = src4[j] & ~dst4[j]; - break; - case PIPE_LOGICOP_INVERT: - for (j = 0; j < 4; j++) - res4[j] = ~dst4[j]; - break; - case PIPE_LOGICOP_XOR: - for (j = 0; j < 4; j++) - res4[j] = dst4[j] ^ src4[j]; - break; - case PIPE_LOGICOP_NAND: - for (j = 0; j < 4; j++) - res4[j] = ~(src4[j] & dst4[j]); - break; - case PIPE_LOGICOP_AND: - for (j = 0; j < 4; j++) - res4[j] = src4[j] & dst4[j]; - break; - case PIPE_LOGICOP_EQUIV: - for (j = 0; j < 4; j++) - res4[j] = ~(src4[j] ^ dst4[j]); - break; - case PIPE_LOGICOP_NOOP: - for (j = 0; j < 4; j++) - res4[j] = dst4[j]; - break; - case PIPE_LOGICOP_OR_INVERTED: - for (j = 0; j < 4; j++) - res4[j] = ~src4[j] | dst4[j]; - break; - case PIPE_LOGICOP_COPY: - for (j = 0; j < 4; j++) - res4[j] = src4[j]; - break; - case PIPE_LOGICOP_OR_REVERSE: - for (j = 0; j < 4; j++) - res4[j] = src4[j] | ~dst4[j]; - break; - case PIPE_LOGICOP_OR: - for (j = 0; j < 4; j++) - res4[j] = src4[j] | dst4[j]; - break; - case PIPE_LOGICOP_SET: - for (j = 0; j < 4; j++) - res4[j] = ~0; - break; - default: - assert(0); - } -} - - static void blend_begin(struct quad_stage *qs) { } @@ -174,18 +92,12 @@ blend_run(struct quad_stage *qs, } } - - if (blend->base.logicop_enable) { - logicop_quad( qs, src, dst ); - } - else { - assert(blend->jit_function); - assert((((uintptr_t)src) & 0xf) == 0); - assert((((uintptr_t)dst) & 0xf) == 0); - assert((((uintptr_t)llvmpipe->blend_color) & 0xf) == 0); - if(blend->jit_function) - blend->jit_function( src, dst, llvmpipe->blend_color, src ); - } + assert(blend->jit_function); + assert((((uintptr_t)src) & 0xf) == 0); + assert((((uintptr_t)dst) & 0xf) == 0); + assert((((uintptr_t)llvmpipe->blend_color) & 0xf) == 0); + if(blend->jit_function) + blend->jit_function( src, dst, llvmpipe->blend_color, src ); /* Output color values */