From ec6e823a99168b7359e76f274641424f778211ef Mon Sep 17 00:00:00 2001 From: Elie Tournier Date: Tue, 8 Aug 2017 14:23:26 +0100 Subject: [PATCH] glsl: Add "built-in" functions to do eq/ne(fp64, fp64) --- src/compiler/glsl/float64.glsl | 56 ++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/compiler/glsl/float64.glsl b/src/compiler/glsl/float64.glsl index 31aae3fca22..2cf85bbcafc 100644 --- a/src/compiler/glsl/float64.glsl +++ b/src/compiler/glsl/float64.glsl @@ -103,3 +103,59 @@ __fsign64(uint64_t __a) retval.y = mix((a.y & 0x80000000u) | 0x3FF00000u, 0u, (a.y << 1 | a.x) == 0u); return packUint2x32(retval); } + +/* Returns the fraction bits of the double-precision floating-point value `a'.*/ +uint +__extractFloat64FracLo(uint64_t a) +{ + return unpackUint2x32(a).x; +} + +uint +__extractFloat64FracHi(uint64_t a) +{ + return unpackUint2x32(a).y & 0x000FFFFFu; +} + +/* Returns the exponent bits of the double-precision floating-point value `a'.*/ +int +__extractFloat64Exp(uint64_t __a) +{ + uvec2 a = unpackUint2x32(__a); + return int((a.y>>20) & 0x7FFu); +} + +bool +__feq64_nonnan(uint64_t __a, uint64_t __b) +{ + uvec2 a = unpackUint2x32(__a); + uvec2 b = unpackUint2x32(__b); + return (a.x == b.x) && + ((a.y == b.y) || ((a.x == 0u) && (((a.y | b.y)<<1) == 0u))); +} + +/* Returns true if the double-precision floating-point value `a' is equal to the + * corresponding value `b', and false otherwise. The comparison is performed + * according to the IEEE Standard for Floating-Point Arithmetic. + */ +bool +__feq64(uint64_t a, uint64_t b) +{ + if (__is_nan(a) || __is_nan(b)) + return false; + + return __feq64_nonnan(a, b); +} + +/* Returns true if the double-precision floating-point value `a' is not equal + * to the corresponding value `b', and false otherwise. The comparison is + * performed according to the IEEE Standard for Floating-Point Arithmetic. + */ +bool +__fne64(uint64_t a, uint64_t b) +{ + if (__is_nan(a) || __is_nan(b)) + return true; + + return !__feq64_nonnan(a, b); +} -- 2.30.2