diff options
Diffstat (limited to 'src/gallium/auxiliary/util/u_math.h')
-rw-r--r-- | src/gallium/auxiliary/util/u_math.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index b76592d1ec..b2969a210a 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -583,6 +583,18 @@ do { \ #endif +static INLINE uint32_t util_unsigned_fixed(float value, unsigned frac_bits) +{ + return value < 0 ? 0 : (uint32_t)(value * (1<<frac_bits)); +} + +static INLINE int32_t util_signed_fixed(float value, unsigned frac_bits) +{ + return (int32_t)(value * (1<<frac_bits)); +} + + + #ifdef __cplusplus } #endif |