Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-01-19 16:41:04 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-01-20 13:26:24 +0300
commita1570562f32d8de654fcb2f2770d8fa3933da601 (patch)
tree9026a8634cadc3d3f87b9e3501fc1aa209c67ec0 /intern/cycles
parent46926b4b117008cdb31b2a7fd3fc780f7c20134d (diff)
Cycles: Add fast-math safe isnan and isfinite
Currently unused, but might become really handy in the future.
Diffstat (limited to 'intern/cycles')
-rw-r--r--intern/cycles/util/util_math.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h
index 6cb68b53d16..d0062646414 100644
--- a/intern/cycles/util/util_math.h
+++ b/intern/cycles/util/util_math.h
@@ -1233,6 +1233,20 @@ ccl_device_inline float __uint_as_float(uint i)
return u.f;
}
+/* Versions of functions which are safe for fast math. */
+ccl_device_inline bool isnan_safe(float f)
+{
+ unsigned int x = __float_as_uint(f);
+ return (x << 1) > 0xff000000u;
+}
+
+ccl_device_inline bool isfinite_safe(float f)
+{
+ /* By IEEE 754 rule, 2*Inf equals Inf */
+ unsigned int x = __float_as_uint(f);
+ return (f == f) && (x == 0 || (f != 2.0f*f));
+}
+
/* Interpolation */
template<class A, class B> A lerp(const A& a, const A& b, const B& t)