glsl: Add "built-in" function to do ffloor(fp64)
authorMatt Turner <mattst88@gmail.com>
Fri, 9 Nov 2018 05:59:42 +0000 (21:59 -0800)
committerMatt Turner <mattst88@gmail.com>
Thu, 10 Jan 2019 00:42:40 +0000 (16:42 -0800)
Reviewed-by: Elie Tournier <tournier.elie@gmail.com>
src/compiler/glsl/float64.glsl

index 88ce0a749579148a504a2cc43695d95f182928e9..c54835fbf78e4b7d8b1df50c050887ac672886a1 100644 (file)
@@ -1384,6 +1384,19 @@ __ftrunc64(uint64_t __a)
    return packUint2x32(uvec2(zLo, zHi));
 }
 
+uint64_t
+__ffloor64(uint64_t a)
+{
+   bool is_positive = __fge64(a, 0ul);
+   uint64_t tr = __ftrunc64(a);
+
+   if (is_positive || __feq64(tr, a)) {
+      return tr;
+   } else {
+      return __fadd64(tr, 0xbff0000000000000ul /* -1.0 */);
+   }
+}
+
 uint64_t
 __fround64(uint64_t __a)
 {