diff options
Diffstat (limited to 'mesalib/src/mesa/math')
-rw-r--r-- | mesalib/src/mesa/math/m_debug_norm.c | 5 | ||||
-rw-r--r-- | mesalib/src/mesa/math/m_debug_util.h | 9 | ||||
-rw-r--r-- | mesalib/src/mesa/math/m_debug_xform.c | 4 | ||||
-rw-r--r-- | mesalib/src/mesa/math/m_matrix.c | 21 | ||||
-rw-r--r-- | mesalib/src/mesa/math/m_norm_tmp.h | 6 | ||||
-rw-r--r-- | mesalib/src/mesa/math/m_trans_tmp.h | 84 | ||||
-rw-r--r-- | mesalib/src/mesa/math/m_translate.c | 6 | ||||
-rw-r--r-- | mesalib/src/mesa/math/m_translate.h | 1 | ||||
-rw-r--r-- | mesalib/src/mesa/math/m_vector.c | 1 | ||||
-rw-r--r-- | mesalib/src/mesa/math/m_xform.c | 1 | ||||
-rw-r--r-- | mesalib/src/mesa/math/m_xform.h | 2 |
11 files changed, 62 insertions, 78 deletions
diff --git a/mesalib/src/mesa/math/m_debug_norm.c b/mesalib/src/mesa/math/m_debug_norm.c index 00e72be54..197b43cf2 100644 --- a/mesalib/src/mesa/math/m_debug_norm.c +++ b/mesalib/src/mesa/math/m_debug_norm.c @@ -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; diff --git a/mesalib/src/mesa/math/m_debug_util.h b/mesalib/src/mesa/math/m_debug_util.h index d05da8994..25ee029ce 100644 --- a/mesalib/src/mesa/math/m_debug_util.h +++ b/mesalib/src/mesa/math/m_debug_util.h @@ -32,6 +32,9 @@ #ifdef DEBUG_MATH /* This code only used for debugging */ +#include "c99_math.h" + + /* Comment this out to deactivate the cycle counter. * NOTE: it works only on CPUs which know the 'rdtsc' command (586 or higher) * (hope, you don't try to debug Mesa on a 386 ;) @@ -286,9 +289,9 @@ static int significand_match( GLfloat a, GLfloat b ) return 0; } - FREXPF( a, &a_ex ); - FREXPF( b, &b_ex ); - FREXPF( d, &d_ex ); + frexpf( a, &a_ex ); + frexpf( b, &b_ex ); + frexpf( d, &d_ex ); if ( a_ex < b_ex ) { return a_ex - d_ex; diff --git a/mesalib/src/mesa/math/m_debug_xform.c b/mesalib/src/mesa/math/m_debug_xform.c index f56b4cfc7..632c82ea2 100644 --- a/mesalib/src/mesa/math/m_debug_xform.c +++ b/mesalib/src/mesa/math/m_debug_xform.c @@ -187,7 +187,7 @@ static int test_transform_function( transform_func func, int psize, mat->type = mtypes[mtype]; m = mat->m; - ASSERT( ((long)m & 15) == 0 ); + assert( ((long)m & 15) == 0 ); init_matrix( m ); @@ -206,7 +206,7 @@ static int test_transform_function( transform_func func, int psize, case VAR: break; default: - ASSERT(0); + assert(0); return 0; } } diff --git a/mesalib/src/mesa/math/m_matrix.c b/mesalib/src/mesa/math/m_matrix.c index 9c9310d93..0475a7ab2 100644 --- a/mesalib/src/mesa/math/m_matrix.c +++ b/mesalib/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; @@ -798,8 +799,8 @@ _math_matrix_rotate( GLmatrix *mat, GLfloat m[16]; GLboolean optimized; - s = (GLfloat) sin( angle * DEG2RAD ); - c = (GLfloat) cos( angle * DEG2RAD ); + s = (GLfloat) sin( angle * M_PI / 180.0 ); + c = (GLfloat) cos( angle * M_PI / 180.0 ); memcpy(m, Identity, sizeof(GLfloat)*16); optimized = GL_FALSE; @@ -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/mesalib/src/mesa/math/m_norm_tmp.h b/mesalib/src/mesa/math/m_norm_tmp.h index 339c03ff8..c8fab0ed3 100644 --- a/mesalib/src/mesa/math/m_norm_tmp.h +++ b/mesalib/src/mesa/math/m_norm_tmp.h @@ -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); diff --git a/mesalib/src/mesa/math/m_trans_tmp.h b/mesalib/src/mesa/math/m_trans_tmp.h index f39a3c83a..0a8bfc538 100644 --- a/mesalib/src/mesa/math/m_trans_tmp.h +++ b/mesalib/src/mesa/math/m_trans_tmp.h @@ -40,13 +40,11 @@ static void DEST_4F( GLfloat (*t)[4], (void) first; (void) start; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - if (SZ >= 1) t[i][0] = TRX_4F(f, 0); - if (SZ >= 2) t[i][1] = TRX_4F(f, 1); - if (SZ >= 3) t[i][2] = TRX_4F(f, 2); - if (SZ == 4) t[i][3] = TRX_4F(f, 3); else t[i][3] = 1.0; - } + NEXT_F2; + if (SZ >= 1) t[i][0] = TRX_4F(f, 0); + if (SZ >= 2) t[i][1] = TRX_4F(f, 1); + if (SZ >= 3) t[i][2] = TRX_4F(f, 2); + if (SZ == 4) t[i][3] = TRX_4F(f, 3); else t[i][3] = 1.0; } } #endif @@ -66,13 +64,11 @@ static void DEST_4FN( GLfloat (*t)[4], (void) first; (void) start; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - if (SZ >= 1) t[i][0] = TRX_4FN(f, 0); - if (SZ >= 2) t[i][1] = TRX_4FN(f, 1); - if (SZ >= 3) t[i][2] = TRX_4FN(f, 2); - if (SZ == 4) t[i][3] = TRX_4FN(f, 3); else t[i][3] = 1.0; - } + NEXT_F2; + if (SZ >= 1) t[i][0] = TRX_4FN(f, 0); + if (SZ >= 2) t[i][1] = TRX_4FN(f, 1); + if (SZ >= 3) t[i][2] = TRX_4FN(f, 2); + if (SZ == 4) t[i][3] = TRX_4FN(f, 3); else t[i][3] = 1.0; } } #endif @@ -90,12 +86,10 @@ static void DEST_3FN( GLfloat (*t)[3], (void) first; (void) start; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - t[i][0] = TRX_3FN(f, 0); - t[i][1] = TRX_3FN(f, 1); - t[i][2] = TRX_3FN(f, 2); - } + NEXT_F2; + t[i][0] = TRX_3FN(f, 0); + t[i][1] = TRX_3FN(f, 1); + t[i][2] = TRX_3FN(f, 2); } } #endif @@ -112,10 +106,8 @@ static void DEST_1F( GLfloat *t, (void) first; (void) start; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - t[i] = TRX_1F(f, 0); - } + NEXT_F2; + t[i] = TRX_1F(f, 0); } } #endif @@ -132,13 +124,11 @@ static void DEST_4UB( GLubyte (*t)[4], (void) start; (void) first; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - if (SZ >= 1) TRX_UB(t[i][0], f, 0); - if (SZ >= 2) TRX_UB(t[i][1], f, 1); - if (SZ >= 3) TRX_UB(t[i][2], f, 2); - if (SZ == 4) TRX_UB(t[i][3], f, 3); else t[i][3] = 255; - } + NEXT_F2; + if (SZ >= 1) TRX_UB(t[i][0], f, 0); + if (SZ >= 2) TRX_UB(t[i][1], f, 1); + if (SZ >= 3) TRX_UB(t[i][2], f, 2); + if (SZ == 4) TRX_UB(t[i][3], f, 3); else t[i][3] = 255; } } #endif @@ -156,13 +146,11 @@ static void DEST_4US( GLushort (*t)[4], (void) start; (void) first; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - if (SZ >= 1) TRX_US(t[i][0], f, 0); - if (SZ >= 2) TRX_US(t[i][1], f, 1); - if (SZ >= 3) TRX_US(t[i][2], f, 2); - if (SZ == 4) TRX_US(t[i][3], f, 3); else t[i][3] = 65535; - } + NEXT_F2; + if (SZ >= 1) TRX_US(t[i][0], f, 0); + if (SZ >= 2) TRX_US(t[i][1], f, 1); + if (SZ >= 3) TRX_US(t[i][2], f, 2); + if (SZ == 4) TRX_US(t[i][3], f, 3); else t[i][3] = 65535; } } #endif @@ -180,10 +168,8 @@ static void DEST_1UB( GLubyte *t, (void) start; (void) first; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - TRX_UB(t[i], f, 0); - } + NEXT_F2; + TRX_UB(t[i], f, 0); } } #endif @@ -202,10 +188,8 @@ static void DEST_1UI( GLuint *t, (void) first; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - t[i] = TRX_UI(f, 0); - } + NEXT_F2; + t[i] = TRX_UI(f, 0); } } #endif @@ -214,19 +198,19 @@ static void DEST_1UI( GLuint *t, static void INIT(void) { #ifdef DEST_1UI - ASSERT(SZ == 1); + assert(SZ == 1); TAB(_1ui)[SRC_IDX] = DEST_1UI; #endif #ifdef DEST_1UB - ASSERT(SZ == 1); + assert(SZ == 1); TAB(_1ub)[SRC_IDX] = DEST_1UB; #endif #ifdef DEST_1F - ASSERT(SZ == 1); + assert(SZ == 1); TAB(_1f)[SRC_IDX] = DEST_1F; #endif #ifdef DEST_3FN - ASSERT(SZ == 3); + assert(SZ == 3); TAB(_3fn)[SRC_IDX] = DEST_3FN; #endif #ifdef DEST_4UB diff --git a/mesalib/src/mesa/math/m_translate.c b/mesalib/src/mesa/math/m_translate.c index 3a8ca74f6..a5bf5d76f 100644 --- a/mesalib/src/mesa/math/m_translate.c +++ b/mesalib/src/mesa/math/m_translate.c @@ -84,10 +84,6 @@ typedef void (*trans_3fn_func)(GLfloat (*to)[3], #define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */ -/* This macro is used on other systems, so undefine it for this module */ - -#undef CHECK - static trans_1f_func _math_trans_1f_tab[MAX_TYPES]; static trans_1ui_func _math_trans_1ui_tab[MAX_TYPES]; static trans_1ub_func _math_trans_1ub_tab[MAX_TYPES]; @@ -108,7 +104,6 @@ static trans_4f_func _math_trans_4fn_tab[5][MAX_TYPES]; #define STRIDE stride #define NEXT_F f += stride #define NEXT_F2 -#define CHECK @@ -604,7 +599,6 @@ static void init_translate_raw(void) #undef CLASS #endif #undef ARGS -#undef CHECK #undef SRC_START #undef DST_START #undef NEXT_F diff --git a/mesalib/src/mesa/math/m_translate.h b/mesalib/src/mesa/math/m_translate.h index bdfa4c770..62f676ca6 100644 --- a/mesalib/src/mesa/math/m_translate.h +++ b/mesalib/src/mesa/math/m_translate.h @@ -26,7 +26,6 @@ #ifndef _M_TRANSLATE_H_ #define _M_TRANSLATE_H_ -#include "main/compiler.h" #include "main/glheader.h" /** diff --git a/mesalib/src/mesa/math/m_vector.c b/mesalib/src/mesa/math/m_vector.c index ff42396b7..831f953d6 100644 --- a/mesalib/src/mesa/math/m_vector.c +++ b/mesalib/src/mesa/math/m_vector.c @@ -26,6 +26,7 @@ * New (3.1) transformation code written by Keith Whitwell. */ +#include <stdio.h> #include "main/glheader.h" #include "main/imports.h" diff --git a/mesalib/src/mesa/math/m_xform.c b/mesalib/src/mesa/math/m_xform.c index 14d1c6453..718ad4993 100644 --- a/mesalib/src/mesa/math/m_xform.c +++ b/mesalib/src/mesa/math/m_xform.c @@ -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" diff --git a/mesalib/src/mesa/math/m_xform.h b/mesalib/src/mesa/math/m_xform.h index e45880322..2ed62e711 100644 --- a/mesalib/src/mesa/math/m_xform.h +++ b/mesalib/src/mesa/math/m_xform.h @@ -119,7 +119,7 @@ typedef void (*vec_copy_func)( GLvector4f *to, /* * Functions for transformation of normals in the VB. */ -typedef void (_NORMAPIP normal_func)( const GLmatrix *mat, +typedef void (_XFORMAPIP normal_func)( const GLmatrix *mat, GLfloat scale, const GLvector4f *in, const GLfloat lengths[], |