summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2015-02-24 09:08:50 -0700
committerBrian Paul <[email protected]>2015-02-24 14:44:19 -0700
commitbd7f7aac56d3703f3d0fd55cd20f86f6c431b030 (patch)
treeb929fea534bf19ae7c2a692e3fcf9a893046a670
parent46ce78d4c659fcf9fb2b088424d4d16d13ab5d75 (diff)
mesa: replace FABSF with fabsf
Reviewed-by: Matt Turner <[email protected]>
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_fog.c3
-rw-r--r--src/mesa/main/imports.h11
-rw-r--r--src/mesa/math/m_matrix.c17
-rw-r--r--src/mesa/program/prog_execute.c30
-rw-r--r--src/mesa/swrast/s_fog.c4
-rw-r--r--src/mesa/swrast/s_span.c9
-rw-r--r--src/mesa/swrast/s_texfilter.c15
-rw-r--r--src/mesa/swrast_setup/ss_triangle.c1
-rw-r--r--src/mesa/swrast_setup/ss_tritmp.h4
-rw-r--r--src/mesa/tnl/t_vb_fog.c4
-rw-r--r--src/mesa/tnl/t_vb_points.c3
11 files changed, 48 insertions, 53 deletions
diff --git a/src/mesa/drivers/dri/radeon/radeon_fog.c b/src/mesa/drivers/dri/radeon/radeon_fog.c
index df955754737..d5c6537036e 100644
--- a/src/mesa/drivers/dri/radeon/radeon_fog.c
+++ b/src/mesa/drivers/dri/radeon/radeon_fog.c
@@ -32,6 +32,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Keith Whitwell <[email protected]>
*/
+#include "c99_math.h"
#include "main/glheader.h"
#include "main/imports.h"
#include "main/context.h"
@@ -97,7 +98,7 @@ radeonComputeFogBlendFactor( struct gl_context *ctx, GLfloat fogcoord )
{
GLfloat end = ctx->Fog.End;
GLfloat d, temp;
- const GLfloat z = FABSF(fogcoord);
+ const GLfloat z = fabsf(fogcoord);
switch (ctx->Fog.Mode) {
case GL_LINEAR:
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 9dee565aa58..3384583106a 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -203,17 +203,6 @@ static inline GLfloat LOG2(GLfloat x)
#endif
-/***
- *** FABSF: absolute value of float
- ***/
-#if defined(__gnu_linux__)
-/* C99 functions */
-#define FABSF(x) fabsf(x)
-#else
-#define FABSF(x) ((GLfloat) fabs(x))
-#endif
-
-
/**
* Convert float to int by rounding to nearest integer, away from zero.
*/
diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c
index 9c9310d939e..9d51021feda 100644
--- a/src/mesa/math/m_matrix.c
+++ b/src/mesa/math/m_matrix.c
@@ -34,6 +34,7 @@
*/
+#include "c99_math.h"
#include "main/glheader.h"
#include "main/imports.h"
#include "main/macros.h"
@@ -376,9 +377,9 @@ static GLboolean invert_matrix_general( GLmatrix *mat )
r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0;
/* choose pivot - or die */
- if (FABSF(r3[0])>FABSF(r2[0])) SWAP_ROWS(r3, r2);
- if (FABSF(r2[0])>FABSF(r1[0])) SWAP_ROWS(r2, r1);
- if (FABSF(r1[0])>FABSF(r0[0])) SWAP_ROWS(r1, r0);
+ if (fabsf(r3[0])>fabsf(r2[0])) SWAP_ROWS(r3, r2);
+ if (fabsf(r2[0])>fabsf(r1[0])) SWAP_ROWS(r2, r1);
+ if (fabsf(r1[0])>fabsf(r0[0])) SWAP_ROWS(r1, r0);
if (0.0 == r0[0]) return GL_FALSE;
/* eliminate first variable */
@@ -396,8 +397,8 @@ static GLboolean invert_matrix_general( GLmatrix *mat )
if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; }
/* choose pivot - or die */
- if (FABSF(r3[1])>FABSF(r2[1])) SWAP_ROWS(r3, r2);
- if (FABSF(r2[1])>FABSF(r1[1])) SWAP_ROWS(r2, r1);
+ if (fabsf(r3[1])>fabsf(r2[1])) SWAP_ROWS(r3, r2);
+ if (fabsf(r2[1])>fabsf(r1[1])) SWAP_ROWS(r2, r1);
if (0.0 == r1[1]) return GL_FALSE;
/* eliminate second variable */
@@ -410,7 +411,7 @@ static GLboolean invert_matrix_general( GLmatrix *mat )
s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; }
/* choose pivot - or die */
- if (FABSF(r3[2])>FABSF(r2[2])) SWAP_ROWS(r3, r2);
+ if (fabsf(r3[2])>fabsf(r2[2])) SWAP_ROWS(r3, r2);
if (0.0 == r2[2]) return GL_FALSE;
/* eliminate third variable */
@@ -508,7 +509,7 @@ static GLboolean invert_matrix_3d_general( GLmatrix *mat )
det = pos + neg;
- if (FABSF(det) < 1e-25)
+ if (fabsf(det) < 1e-25)
return GL_FALSE;
det = 1.0F / det;
@@ -1069,7 +1070,7 @@ _math_matrix_scale( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z )
m[2] *= x; m[6] *= y; m[10] *= z;
m[3] *= x; m[7] *= y; m[11] *= z;
- if (FABSF(x - y) < 1e-8 && FABSF(x - z) < 1e-8)
+ if (fabsf(x - y) < 1e-8 && fabsf(x - z) < 1e-8)
mat->flags |= MAT_FLAG_UNIFORM_SCALE;
else
mat->flags |= MAT_FLAG_GENERAL_SCALE;
diff --git a/src/mesa/program/prog_execute.c b/src/mesa/program/prog_execute.c
index 8ae015f4bf2..de3a53b493f 100644
--- a/src/mesa/program/prog_execute.c
+++ b/src/mesa/program/prog_execute.c
@@ -202,10 +202,10 @@ fetch_vector4(const struct prog_src_register *source,
}
if (source->Abs) {
- result[0] = FABSF(result[0]);
- result[1] = FABSF(result[1]);
- result[2] = FABSF(result[2]);
- result[3] = FABSF(result[3]);
+ result[0] = fabsf(result[0]);
+ result[1] = fabsf(result[1]);
+ result[2] = fabsf(result[2]);
+ result[3] = fabsf(result[3]);
}
if (source->Negate) {
assert(source->Negate == NEGATE_XYZW);
@@ -260,10 +260,10 @@ fetch_vector4_deriv(struct gl_context * ctx,
result[3] = deriv[GET_SWZ(source->Swizzle, 3)];
if (source->Abs) {
- result[0] = FABSF(result[0]);
- result[1] = FABSF(result[1]);
- result[2] = FABSF(result[2]);
- result[3] = FABSF(result[3]);
+ result[0] = fabsf(result[0]);
+ result[1] = fabsf(result[1]);
+ result[2] = fabsf(result[2]);
+ result[3] = fabsf(result[3]);
}
if (source->Negate) {
assert(source->Negate == NEGATE_XYZW);
@@ -291,7 +291,7 @@ fetch_vector1(const struct prog_src_register *source,
result[0] = src[GET_SWZ(source->Swizzle, 0)];
if (source->Abs) {
- result[0] = FABSF(result[0]);
+ result[0] = fabsf(result[0]);
}
if (source->Negate) {
result[0] = -result[0];
@@ -521,10 +521,10 @@ _mesa_execute_program(struct gl_context * ctx,
{
GLfloat a[4], result[4];
fetch_vector4(&inst->SrcReg[0], machine, a);
- result[0] = FABSF(a[0]);
- result[1] = FABSF(a[1]);
- result[2] = FABSF(a[2]);
- result[3] = FABSF(a[3]);
+ result[0] = fabsf(a[0]);
+ result[1] = fabsf(a[1]);
+ result[2] = fabsf(a[2]);
+ result[3] = fabsf(a[3]);
store_vector4(inst, machine, result);
}
break;
@@ -875,7 +875,7 @@ _mesa_execute_program(struct gl_context * ctx,
{
GLfloat t[4], q[4], abs_t0;
fetch_vector1(&inst->SrcReg[0], machine, t);
- abs_t0 = FABSF(t[0]);
+ abs_t0 = fabsf(t[0]);
if (abs_t0 != 0.0F) {
if (IS_INF_OR_NAN(abs_t0))
{
@@ -1084,7 +1084,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]);
+ a[0] = fabsf(a[0]);
result[0] = result[1] = result[2] = result[3] = INV_SQRTF(a[0]);
store_vector4(inst, machine, result);
if (DEBUG_PROG) {
diff --git a/src/mesa/swrast/s_fog.c b/src/mesa/swrast/s_fog.c
index 380dcc11bab..e270b7e244e 100644
--- a/src/mesa/swrast/s_fog.c
+++ b/src/mesa/swrast/s_fog.c
@@ -92,7 +92,7 @@ if (span->arrayAttribs & VARYING_BIT_FOGC) { \
GLuint i; \
for (i = 0; i < span->end; i++) { \
const GLfloat fogCoord = span->array->attribs[VARYING_SLOT_FOGC][i][0]; \
- const GLfloat c = FABSF(fogCoord); \
+ const GLfloat c = fabsf(fogCoord); \
GLfloat f, oneMinusF; \
FOG_FUNC(f, c); \
f = CLAMP(f, 0.0F, 1.0F); \
@@ -109,7 +109,7 @@ else { \
GLfloat w = span->attrStart[VARYING_SLOT_POS][3]; \
GLuint i; \
for (i = 0; i < span->end; i++) { \
- const GLfloat c = FABSF(fogCoord) / w; \
+ const GLfloat c = fabsf(fogCoord) / w; \
GLfloat f, oneMinusF; \
FOG_FUNC(f, c); \
f = CLAMP(f, 0.0F, 1.0F); \
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index a8dc391116a..5d618f0488a 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -31,6 +31,7 @@
* \author Brian Paul
*/
+#include "c99_math.h"
#include "main/glheader.h"
#include "main/colormac.h"
#include "main/format_pack.h"
@@ -443,10 +444,10 @@ _swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy,
GLfloat dsdy2 = (s + dsdy) / (q + dqdy) - s * invQ;
GLfloat dtdy2 = (t + dtdy) / (q + dqdy) - t * invQ;
GLfloat maxU, maxV, rho, lambda;
- dsdx2 = FABSF(dsdx2);
- dsdy2 = FABSF(dsdy2);
- dtdx2 = FABSF(dtdx2);
- dtdy2 = FABSF(dtdy2);
+ dsdx2 = fabsf(dsdx2);
+ dsdy2 = fabsf(dsdy2);
+ dtdx2 = fabsf(dtdx2);
+ dtdy2 = fabsf(dtdy2);
maxU = MAX2(dsdx2, dsdy2) * texW;
maxV = MAX2(dtdx2, dtdy2) * texH;
rho = MAX2(maxU, maxV);
diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c
index ae42640cf69..3ade99519bf 100644
--- a/src/mesa/swrast/s_texfilter.c
+++ b/src/mesa/swrast/s_texfilter.c
@@ -23,6 +23,7 @@
*/
+#include "c99_math.h"
#include "main/glheader.h"
#include "main/context.h"
#include "main/colormac.h"
@@ -223,7 +224,7 @@ linear_texel_locations(GLenum wrapMode,
}
break;
case GL_MIRROR_CLAMP_EXT:
- u = FABSF(s);
+ u = fabsf(s);
if (u >= 1.0F)
u = (GLfloat) size;
else
@@ -233,7 +234,7 @@ linear_texel_locations(GLenum wrapMode,
*i1 = *i0 + 1;
break;
case GL_MIRROR_CLAMP_TO_EDGE_EXT:
- u = FABSF(s);
+ u = fabsf(s);
if (u >= 1.0F)
u = (GLfloat) size;
else
@@ -250,7 +251,7 @@ linear_texel_locations(GLenum wrapMode,
{
const GLfloat min = -1.0F / (2.0F * size);
const GLfloat max = 1.0F - min;
- u = FABSF(s);
+ u = fabsf(s);
if (u <= min)
u = min * size;
else if (u >= max)
@@ -354,7 +355,7 @@ nearest_texel_location(GLenum wrapMode,
{
/* s limited to [0,1] */
/* i limited to [0,size-1] */
- const GLfloat u = FABSF(s);
+ const GLfloat u = fabsf(s);
if (u <= 0.0F)
i = 0;
else if (u >= 1.0F)
@@ -369,7 +370,7 @@ nearest_texel_location(GLenum wrapMode,
/* i limited to [0, size-1] */
const GLfloat min = 1.0F / (2.0F * size);
const GLfloat max = 1.0F - min;
- const GLfloat u = FABSF(s);
+ const GLfloat u = fabsf(s);
if (u < min)
i = 0;
else if (u > max)
@@ -384,7 +385,7 @@ nearest_texel_location(GLenum wrapMode,
/* i limited to [0, size-1] */
const GLfloat min = -1.0F / (2.0F * size);
const GLfloat max = 1.0F - min;
- const GLfloat u = FABSF(s);
+ const GLfloat u = fabsf(s);
if (u < min)
i = -1;
else if (u > max)
@@ -2358,7 +2359,7 @@ choose_cube_face(const struct gl_texture_object *texObj,
const GLfloat rx = texcoord[0];
const GLfloat ry = texcoord[1];
const GLfloat rz = texcoord[2];
- const GLfloat arx = FABSF(rx), ary = FABSF(ry), arz = FABSF(rz);
+ const GLfloat arx = fabsf(rx), ary = fabsf(ry), arz = fabsf(rz);
GLuint face;
GLfloat sc, tc, ma;
diff --git a/src/mesa/swrast_setup/ss_triangle.c b/src/mesa/swrast_setup/ss_triangle.c
index 42ba891abe1..483c41592e4 100644
--- a/src/mesa/swrast_setup/ss_triangle.c
+++ b/src/mesa/swrast_setup/ss_triangle.c
@@ -25,6 +25,7 @@
* Keith Whitwell <[email protected]>
*/
+#include "c99_math.h"
#include "main/glheader.h"
#include "main/colormac.h"
#include "main/macros.h"
diff --git a/src/mesa/swrast_setup/ss_tritmp.h b/src/mesa/swrast_setup/ss_tritmp.h
index d4513c9acab..c38c76a4adb 100644
--- a/src/mesa/swrast_setup/ss_tritmp.h
+++ b/src/mesa/swrast_setup/ss_tritmp.h
@@ -142,8 +142,8 @@ static void TAG(triangle)(struct gl_context *ctx, GLuint e0, GLuint e1, GLuint e
const GLfloat ez = z[0] - z[2];
const GLfloat fz = z[1] - z[2];
const GLfloat oneOverArea = 1.0F / cc;
- const GLfloat dzdx = FABSF((ey * fz - ez * fy) * oneOverArea);
- const GLfloat dzdy = FABSF((ez * fx - ex * fz) * oneOverArea);
+ const GLfloat dzdx = fabsf((ey * fz - ez * fy) * oneOverArea);
+ const GLfloat dzdy = fabsf((ez * fx - ex * fz) * oneOverArea);
offset += MAX2(dzdx, dzdy) * ctx->Polygon.OffsetFactor;
}
/* new Z values */
diff --git a/src/mesa/tnl/t_vb_fog.c b/src/mesa/tnl/t_vb_fog.c
index 3c8950f1803..3626f1da30d 100644
--- a/src/mesa/tnl/t_vb_fog.c
+++ b/src/mesa/tnl/t_vb_fog.c
@@ -187,7 +187,7 @@ run_fog_stage(struct gl_context *ctx, struct tnl_pipeline_stage *stage)
NOTE should avoid going through array twice */
coord = input->start;
for (i = 0; i < input->count; i++) {
- *coord = FABSF(*coord);
+ *coord = fabsf(*coord);
STRIDE_F(coord, input->stride);
}
}
@@ -202,7 +202,7 @@ run_fog_stage(struct gl_context *ctx, struct tnl_pipeline_stage *stage)
input->count = VB->EyePtr->count;
coord = VB->EyePtr->start;
for (i = 0 ; i < VB->EyePtr->count; i++) {
- input->data[i][0] = FABSF(coord[2]);
+ input->data[i][0] = fabsf(coord[2]);
STRIDE_F(coord, VB->EyePtr->stride);
}
}
diff --git a/src/mesa/tnl/t_vb_points.c b/src/mesa/tnl/t_vb_points.c
index 5f6c258570a..273db76829d 100644
--- a/src/mesa/tnl/t_vb_points.c
+++ b/src/mesa/tnl/t_vb_points.c
@@ -25,6 +25,7 @@
* Brian Paul
*/
+#include "c99_math.h"
#include "main/glheader.h"
#include "main/mtypes.h"
#include "main/dd.h"
@@ -62,7 +63,7 @@ run_point_stage(struct gl_context *ctx, struct tnl_pipeline_stage *stage)
GLuint i;
for (i = 0; i < VB->Count; i++) {
- const GLfloat dist = FABSF(*eyeCoord);
+ const GLfloat dist = fabsf(*eyeCoord);
const GLfloat q = p0 + dist * (p1 + dist * p2);
const GLfloat atten = (q != 0.0F) ? INV_SQRTF(q) : 1.0F;
size[i][0] = pointSize * atten; /* clamping done in rasterization */