diff options
author | Sagar Ghuge <[email protected]> | 2018-11-30 11:50:44 -0800 |
---|---|---|
committer | Matt Turner <[email protected]> | 2019-01-09 16:42:40 -0800 |
commit | 7c5b982b89a1ec6009226a851206e84294552aa2 (patch) | |
tree | 24f5e80f0f1ecf26585c65a9f1bcb89e651ea3d9 | |
parent | 15757bc80b89aa47d3c68e2d785b1a94cf4e3a01 (diff) |
glsl: Add "built-in" functions to do uint64_to_fp64(uint64_t)
Reviewed-by: Elie Tournier <[email protected]>
Signed-off-by: Sagar Ghuge <[email protected]>
-rw-r--r-- | src/compiler/glsl/float64.glsl | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/compiler/glsl/float64.glsl b/src/compiler/glsl/float64.glsl index 1808fec0727..ac6d6221a64 100644 --- a/src/compiler/glsl/float64.glsl +++ b/src/compiler/glsl/float64.glsl @@ -887,6 +887,24 @@ __uint_to_fp64(uint a) return __packFloat64(0u, 0x432 - shiftDist, aHigh, aLow); } +uint64_t +__uint64_to_fp64(uint64_t a) +{ + if (a == 0u) + return 0ul; + + uvec2 aFrac = unpackUint2x32(a); + uint aFracLo = __extractFloat64FracLo(a); + uint aFracHi = __extractFloat64FracHi(a); + + if ((aFracHi & 0x80000000u) != 0u) { + __shift64RightJamming(aFracHi, aFracLo, 1, aFracHi, aFracLo); + return __roundAndPackFloat64(0, 0x433, aFracHi, aFracLo, 0u); + } else { + return __normalizeRoundAndPackFloat64(0, 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--- |