Commit 5af81393 authored by Marek Olšák's avatar Marek Olšák Committed by Marge Bot

util: move util_half_to_float code into _mesa_half_to_float_slow

Acked-by: Pierre-Eric Pelloux-Prayer's avatarPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <mesa/mesa!6774>
parent 87900afe
...@@ -110,29 +110,7 @@ util_float_to_half_rtz(float f) ...@@ -110,29 +110,7 @@ util_float_to_half_rtz(float f)
static inline float static inline float
util_half_to_float(uint16_t f16) util_half_to_float(uint16_t f16)
{ {
union fi infnan; return _mesa_half_to_float(f16);
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;
} }
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -142,7 +142,29 @@ _mesa_float_to_float16_rtz_slow(float val) ...@@ -142,7 +142,29 @@ _mesa_float_to_float16_rtz_slow(float val)
float float
_mesa_half_to_float_slow(uint16_t val) _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;
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment