aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorElie Tournier <[email protected]>2017-08-08 14:42:56 +0100
committerMatt Turner <[email protected]>2019-01-09 16:42:40 -0800
commitc036fc97a21d6bf1f7a6ffec9932fb8a79ac262c (patch)
tree329415eebd4aae20a259ec5ccf8ada844cb4b9bc /src
parent3e4d5ea7b8dda32ee6a8a2d23f6ab4f00f4334e7 (diff)
glsl: Add "built-in" functions to do lt(fp64, fp64)
Signed-off-by: Elie Tournier <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/glsl/float64.glsl50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/compiler/glsl/float64.glsl b/src/compiler/glsl/float64.glsl
index 5f2804a8a34..a2642e9b34e 100644
--- a/src/compiler/glsl/float64.glsl
+++ b/src/compiler/glsl/float64.glsl
@@ -166,3 +166,53 @@ __extractFloat64Sign(uint64_t a)
{
return unpackUint2x32(a).y >> 31;
}
+
+/* Returns true if the 64-bit value formed by concatenating `a0' and `a1' is less
+ * than the 64-bit value formed by concatenating `b0' and `b1'. Otherwise,
+ * returns false.
+ */
+bool
+lt64(uint a0, uint a1, uint b0, uint b1)
+{
+ return (a0 < b0) || ((a0 == b0) && (a1 < b1));
+}
+
+bool
+__flt64_nonnan(uint64_t __a, uint64_t __b)
+{
+ uvec2 a = unpackUint2x32(__a);
+ uvec2 b = unpackUint2x32(__b);
+ uint aSign = __extractFloat64Sign(__a);
+ uint bSign = __extractFloat64Sign(__b);
+ if (aSign != bSign)
+ return (aSign != 0u) && ((((a.y | b.y)<<1) | a.x | b.x) != 0u);
+
+ return mix(lt64(a.y, a.x, b.y, b.x), lt64(b.y, b.x, a.y, a.x), aSign != 0u);
+}
+
+/* Returns true if the double-precision floating-point value `a' is less than
+ * the corresponding value `b', and false otherwise. The comparison is performed
+ * according to the IEEE Standard for Floating-Point Arithmetic.
+ */
+bool
+__flt64(uint64_t a, uint64_t b)
+{
+ if (__is_nan(a) || __is_nan(b))
+ return false;
+
+ return __flt64_nonnan(a, b);
+}
+
+/* Returns true if the double-precision floating-point value `a' is greater
+ * than or equal to * the corresponding value `b', and false otherwise. The
+ * comparison is performed * according to the IEEE Standard for Floating-Point
+ * Arithmetic.
+ */
+bool
+__fge64(uint64_t a, uint64_t b)
+{
+ if (__is_nan(a) || __is_nan(b))
+ return false;
+
+ return !__flt64_nonnan(a, b);
+}