summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2008-08-22 15:25:21 -0600
committerBrian Paul <[email protected]>2008-08-22 15:25:21 -0600
commit1a46dcc8a927dfb38ca1381e7b3dafb789f8257c (patch)
tree2f8fdae0e1e2858b73ca012f485777362792778e /src/gallium
parent1c2ff4d9e65563c071747a9c3bd907bd24706da0 (diff)
gallium: replace LOG2() macro with util_fast_log2() inline func
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_sse2.c8
-rw-r--r--src/gallium/drivers/softpipe/sp_context.c3
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.c3
-rw-r--r--src/gallium/include/pipe/p_util.h15
4 files changed, 9 insertions, 20 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
index e3906070237..00ed4da4507 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
@@ -713,10 +713,10 @@ lg24f(
{
const unsigned X = 0;
- store[X + 0] = LOG2( store[X + 0] );
- store[X + 1] = LOG2( store[X + 1] );
- store[X + 2] = LOG2( store[X + 2] );
- store[X + 3] = LOG2( store[X + 3] );
+ store[X + 0] = util_fast_log2( store[X + 0] );
+ store[X + 1] = util_fast_log2( store[X + 1] );
+ store[X + 2] = util_fast_log2( store[X + 2] );
+ store[X + 3] = util_fast_log2( store[X + 3] );
}
static void
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
index 626c3a9d4e1..9b1313bc83e 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -33,6 +33,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "pipe/p_util.h"
+#include "util/u_math.h"
#include "sp_clear.h"
#include "sp_context.h"
#include "sp_flush.h"
@@ -128,6 +129,8 @@ softpipe_create( struct pipe_screen *screen,
struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
uint i;
+ util_init_math();
+
#ifdef PIPE_ARCH_X86
softpipe->use_sse = !debug_get_bool_option( "GALLIUM_NOSSE", FALSE );
#else
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index 01f4d0ca811..d7680ffa81d 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -41,6 +41,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_util.h"
#include "tgsi/tgsi_exec.h"
+#include "util/u_math.h"
/*
@@ -499,7 +500,7 @@ compute_lambda(struct tgsi_sampler *sampler,
rho = MAX2(rho, max);
}
- lambda = LOG2(rho);
+ lambda = util_fast_log2(rho);
lambda += lodbias + sampler->state->lod_bias;
lambda = CLAMP(lambda, sampler->state->min_lod, sampler->state->max_lod);
diff --git a/src/gallium/include/pipe/p_util.h b/src/gallium/include/pipe/p_util.h
index 473a8d94abb..660192b28e7 100644
--- a/src/gallium/include/pipe/p_util.h
+++ b/src/gallium/include/pipe/p_util.h
@@ -443,21 +443,6 @@ static INLINE int iround(float f)
#define FABSF(x) ((float) fabs(x))
#endif
-/* Pretty fast, and accurate.
- * Based on code from http://www.flipcode.com/totd/
- */
-static INLINE float LOG2(float val)
-{
- union fi num;
- int log_2;
-
- num.f = val;
- log_2 = ((num.i >> 23) & 255) - 128;
- num.i &= ~(255 << 23);
- num.i += 127 << 23;
- num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3;
- return num.f + log_2;
-}
#if defined(__GNUC__)
#define CEILF(x) ceilf(x)