summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util/u_half.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/util/u_half.h')
-rw-r--r--src/gallium/auxiliary/util/u_half.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/util/u_half.h b/src/gallium/auxiliary/util/u_half.h
index 5afdd925a6..50948cadf5 100644
--- a/src/gallium/auxiliary/util/u_half.h
+++ b/src/gallium/auxiliary/util/u_half.h
@@ -8,13 +8,14 @@
extern "C" {
#endif
-
extern uint32_t util_half_to_float_mantissa_table[2048];
extern uint32_t util_half_to_float_exponent_table[64];
extern uint32_t util_half_to_float_offset_table[64];
extern uint16_t util_float_to_half_base_table[512];
extern uint8_t util_float_to_half_shift_table[512];
+void util_half_init_tables(void);
+
/*
* Note that if the half float is a signaling NaN, the x87 FPU will turn
* it into a quiet NaN immediately upon loading into a float.
@@ -30,6 +31,7 @@ static INLINE uint32_t
util_half_to_floatui(half h)
{
unsigned exp = h >> 10;
+ util_half_init_tables();
return util_half_to_float_mantissa_table[util_half_to_float_offset_table[exp] + (h & 0x3ff)]
+ util_half_to_float_exponent_table[exp];
}
@@ -38,6 +40,7 @@ static INLINE float
util_half_to_float(half h)
{
union fi r;
+ util_half_init_tables();
r.ui = util_half_to_floatui(h);
return r.f;
}
@@ -46,6 +49,7 @@ static INLINE half
util_floatui_to_half(uint32_t v)
{
unsigned signexp = v >> 23;
+ util_half_init_tables();
return util_float_to_half_base_table[signexp]
+ ((v & 0x007fffff) >> util_float_to_half_shift_table[signexp]);
}
@@ -54,6 +58,7 @@ static INLINE half
util_float_to_half(float f)
{
union fi i;
+ util_half_init_tables();
i.f = f;
return util_floatui_to_half(i.ui);
}