Mesa (master): llvmpipe: add masking support to aos blend
Jose Fonseca
jrfonseca at kemper.freedesktop.org
Wed May 2 09:25:58 UTC 2012
Module: Mesa
Branch: master
Commit: 16b081f1b0acf3158423c9fbed69c85807ce5276
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=16b081f1b0acf3158423c9fbed69c85807ce5276
Author: James Benton <jbenton at vmware.com>
Date: Thu Apr 19 18:13:13 2012 +0100
llvmpipe: add masking support to aos blend
Signed-off-by: José Fonseca <jfonseca at vmware.com>
---
src/gallium/drivers/llvmpipe/lp_bld_blend.h | 1 +
src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c | 38 ++++++++++++++++++++---
src/gallium/drivers/llvmpipe/lp_test_blend.c | 2 +-
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 00838a6..c0c95a2 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 678dac8..e67286b 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 af66ac3..51324cb 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");
More information about the mesa-commit
mailing list