mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 11:18:08 +02:00
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 <sagar.ghuge@intel.com> Reviewed-by: Elie Tournier <elie.tournier@collabora.com> Acked-by: Anuj Phogat <anuj.phogat@gmail.com>
This commit is contained in:
parent
e8f4c9f56c
commit
06807e1948
1 changed files with 12 additions and 9 deletions
|
|
@ -1693,17 +1693,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;
|
||||
}
|
||||
|
|
@ -1720,9 +1725,7 @@ __fround64(uint64_t __a)
|
|||
aLo &= ~maskExp;
|
||||
}
|
||||
|
||||
a.x = aLo;
|
||||
a.y = aHi;
|
||||
return packUint2x32(a);
|
||||
return packUint2x32(uvec2(aLo, aHi));
|
||||
}
|
||||
|
||||
uint64_t
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue