summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Benton <[email protected]>2012-04-19 18:13:13 +0100
committerJosé Fonseca <[email protected]>2012-05-02 10:23:52 +0100
commit16b081f1b0acf3158423c9fbed69c85807ce5276 (patch)
tree3180cef916199bb8928a98c26d106985359ff6ac
parent9bc58d941ac32d10c6b4c601e0c4c6e00876d738 (diff)
llvmpipe: add masking support to aos blend
Signed-off-by: José Fonseca <[email protected]>
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_blend.h1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c38
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_blend.c2
3 files changed, 35 insertions, 6 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend.h b/src/gallium/drivers/llvmpipe/lp_bld_blend.h
index 00838a66342..c0c95a27129 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_blend.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_blend.h
@@ -69,6 +69,7 @@ lp_build_blend_aos(struct gallivm_state *gallivm,
unsigned rt,
LLVMValueRef src,
LLVMValueRef dst,
+ LLVMValueRef mask,
LLVMValueRef const_,
const unsigned char swizzle[4]);
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
index 678dac81f28..e67286baf5e 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
@@ -52,6 +52,7 @@
#include "gallivm/lp_bld_arit.h"
#include "gallivm/lp_bld_logic.h"
#include "gallivm/lp_bld_swizzle.h"
+#include "gallivm/lp_bld_bitarit.h"
#include "gallivm/lp_bld_debug.h"
#include "lp_bld_blend.h"
@@ -301,6 +302,21 @@ lp_build_blend_func(struct lp_build_context *bld,
}
+/**
+ * Performs blending of src and dst pixels
+ *
+ * @param blend the blend state of the shader variant
+ * @param cbuf_format format of the colour buffer
+ * @param type data type of the pixel vector
+ * @param rt rt number
+ * @param src blend src
+ * @param dst blend dst
+ * @param mask optional mask to apply to the blending result
+ * @param const_ const blend color
+ * @param swizzle swizzle values for RGBA
+ *
+ * @return the result of blending src and dst
+ */
LLVMValueRef
lp_build_blend_aos(struct gallivm_state *gallivm,
const struct pipe_blend_state *blend,
@@ -309,6 +325,7 @@ lp_build_blend_aos(struct gallivm_state *gallivm,
unsigned rt,
LLVMValueRef src,
LLVMValueRef dst,
+ LLVMValueRef mask,
LLVMValueRef const_,
const unsigned char swizzle[4])
{
@@ -358,22 +375,33 @@ lp_build_blend_aos(struct gallivm_state *gallivm,
}
}
- /* Apply color masking if necessary */
+ /* Check if color mask is necessary */
fullcolormask = util_format_colormask_full(util_format_description(cbuf_format[rt]), blend->rt[rt].colormask);
if (!fullcolormask) {
- LLVMValueRef mask;
- unsigned mask_swizzle;
+ LLVMValueRef color_mask;
+ unsigned color_mask_swizzle;
/* Swizzle the color mask to ensure it matches target format */
- mask_swizzle =
+ color_mask_swizzle =
((blend->rt[rt].colormask & (1 << swizzle[0])) >> swizzle[0])
| (((blend->rt[rt].colormask & (1 << swizzle[1])) >> swizzle[1]) << 1)
| (((blend->rt[rt].colormask & (1 << swizzle[2])) >> swizzle[2]) << 2)
| (((blend->rt[rt].colormask & (1 << swizzle[3])) >> swizzle[3]) << 3);
- mask = lp_build_const_mask_aos(gallivm, bld.base.type, mask_swizzle);
+ color_mask = lp_build_const_mask_aos(gallivm, bld.base.type, color_mask_swizzle);
+ lp_build_name(color_mask, "color_mask");
+
+ /* Combine with input mask if necessary */
+ if (mask) {
+ mask = lp_build_and(&bld.base, color_mask, mask);
+ } else {
+ mask = color_mask;
+ }
+ }
+ /* Apply mask, if one exists */
+ if (mask) {
result = lp_build_select(&bld.base, mask, result, dst);
}
diff --git a/src/gallium/drivers/llvmpipe/lp_test_blend.c b/src/gallium/drivers/llvmpipe/lp_test_blend.c
index af66ac388f7..51324cbb6a3 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_blend.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_blend.c
@@ -207,7 +207,7 @@ add_blend_test(struct gallivm_state *gallivm,
dst = LLVMBuildLoad(builder, dst_ptr, "dst");
con = LLVMBuildLoad(builder, const_ptr, "const");
- res = lp_build_blend_aos(gallivm, blend, &format, type, rt, src, dst, con, swizzle);
+ res = lp_build_blend_aos(gallivm, blend, &format, type, rt, src, dst, NULL, con, swizzle);
lp_build_name(res, "res");