gallium: Add a uif() helper function to complement fui()
authorEric Anholt <eric@anholt.net>
Fri, 27 Jun 2014 14:09:32 +0000 (15:09 +0100)
committerEric Anholt <eric@anholt.net>
Thu, 31 Jul 2014 05:30:19 +0000 (22:30 -0700)
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 <michel.daenzer@amd.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
src/gallium/auxiliary/util/u_math.h

index d956fa1..2823e05 100644 (file)
@@ -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].