diff options
author | Elie Tournier <[email protected]> | 2017-08-08 13:55:30 +0100 |
---|---|---|
committer | Matt Turner <[email protected]> | 2019-01-09 16:42:40 -0800 |
commit | eac66f024865640a328803b024d9bf025c408e49 (patch) | |
tree | 55de904d6213188a56cab258dbe318423359fefa /src/compiler/glsl | |
parent | 0428951b9d554faae13807e033d40c2e0698dc7b (diff) |
glsl: Add "built-in" functions to do neg(fp64)
v2: use mix.
Signed-off-by: Elie Tournier <[email protected]>
Diffstat (limited to 'src/compiler/glsl')
-rw-r--r-- | src/compiler/glsl/float64.glsl | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/compiler/glsl/float64.glsl b/src/compiler/glsl/float64.glsl index 28e3258e0fb..5f873319b42 100644 --- a/src/compiler/glsl/float64.glsl +++ b/src/compiler/glsl/float64.glsl @@ -43,6 +43,7 @@ #version 430 #extension GL_ARB_gpu_shader_int64 : enable #extension GL_ARB_shader_bit_encoding : enable +#extension GL_EXT_shader_integer_mix : enable #pragma warning(off) @@ -67,3 +68,28 @@ __fabs64(uint64_t __a) a.y &= 0x7FFFFFFFu; return packUint2x32(a); } + +/* Returns 1 if the double-precision floating-point value `a' is a NaN; + * otherwise returns 0. + */ +bool +__is_nan(uint64_t __a) +{ + uvec2 a = unpackUint2x32(__a); + return (0xFFE00000u <= (a.y<<1)) && + ((a.x != 0u) || ((a.y & 0x000FFFFFu) != 0u)); +} + +/* Negate value of a Float64 : + * Toggle the sign bit + */ +uint64_t +__fneg64(uint64_t __a) +{ + uvec2 a = unpackUint2x32(__a); + uint t = a.y; + + t ^= (1u << 31); + a.y = mix(t, a.y, __is_nan(__a)); + return packUint2x32(a); +} |