mesa: remove INV_SQRTF() macro

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
Brian Paul 2015-02-24 09:39:51 -07:00
parent bbb2d84032
commit a2b366b92c
10 changed files with 15 additions and 22 deletions

View File

@ -119,15 +119,6 @@ static inline int isblank(int ch) { return ch == ' ' || ch == '\t'; }
#endif
/** 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
***/

View File

@ -1026,9 +1026,9 @@ update_modelview_scale( struct gl_context *ctx )
GLfloat f = m[2] * m[2] + m[6] * m[6] + m[10] * m[10];
if (f < 1e-12) f = 1.0;
if (ctx->_NeedEyeCoords)
ctx->_ModelViewInvScale = (GLfloat) INV_SQRTF(f);
ctx->_ModelViewInvScale = 1.0f / sqrtf(f);
else
ctx->_ModelViewInvScale = (GLfloat) sqrtf(f);
ctx->_ModelViewInvScale = sqrtf(f);
}
}

View File

@ -775,7 +775,7 @@ NORMALIZE_3FV(GLfloat v[3])
{
GLfloat len = (GLfloat) LEN_SQUARED_3FV(v);
if (len) {
len = INV_SQRTF(len);
len = 1.0f / sqrtf(len);
v[0] *= len;
v[1] *= len;
v[2] *= len;

View File

@ -26,6 +26,7 @@
* Gareth Hughes
*/
#include "c99_math.h"
#include "main/glheader.h"
#include "main/context.h"
#include "main/macros.h"
@ -165,7 +166,7 @@ static void ref_norm_transform_normalize( const GLmatrix *mat,
/* Hmmm, don't know how we could test the precalculated
* length case...
*/
scale = INV_SQRTF( len );
scale = 1.0f / sqrtf(len);
SCALE_SCALAR_3V( out[i], scale, t );
} else {
out[i][0] = out[i][1] = out[i][2] = 0;
@ -241,7 +242,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles )
ASSIGN_3V( d2[i], 0.0, 0.0, 0.0 );
for ( j = 0 ; j < 3 ; j++ )
s[i][j] = rnd();
length[i] = INV_SQRTF( LEN_SQUARED_3FV( s[i] ) );
length[i] = 1.0f / sqrtf( LEN_SQUARED_3FV( s[i] ) );
}
source->data = (GLfloat(*)[4]) s;

View File

@ -68,7 +68,7 @@ TAG(transform_normalize_normals)( const GLmatrix *mat,
{
GLdouble len = tx*tx + ty*ty + tz*tz;
if (len > 1e-20) {
GLfloat scale = INV_SQRTF(len);
GLfloat scale = 1.0f / sqrtf(len);
out[i][0] = tx * scale;
out[i][1] = ty * scale;
out[i][2] = tz * scale;
@ -135,7 +135,7 @@ TAG(transform_normalize_normals_no_rot)( const GLmatrix *mat,
{
GLdouble len = tx*tx + ty*ty + tz*tz;
if (len > 1e-20) {
GLfloat scale = INV_SQRTF(len);
GLfloat scale = 1.0f / sqrtf(len);
out[i][0] = tx * scale;
out[i][1] = ty * scale;
out[i][2] = tz * scale;
@ -322,7 +322,7 @@ TAG(normalize_normals)( const GLmatrix *mat,
const GLfloat x = from[0], y = from[1], z = from[2];
GLdouble len = x * x + y * y + z * z;
if (len > 1e-50) {
len = INV_SQRTF(len);
len = 1.0f / sqrtf(len);
out[i][0] = (GLfloat)(x * len);
out[i][1] = (GLfloat)(y * len);
out[i][2] = (GLfloat)(z * len);

View File

@ -33,6 +33,7 @@
* 3. Transformation of a point p by a matrix M is: p' = M * p
*/
#include "c99_math.h"
#include "main/glheader.h"
#include "main/macros.h"

View File

@ -1085,7 +1085,7 @@ _mesa_execute_program(struct gl_context * ctx,
GLfloat a[4], result[4];
fetch_vector1(&inst->SrcReg[0], machine, a);
a[0] = fabsf(a[0]);
result[0] = result[1] = result[2] = result[3] = INV_SQRTF(a[0]);
result[0] = result[1] = result[2] = result[3] = 1.0f / sqrtf(a[0]);
store_vector4(inst, machine, result);
if (DEBUG_PROG) {
printf("RSQ %g = 1/sqrt(|%g|)\n", result[0], a[0]);

View File

@ -272,7 +272,7 @@ compute_texgen(struct gl_context *ctx, const GLfloat vObj[4], const GLfloat vEye
rz = u[2] - normal[2] * two_nu;
m = rx * rx + ry * ry + (rz + 1.0F) * (rz + 1.0F);
if (m > 0.0F)
mInv = 0.5F * INV_SQRTF(m);
mInv = 0.5F * (1.0f / sqrtf(m));
else
mInv = 0.0F;

View File

@ -65,7 +65,7 @@ run_point_stage(struct gl_context *ctx, struct tnl_pipeline_stage *stage)
for (i = 0; i < VB->Count; i++) {
const GLfloat dist = fabsf(*eyeCoord);
const GLfloat q = p0 + dist * (p1 + dist * p2);
const GLfloat atten = (q != 0.0F) ? INV_SQRTF(q) : 1.0F;
const GLfloat atten = (q != 0.0F) ? (1.0f / sqrtf(q)) : 1.0F;
size[i][0] = pointSize * atten; /* clamping done in rasterization */
eyeCoord += eyeCoordStride;
}

View File

@ -116,7 +116,7 @@ static void build_m3( GLfloat f[][3], GLfloat m[],
fz = f[i][2] = u[2] - norm[2] * two_nu;
m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F);
if (m[i] != 0.0F) {
m[i] = 0.5F * INV_SQRTF(m[i]);
m[i] = 0.5F * (1.0f / sqrtf(m[i]));
}
}
}
@ -145,7 +145,7 @@ static void build_m2( GLfloat f[][3], GLfloat m[],
fz = f[i][2] = u[2] - norm[2] * two_nu;
m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F);
if (m[i] != 0.0F) {
m[i] = 0.5F * INV_SQRTF(m[i]);
m[i] = 0.5F * (1.0f / sqrtf(m[i]));
}
}
}