From: Eric Anholt Date: Fri, 27 Jun 2014 14:09:32 +0000 (+0100) Subject: gallium: Add a uif() helper function to complement fui() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bfb0da9fa765242f52dc66a5acb14037ef17be94;p=mesa.git gallium: Add a uif() helper function to complement fui() I found myself often wanting this when I'm printing out a uint32_t mapping of some GPU data, and I want to put in an interpretation of that value as a float. Reviewed-by: Michel Dänzer Reviewed-by: Emil Velikov --- diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index d956fa1c975..2823e0570fc 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -616,6 +616,14 @@ fui( float f ) return fi.ui; } +static INLINE float +uif(uint32_t ui) +{ + union fi fi; + fi.ui = ui; + return fi.f; +} + /** * Convert ubyte to float in [0, 1].