mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-04 21:10:31 +01:00
mesa: remove SQRTF, use sqrtf. Convert INV_SQRT() to inline function.
We were already defining sqrtf where we don't have the C99 version. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
parent
f44bda17f5
commit
56ccdf7e30
8 changed files with 20 additions and 22 deletions
|
|
@ -96,18 +96,6 @@ typedef union { GLfloat f; GLint i; } fi_type;
|
|||
#define DEG2RAD (M_PI/180.0)
|
||||
|
||||
|
||||
/***
|
||||
*** SQRTF: single-precision square root
|
||||
***/
|
||||
#define SQRTF(X) (float) sqrt((float) (X))
|
||||
|
||||
|
||||
/***
|
||||
*** INV_SQRTF: single-precision inverse square root
|
||||
***/
|
||||
#define INV_SQRTF(X) (1.0F / SQRTF(X))
|
||||
|
||||
|
||||
/**
|
||||
* \name Work-arounds for platforms that lack C99 math functions
|
||||
*/
|
||||
|
|
@ -157,6 +145,16 @@ static inline int isblank(int ch) { return ch == ' ' || ch == '\t'; }
|
|||
/*@}*/
|
||||
|
||||
|
||||
|
||||
/** single-precision inverse square root */
|
||||
static inline float
|
||||
INV_SQRTF(float x)
|
||||
{
|
||||
/* XXX we could try Quake's fast inverse square root function here */
|
||||
return 1.0F / sqrtf(x);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** LOG2: Log base 2 of float
|
||||
***/
|
||||
|
|
|
|||
|
|
@ -1038,7 +1038,7 @@ update_modelview_scale( struct gl_context *ctx )
|
|||
if (ctx->_NeedEyeCoords)
|
||||
ctx->_ModelViewInvScale = (GLfloat) INV_SQRTF(f);
|
||||
else
|
||||
ctx->_ModelViewInvScale = (GLfloat) SQRTF(f);
|
||||
ctx->_ModelViewInvScale = (GLfloat) sqrtf(f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -665,13 +665,13 @@ LEN_SQUARED_2FV(const GLfloat v[2])
|
|||
static inline GLfloat
|
||||
LEN_3FV(const GLfloat v[3])
|
||||
{
|
||||
return SQRTF(LEN_SQUARED_3FV(v));
|
||||
return sqrtf(LEN_SQUARED_3FV(v));
|
||||
}
|
||||
|
||||
static inline GLfloat
|
||||
LEN_2FV(const GLfloat v[2])
|
||||
{
|
||||
return SQRTF(LEN_SQUARED_2FV(v));
|
||||
return sqrtf(LEN_SQUARED_2FV(v));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -856,7 +856,7 @@ _math_matrix_rotate( GLmatrix *mat,
|
|||
}
|
||||
|
||||
if (!optimized) {
|
||||
const GLfloat mag = SQRTF(x * x + y * y + z * z);
|
||||
const GLfloat mag = sqrtf(x * x + y * y + z * z);
|
||||
|
||||
if (mag <= 1.0e-4) {
|
||||
/* no rotation, leave mat as-is */
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ NAME(line)(struct gl_context *ctx, const SWvertex *v0, const SWvertex *v1)
|
|||
line.y1 = v1->attrib[FRAG_ATTRIB_WPOS][1];
|
||||
line.dx = line.x1 - line.x0;
|
||||
line.dy = line.y1 - line.y0;
|
||||
line.len = SQRTF(line.dx * line.dx + line.dy * line.dy);
|
||||
line.len = sqrtf(line.dx * line.dx + line.dy * line.dy);
|
||||
line.halfWidth = 0.5F * CLAMP(ctx->Line.Width,
|
||||
ctx->Const.MinLineWidthAA,
|
||||
ctx->Const.MaxLineWidthAA);
|
||||
|
|
|
|||
|
|
@ -419,8 +419,8 @@ _swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy,
|
|||
GLfloat dvdx = texH * ((t + dtdx) / (q + dqdx) - t * invQ);
|
||||
GLfloat dudy = texW * ((s + dsdy) / (q + dqdy) - s * invQ);
|
||||
GLfloat dvdy = texH * ((t + dtdy) / (q + dqdy) - t * invQ);
|
||||
GLfloat x = SQRTF(dudx * dudx + dvdx * dvdx);
|
||||
GLfloat y = SQRTF(dudy * dudy + dvdy * dvdy);
|
||||
GLfloat x = sqrtf(dudx * dudx + dvdx * dvdx);
|
||||
GLfloat y = sqrtf(dudy * dudy + dvdy * dvdy);
|
||||
GLfloat rho = MAX2(x, y);
|
||||
GLfloat lambda = LOG2(rho);
|
||||
return lambda;
|
||||
|
|
|
|||
|
|
@ -1795,12 +1795,12 @@ sample_2d_footprint(struct gl_context *ctx,
|
|||
|
||||
/* Calculate the per anisotropic sample offsets in s,t space. */
|
||||
if (Px2 > Py2) {
|
||||
numSamples = ceil(SQRTF(Px2));
|
||||
numSamples = ceil(sqrtf(Px2));
|
||||
ds = ux / ((GLfloat) img->Width2);
|
||||
dt = vx / ((GLfloat) img->Height2);
|
||||
}
|
||||
else {
|
||||
numSamples = ceil(SQRTF(Py2));
|
||||
numSamples = ceil(sqrtf(Py2));
|
||||
ds = uy / ((GLfloat) img->Width2);
|
||||
dt = vy / ((GLfloat) img->Height2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -429,7 +429,7 @@ _tnl_RasterPos(struct gl_context *ctx, const GLfloat vObj[4])
|
|||
ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0];
|
||||
else
|
||||
ctx->Current.RasterDistance =
|
||||
SQRTF( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] );
|
||||
sqrtf( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] );
|
||||
|
||||
/* compute transformed normal vector (for lighting or texgen) */
|
||||
if (ctx->_NeedEyeCoords) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue