diff options
author | Sagar Ghuge <[email protected]> | 2019-06-24 15:10:53 -0700 |
---|---|---|
committer | Juan A. Suarez Romero <[email protected]> | 2019-06-26 17:32:00 +0000 |
commit | 6fbe0eea2614e4748d18ba633f976e4ecfd943ab (patch) | |
tree | b80e837aac92fe8c3309a6937a1e3cb1e94a835c | |
parent | 3e1c46f233d680e313ad3458a32d540980c62018 (diff) |
glsl: Fix round64 conversion function
Fix round64 function to handle round to nearest even cases specially
with positive and negative numbers with fraction part 0.5.
v2: 1) Simplify unused bits (Elie Tournier)
Fixes:
KHR-GL45.gpu_shader_fp64.builtin.round_dvec2
KHR-GL45.gpu_shader_fp64.builtin.round_dvec3
KHR-GL45.gpu_shader_fp64.builtin.round_dvec4
KHR-GL45.gpu_shader_fp64.builtin.roundeven_double
KHR-GL45.gpu_shader_fp64.builtin.roundeven_dvec2
KHR-GL45.gpu_shader_fp64.builtin.roundeven_dvec3
KHR-GL45.gpu_shader_fp64.builtin.roundeven_dvec4
Signed-off-by: Sagar Ghuge <[email protected]>
Reviewed-by: Elie Tournier <[email protected]>
Acked-by: Anuj Phogat <[email protected]>
(cherry picked from commit 06807e1948f1bced9806b00908c892f1e3c3db5b)
-rw-r--r-- | src/compiler/glsl/float64.glsl | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/compiler/glsl/float64.glsl b/src/compiler/glsl/float64.glsl index 415dde3907c..c92577c4e4c 100644 --- a/src/compiler/glsl/float64.glsl +++ b/src/compiler/glsl/float64.glsl @@ -1681,17 +1681,22 @@ __fround64(uint64_t __a) if (unbiasedExp < 20) { if (unbiasedExp < 0) { + if ((aHi & 0x80000000u) != 0u && aLo == 0u) { + return 0; + } aHi &= 0x80000000u; - if (unbiasedExp == -1 && aLo != 0u) - aHi |= (1023u << 20); + if ((a.y & 0x000FFFFFu) == 0u && a.x == 0u) { + aLo = 0u; + return packUint2x32(uvec2(aLo, aHi)); + } + aHi = mix(aHi, (aHi | 0x3FF00000u), unbiasedExp == -1); aLo = 0u; } else { uint maskExp = 0x000FFFFFu >> unbiasedExp; - /* a is an integral value */ - if (((aHi & maskExp) == 0u) && (aLo == 0u)) - return __a; - + uint lastBit = maskExp + 1; aHi += 0x00080000u >> unbiasedExp; + if ((aHi & maskExp) == 0u) + aHi &= ~lastBit; aHi &= ~maskExp; aLo = 0u; } @@ -1708,9 +1713,7 @@ __fround64(uint64_t __a) aLo &= ~maskExp; } - a.x = aLo; - a.y = aHi; - return packUint2x32(a); + return packUint2x32(uvec2(aLo, aHi)); } uint64_t |