summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/llvmpipe/lp_bld_blend.c
diff options
context:
space:
mode:
authorSi Chen <sichen@vmware.com>2013-12-18 02:17:55 -0800
committerJosé Fonseca <jfonseca@vmware.com>2014-01-07 16:04:42 +0000
commit72c6d0e506ad0e8262dddbc7a7cf2d6813761753 (patch)
treee05ac43e669da8a3cf09a7631e9fbb0d171623e4 /src/gallium/drivers/llvmpipe/lp_bld_blend.c
parent2a0fb946e147f5482c93702fbf46ffdf5208f57c (diff)
llvmpipe: Implement alpha_to_coverage for non-MSAA framebuffers.
Implement Alpha to Coverage by discarding a fragment alpha component is less than 0.5. This is a joint work of Jose and Si. Reviewed-by: José Fonseca <jfonseca@vmware.com> Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_bld_blend.c')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_blend.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend.c b/src/gallium/drivers/llvmpipe/lp_bld_blend.c
index 1dab28cedf..1de43f77ee 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_blend.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_blend.c
@@ -30,6 +30,11 @@
#include "gallivm/lp_bld_type.h"
#include "gallivm/lp_bld_arit.h"
+#include "gallivm/lp_bld_const.h"
+#include "gallivm/lp_bld_logic.h"
+#include "gallivm/lp_bld_swizzle.h"
+#include "gallivm/lp_bld_flow.h"
+#include "gallivm/lp_bld_debug.h"
#include "lp_bld_blend.h"
@@ -191,3 +196,28 @@ lp_build_blend(struct lp_build_context *bld,
dst_term = lp_build_mul(bld, dst, dst_factor);
return lp_build_blend_func(bld, func, src_term, dst_term);
}
+
+void
+lp_build_alpha_to_coverage(struct gallivm_state *gallivm,
+ struct lp_type type,
+ struct lp_build_mask_context *mask,
+ LLVMValueRef alpha,
+ boolean do_branch)
+{
+ struct lp_build_context bld;
+ LLVMValueRef test;
+ LLVMValueRef alpha_ref_value;
+
+ lp_build_context_init(&bld, gallivm, type);
+
+ alpha_ref_value = lp_build_const_vec(gallivm, type, 0.5);
+
+ test = lp_build_cmp(&bld, PIPE_FUNC_GREATER, alpha, alpha_ref_value);
+
+ lp_build_name(test, "alpha_to_coverage");
+
+ lp_build_mask_update(mask, test);
+
+ if (do_branch)
+ lp_build_mask_check(mask);
+}