GLfloat x = sqrtf(dudx * dudx + dvdx * dvdx);
GLfloat y = sqrtf(dudy * dudy + dvdy * dvdy);
GLfloat rho = MAX2(x, y);
- GLfloat lambda = LOG2(rho);
+ GLfloat lambda = util_fast_log2(rho);
return lambda;
}
maxU = MAX2(dsdx2, dsdy2) * texW;
maxV = MAX2(dtdx2, dtdy2) * texH;
rho = MAX2(maxU, maxV);
- lambda = LOG2(rho);
+ lambda = util_fast_log2(rho);
return lambda;
}
#endif
/* note: we need to have Pmin=sqrt(Pmin2) here, but we can avoid
* this since 0.5*log(x) = log(sqrt(x))
*/
- lod = 0.5f * LOG2(Pmin2);
+ lod = 0.5f * util_fast_log2(Pmin2);
if (adjustLOD) {
/* from swrast/s_texcombine.c _swrast_texture_span */
/*@}*/
-/***
- *** LOG2: Log base 2 of float
- ***/
-static inline float LOG2(float x)
-{
-#if 0
- /* This is pretty fast, but not accurate enough (only 2 fractional bits).
- * Based on code from http://www.stereopsis.com/log2.html
- */
- const float y = x * x * x * x;
- const unsigned ix = *((unsigned *) &y);
- const unsigned exp = (ix >> 23) & 0xFF;
- const int log2 = ((int) exp) - 127;
- return (float) log2 * (1.0 / 4.0); /* 4, because of x^4 above */
-#endif
- /* Pretty fast, and accurate.
- * Based on code from http://www.flipcode.com/totd/
- */
- fi_type num;
- int log_2;
- num.f = x;
- 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;
-}
-
-
-
/**
* finite macro.
*/