util: move util_half_to_float code into _mesa_half_to_float_slow

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6774>
This commit is contained in:
Marek Olšák 2020-09-18 05:48:05 -04:00 committed by Marge Bot
parent 87900afe5b
commit 5af81393e4
2 changed files with 24 additions and 24 deletions

View File

@ -110,29 +110,7 @@ util_float_to_half_rtz(float f)
static inline float
util_half_to_float(uint16_t f16)
{
union fi infnan;
union fi magic;
union fi f32;
infnan.ui = 0x8f << 23;
infnan.f = 65536.0f;
magic.ui = 0xef << 23;
/* Exponent / Mantissa */
f32.ui = (f16 & 0x7fff) << 13;
/* Adjust */
f32.f *= magic.f;
/* XXX: The magic mul relies on denorms being available */
/* Inf / NaN */
if (f32.f >= infnan.f)
f32.ui |= 0xff << 23;
/* Sign */
f32.ui |= (uint32_t)(f16 & 0x8000) << 16;
return f32.f;
return _mesa_half_to_float(f16);
}
#ifdef __cplusplus

View File

@ -142,7 +142,29 @@ _mesa_float_to_float16_rtz_slow(float val)
float
_mesa_half_to_float_slow(uint16_t val)
{
return util_half_to_float(val);
union fi infnan;
union fi magic;
union fi f32;
infnan.ui = 0x8f << 23;
infnan.f = 65536.0f;
magic.ui = 0xef << 23;
/* Exponent / Mantissa */
f32.ui = (val & 0x7fff) << 13;
/* Adjust */
f32.f *= magic.f;
/* XXX: The magic mul relies on denorms being available */
/* Inf / NaN */
if (f32.f >= infnan.f)
f32.ui |= 0xff << 23;
/* Sign */
f32.ui |= (uint32_t)(val & 0x8000) << 16;
return f32.f;
}
/**