From 5c9a659f50d40bc7de291ed38cb1d6c76c15e731 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Thu, 8 Nov 2018 21:59:42 -0800 Subject: [PATCH] glsl: Add "built-in" function to do ffloor(fp64) Reviewed-by: Elie Tournier --- src/compiler/glsl/float64.glsl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/compiler/glsl/float64.glsl b/src/compiler/glsl/float64.glsl index 88ce0a74957..c54835fbf78 100644 --- a/src/compiler/glsl/float64.glsl +++ b/src/compiler/glsl/float64.glsl @@ -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) { -- 2.30.2