summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util/u_math.h
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2008-11-15 16:23:31 +0000
committerKeith Whitwell <[email protected]>2008-11-15 16:23:31 +0000
commit5e1454a036be6da2c48e2e20bf6f8047ee1a94d3 (patch)
tree660228843fc88f2e43d975921e7d4e078e483f1c /src/gallium/auxiliary/util/u_math.h
parent56ef0aeda5d23bf0c6147fd9d20d61abd18207af (diff)
parent7e584a70c492698be18bf4d6372b50d1a1c38385 (diff)
Merge commit 'origin/gallium-0.1' into gallium-0.2
Conflicts: src/mesa/drivers/dri/common/dri_util.c
Diffstat (limited to 'src/gallium/auxiliary/util/u_math.h')
-rw-r--r--src/gallium/auxiliary/util/u_math.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
index fdaec8df823..653d79ccd5b 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -246,8 +246,9 @@ util_fast_exp(float x)
}
-#define LOG2_TABLE_SIZE_LOG2 8
-#define LOG2_TABLE_SIZE (1 << LOG2_TABLE_SIZE_LOG2)
+#define LOG2_TABLE_SIZE_LOG2 16
+#define LOG2_TABLE_SCALE (1 << LOG2_TABLE_SIZE_LOG2)
+#define LOG2_TABLE_SIZE (LOG2_TABLE_SCALE + 1)
extern float log2_table[LOG2_TABLE_SIZE];
@@ -258,7 +259,8 @@ util_fast_log2(float x)
float epart, mpart;
num.f = x;
epart = (float)(((num.i & 0x7f800000) >> 23) - 127);
- mpart = log2_table[(num.i & 0x007fffff) >> (23 - LOG2_TABLE_SIZE_LOG2)];
+ /* mpart = log2_table[mantissa*LOG2_TABLE_SCALE + 0.5] */
+ mpart = log2_table[((num.i & 0x007fffff) + (1 << (22 - LOG2_TABLE_SIZE_LOG2))) >> (23 - LOG2_TABLE_SIZE_LOG2)];
return epart + mpart;
}