Mesa (master): mesa: replace ONE_DIV_LN2 constant with M_LOG2E
Brian Paul
brianp at kemper.freedesktop.org
Sat May 7 14:10:28 UTC 2011
Module: Mesa
Branch: master
Commit: ebc0b2dca0eb6510189d433851bd475475e69aa6
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ebc0b2dca0eb6510189d433851bd475475e69aa6
Author: Matt Turner <mattst88 at gmail.com>
Date: Fri May 6 13:01:12 2011 -0400
mesa: replace ONE_DIV_LN2 constant with M_LOG2E
1/ln(2) is equivalent to log2(e), so define it as such.
log2(e) = ln(e)/ln(2) = 1/ln(2)
Worst of all, the definitions for M_LOG2E and ONE_DIV_LN2
(right beside each other!) weren't the same.
Reviewed-by: Alex Deucher <alexdeucher at gmail.com>
Signed-off-by: Matt Turner <mattst88 at gmail.com>
Signed-off-by: Brian Paul <brianp at vmware.com>
---
src/mesa/main/compiler.h | 4 ----
src/mesa/program/prog_statevars.c | 2 +-
2 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h
index e17fd0f..81e08a0 100644
--- a/src/mesa/main/compiler.h
+++ b/src/mesa/main/compiler.h
@@ -366,10 +366,6 @@ static INLINE GLuint CPU_TO_LE32(GLuint x)
#define M_LOG2E (1.4426950408889634074)
#endif
-#ifndef ONE_DIV_LN2
-#define ONE_DIV_LN2 (1.442695040888963456)
-#endif
-
#ifndef ONE_DIV_SQRT_LN2
#define ONE_DIV_SQRT_LN2 (1.201122408786449815)
#endif
diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c
index d94d7fe..16f9690 100644
--- a/src/mesa/program/prog_statevars.c
+++ b/src/mesa/program/prog_statevars.c
@@ -459,7 +459,7 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
value[0] = (ctx->Fog.End == ctx->Fog.Start)
? 1.0f : (GLfloat)(-1.0F / (ctx->Fog.End - ctx->Fog.Start));
value[1] = ctx->Fog.End * -value[0];
- value[2] = (GLfloat)(ctx->Fog.Density * ONE_DIV_LN2);
+ value[2] = (GLfloat)(ctx->Fog.Density * M_LOG2E); /* M_LOG2E == 1/ln(2) */
value[3] = (GLfloat)(ctx->Fog.Density * ONE_DIV_SQRT_LN2);
return;
More information about the mesa-commit
mailing list