gallium: replace LOG2() macro with util_fast_log2() inline func

This commit is contained in:
Brian Paul 2008-08-22 15:25:21 -06:00
parent 1c2ff4d9e6
commit 1a46dcc8a9
4 changed files with 9 additions and 20 deletions

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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)