Forgot to mention, this passes the piglit arb_blend_func_extended tests.
Oh and I forgot to remove the load_shader_output function in this patch
(this was an attempt to factor out some more code but ultimately I
reverted it as it made the code no bit simpler).
Roland
Am 08.02.2013 04:19, schrieb srol...@vmware.com:
> From: Roland Scheidegger
>
> link up the fs outputs and blend inputs, and make sure the second blend source
> is correctly loaded and converted (which is quite complex).
> There's a slight refactoring of the monster generate_unswizzled_blend()
> function where it makes sense to factor out alpha conversion (which needs
> to run twice for dual source blend).
> ---
> src/gallium/drivers/llvmpipe/lp_bld_blend.h |1 +
> src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c | 13 +-
> src/gallium/drivers/llvmpipe/lp_screen.c|2 +-
> src/gallium/drivers/llvmpipe/lp_state_fs.c | 331
> +--
> src/gallium/drivers/llvmpipe/lp_test_blend.c|3 +-
> 5 files changed, 257 insertions(+), 93 deletions(-)
>
> diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend.h
> b/src/gallium/drivers/llvmpipe/lp_bld_blend.h
> index 4bd2867..249a345 100644
> --- a/src/gallium/drivers/llvmpipe/lp_bld_blend.h
> +++ b/src/gallium/drivers/llvmpipe/lp_bld_blend.h
> @@ -62,6 +62,7 @@ lp_build_blend_aos(struct gallivm_state *gallivm,
> LLVMValueRef src,
> LLVMValueRef src_alpha,
> LLVMValueRef src1,
> + LLVMValueRef src1_alpha,
> LLVMValueRef dst,
> LLVMValueRef mask,
> LLVMValueRef const_,
> diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
> b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
> index 8e9e7fe..c4d04a2 100644
> --- a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
> +++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
> @@ -70,6 +70,7 @@ struct lp_build_blend_aos_context
> LLVMValueRef src;
> LLVMValueRef src_alpha;
> LLVMValueRef src1;
> + LLVMValueRef src1_alpha;
> LLVMValueRef dst;
> LLVMValueRef const_;
> LLVMValueRef const_alpha;
> @@ -94,6 +95,7 @@ lp_build_blend_factor_unswizzled(struct
> lp_build_blend_aos_context *bld,
> boolean alpha)
> {
> LLVMValueRef src_alpha = bld->src_alpha ? bld->src_alpha : bld->src;
> + LLVMValueRef src1_alpha = bld->src1_alpha ? bld->src1_alpha : bld->src1;
> LLVMValueRef const_alpha = bld->const_alpha ? bld->const_alpha :
> bld->const_;
>
> switch (factor) {
> @@ -123,8 +125,9 @@ lp_build_blend_factor_unswizzled(struct
> lp_build_blend_aos_context *bld,
> case PIPE_BLENDFACTOR_CONST_ALPHA:
>return const_alpha;
> case PIPE_BLENDFACTOR_SRC1_COLOR:
> - case PIPE_BLENDFACTOR_SRC1_ALPHA:
>return bld->src1;
> + case PIPE_BLENDFACTOR_SRC1_ALPHA:
> + return src1_alpha;
> case PIPE_BLENDFACTOR_INV_SRC_COLOR:
>if(!bld->inv_src)
> bld->inv_src = lp_build_comp(&bld->base, bld->src);
> @@ -147,8 +150,9 @@ lp_build_blend_factor_unswizzled(struct
> lp_build_blend_aos_context *bld,
> bld->inv_const_alpha = lp_build_comp(&bld->base, const_alpha);
>return bld->inv_const_alpha;
> case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
> - case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
>return lp_build_comp(&bld->base, bld->src1);
> + case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
> + return lp_build_comp(&bld->base, src1_alpha);
> default:
>assert(0);
>return bld->base.zero;
> @@ -265,10 +269,13 @@ lp_build_blend_factor(struct lp_build_blend_aos_context
> *bld,
> * @param type data type of the pixel vector
> * @param rtrender target index
> * @param src blend src
> + * @param src_alpha blend src alpha (if not included in src)
> * @param src1 second blend src (for dual source blend)
> + * @param src1_alphasecond blend src alpha (if not included in src1)
> * @param dst blend dst
> * @param mask optional mask to apply to the blending result
> * @param const_const blend color
> + * @param const_alpha const blend color alpha (if not included in const_)
> * @param swizzle swizzle values for RGBA
> *
> * @return the result of blending src and dst
> @@ -282,6 +289,7 @@ lp_build_blend_aos(struct gallivm_state *gallivm,
> LLVMValueRef src,
> LLVMValueRef src_alpha,
> LLVMValueRef src1,
> + LLVMValueRef src1_alpha,
> LLVMValueRef dst,
> LLVMValueRef mask,
> LLVMValueRef const_,
> @@ -307,6 +315,7 @@ lp_build_blend_aos(struct gallivm_state *gallivm,
> bld.dst = dst;
> bld.const_ = const_;
> bld.src_alpha = src_alpha;
> + bld.src1_alpha = src1_alpha;
> bld.const_alpha = const_alpha;
>
> /*