diff options
author | Elie Tournier <[email protected]> | 2017-08-09 11:41:13 +0100 |
---|---|---|
committer | Matt Turner <[email protected]> | 2019-01-09 16:42:40 -0800 |
commit | cbf090b809bd8e74c0def50551b580585092d664 (patch) | |
tree | 3c77ba696e636c28a5c9e29ab240c71478da29a5 | |
parent | a3551ee61f8e3622b4755d6271b9bd5b40de0cb8 (diff) |
glsl: Add "built-in" functions to do uint_to_fp64(uint)
Signed-off-by: Elie Tournier <[email protected]>
-rw-r--r-- | src/compiler/glsl/float64.glsl | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/compiler/glsl/float64.glsl b/src/compiler/glsl/float64.glsl index f7952413fad..232bf18b4d3 100644 --- a/src/compiler/glsl/float64.glsl +++ b/src/compiler/glsl/float64.glsl @@ -858,3 +858,25 @@ __fp64_to_uint(uint64_t a) return mix(z, expt, (aSign != 0u) && (z != 0u)); } + +uint64_t +__uint_to_fp64(uint a) +{ + if (a == 0u) + return 0ul; + + int shiftDist = __countLeadingZeros32(a) + 21; + + uint aHigh = 0u; + uint aLow = 0u; + int negCount = (- shiftDist) & 31; + + aHigh = mix(0u, a<< shiftDist - 32, shiftDist < 64); + aLow = 0u; + aHigh = mix(aHigh, 0u, shiftDist == 0); + aLow = mix(aLow, a, shiftDist ==0); + aHigh = mix(aHigh, a >> negCount, shiftDist < 32); + aLow = mix(aLow, a << shiftDist, shiftDist < 32); + + return __packFloat64(0u, 0x432 - shiftDist, aHigh, aLow); +} |