diff options
author | Elie Tournier <tournier.elie@gmail.com> | 2017-08-08 14:23:26 +0100 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2019-01-09 16:42:40 -0800 |
commit | ec6e823a99168b7359e76f274641424f778211ef (patch) | |
tree | f0a755fdfecdf01b905f0cb2e1542fa56d19065d /src | |
parent | c802cdde9df1295fe0d6d6a3dbf4151f46070d19 (diff) |
glsl: Add "built-in" functions to do eq/ne(fp64, fp64)
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/glsl/float64.glsl | 56 |
1 files changed, 56 insertions, 0 deletions
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); +} |