[Mesa-dev] [PATCH] Improve ONE_DIV_LN2 and M_PI constants

Matt Turner mattst88 at gmail.com
Wed Dec 1 13:40:58 PST 2010


1/ln(2) is equivalent to log2(e), so define it as such.

log2(e) = ln(e)/ln(2) = 1/ln(2)

M_PI is updated to add some precision (value found in my math.h header).

Signed-off-by: Matt Turner <mattst88 at gmail.com>
---
 src/mesa/main/compiler.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h
index 5557a3b..4c52be2 100644
--- a/src/mesa/main/compiler.h
+++ b/src/mesa/main/compiler.h
@@ -351,7 +351,7 @@ static INLINE GLuint CPU_TO_LE32(GLuint x)
 
 
 #ifndef M_PI
-#define M_PI (3.1415926536)
+#define M_PI (3.14159265358979323846)
 #endif
 
 #ifndef M_E
@@ -363,7 +363,7 @@ static INLINE GLuint CPU_TO_LE32(GLuint x)
 #endif
 
 #ifndef ONE_DIV_LN2
-#define ONE_DIV_LN2 (1.442695040888963456)
+#define ONE_DIV_LN2 M_LOG2E
 #endif
 
 #ifndef ONE_DIV_SQRT_LN2
-- 
1.7.2.2



More information about the mesa-dev mailing list