glsl: Add "built-in" function to do sign(fp64)
authorElie Tournier <tournier.elie@gmail.com>
Tue, 8 Aug 2017 13:12:35 +0000 (14:12 +0100)
committerMatt Turner <mattst88@gmail.com>
Thu, 10 Jan 2019 00:42:40 +0000 (16:42 -0800)
v2: use mix.

Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
src/compiler/glsl/float64.glsl

index 5f873319b4210a6f391e71665a47a187bc6aa823..31aae3fca2287a2e29997834dab2a08e01c7bac3 100644 (file)
@@ -93,3 +93,13 @@ __fneg64(uint64_t __a)
    a.y = mix(t, a.y, __is_nan(__a));
    return packUint2x32(a);
 }
+
+uint64_t
+__fsign64(uint64_t __a)
+{
+   uvec2 a = unpackUint2x32(__a);
+   uvec2 retval;
+   retval.x = 0u;
+   retval.y = mix((a.y & 0x80000000u) | 0x3FF00000u, 0u, (a.y << 1 | a.x) == 0u);
+   return packUint2x32(retval);
+}