Mesa (gallium-0.2): util: Optimise log2().

Michał Król michal at kemper.freedesktop.org
Wed Nov 12 18:04:22 UTC 2008


Module: Mesa
Branch: gallium-0.2
Commit: c5ba8ba9182a6946ee489241738457b1370b3c77
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c5ba8ba9182a6946ee489241738457b1370b3c77

Author: Michal Krol <michal at tungstengraphics.com>
Date:   Wed Nov 12 19:01:46 2008 +0100

util: Optimise log2().

---

 src/gallium/auxiliary/util/u_math.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
index 6227211..fdaec8d 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -163,7 +163,8 @@ static INLINE float logf( float f )
 
 static INLINE double log2( double x )
 {
-   return log( x ) / log( 2.0 );
+   const double invln2 = 1.442695041;
+   return log( x ) * invln2;
 }
 
 #else




More information about the mesa-commit mailing list