summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/gallivm
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2013-08-15 13:10:22 -0400
committerZack Rusin <[email protected]>2013-08-15 16:26:32 -0400
commit7115bc3940c4c1952d503d9d56ebe6fd1fb11645 (patch)
tree53e95c9973f39b3baaf476b968725617c11ce02d /src/gallium/auxiliary/gallivm
parent035bf2198368d3fa69387788a63039d71319f0bf (diff)
draw: handle nan clipdistance
If clipdistance for one of the vertices is nan (or inf) then the entire primitive should be discarded. Signed-off-by: Zack Rusin <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/gallivm')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_arit.c26
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_arit.h6
2 files changed, 32 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
index 98409c3be86..f7daabc639e 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
@@ -3671,3 +3671,29 @@ lp_build_isfinite(struct lp_build_context *bld,
return lp_build_compare(bld->gallivm, int_type, PIPE_FUNC_NOTEQUAL,
intx, infornan32);
}
+
+/*
+ * Returns true if the number is nan or inf and false otherwise.
+ * The input has to be a floating point vector.
+ */
+LLVMValueRef
+lp_build_is_inf_or_nan(struct gallivm_state *gallivm,
+ const struct lp_type type,
+ LLVMValueRef x)
+{
+ LLVMBuilderRef builder = gallivm->builder;
+ struct lp_type int_type = lp_int_type(type);
+ LLVMValueRef const0 = lp_build_const_int_vec(gallivm, int_type,
+ 0x7f800000);
+ LLVMValueRef ret;
+
+ assert(type.floating);
+
+ ret = LLVMBuildBitCast(builder, x, lp_build_vec_type(gallivm, int_type), "");
+ ret = LLVMBuildAnd(builder, ret, const0, "");
+ ret = lp_build_compare(gallivm, int_type, PIPE_FUNC_EQUAL,
+ ret, const0);
+
+ return ret;
+}
+
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.h b/src/gallium/auxiliary/gallivm/lp_bld_arit.h
index 35119d18f7b..d98025e42e3 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.h
@@ -42,6 +42,7 @@
struct lp_type;
struct lp_build_context;
+struct gallivm_state;
/**
@@ -353,4 +354,9 @@ lp_build_isfinite(struct lp_build_context *bld,
LLVMValueRef x);
+LLVMValueRef
+lp_build_is_inf_or_nan(struct gallivm_state *gallivm,
+ const struct lp_type type,
+ LLVMValueRef x);
+
#endif /* !LP_BLD_ARIT_H */