summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSagar Ghuge <[email protected]>2018-12-03 12:09:38 -0800
committerMatt Turner <[email protected]>2019-01-09 16:42:40 -0800
commitb830efb191279e8fba480356c582d41e7f49ee78 (patch)
tree3891f4add3f2fc0db0df45869686a4ee3b1e3103 /src
parent7c5b982b89a1ec6009226a851206e84294552aa2 (diff)
glsl: Add "built-in" functions to do int64_to_fp64(int64_t)
Reviewed-by: Elie Tournier <[email protected]> Signed-off-by: Sagar Ghuge <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/glsl/float64.glsl18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/compiler/glsl/float64.glsl b/src/compiler/glsl/float64.glsl
index ac6d6221a64..e8f6acc3c30 100644
--- a/src/compiler/glsl/float64.glsl
+++ b/src/compiler/glsl/float64.glsl
@@ -905,6 +905,24 @@ __uint64_to_fp64(uint64_t a)
}
}
+uint64_t
+__int64_to_fp64(int64_t a)
+{
+ if (a==0)
+ return 0ul;
+
+ uint64_t absA = mix(uint64_t(a), uint64_t(-a), a < 0);
+ uint aFracHi = __extractFloat64FracHi(absA);
+ uvec2 aFrac = unpackUint2x32(absA);
+ uint zSign = uint(a < 0);
+
+ if ((aFracHi & 0x80000000u) != 0u) {
+ return mix(0ul, __packFloat64(1, 0x434, 0u, 0u), a < 0);
+ }
+
+ return __normalizeRoundAndPackFloat64(zSign, 0x432, aFrac.y, aFrac.x);
+}
+
/* Returns the result of converting the double-precision floating-point value
* `a' to the 32-bit two's complement integer format. The conversion is
* performed according to the IEEE Standard for Floating-Point Arithmetic---