aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/math
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-07-31 10:00:43 +0200
committermarha <marha@users.sourceforge.net>2012-07-31 10:00:43 +0200
commitbd27b3d008b0abf9ae2edcb127302728808533e4 (patch)
treea73a74f04a31a0f44465ed82bcf58b180ca53dbd /mesalib/src/mesa/math
parent2ff5448bcca8cba4b62026d5493cb08aaf2838d8 (diff)
downloadvcxsrv-bd27b3d008b0abf9ae2edcb127302728808533e4.tar.gz
vcxsrv-bd27b3d008b0abf9ae2edcb127302728808533e4.tar.bz2
vcxsrv-bd27b3d008b0abf9ae2edcb127302728808533e4.zip
fontconfig libXext mesa xserver pixman git update 31 Jul 2012
Diffstat (limited to 'mesalib/src/mesa/math')
-rw-r--r--mesalib/src/mesa/math/m_debug_norm.c4
-rw-r--r--mesalib/src/mesa/math/m_matrix.c56
-rw-r--r--mesalib/src/mesa/math/m_matrix.h5
3 files changed, 16 insertions, 49 deletions
diff --git a/mesalib/src/mesa/math/m_debug_norm.c b/mesalib/src/mesa/math/m_debug_norm.c
index 02eb1f989..dc768f306 100644
--- a/mesalib/src/mesa/math/m_debug_norm.c
+++ b/mesalib/src/mesa/math/m_debug_norm.c
@@ -165,7 +165,7 @@ static void ref_norm_transform_normalize( const GLmatrix *mat,
/* Hmmm, don't know how we could test the precalculated
* length case...
*/
- scale = 1.0 / SQRTF( len );
+ scale = INV_SQRTF( len );
SCALE_SCALAR_3V( out[i], scale, t );
} else {
out[i][0] = out[i][1] = out[i][2] = 0;
@@ -241,7 +241,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] = 1 / SQRTF( LEN_SQUARED_3FV( s[i] ) );
+ length[i] = INV_SQRTF( LEN_SQUARED_3FV( s[i] ) );
}
source->data = (GLfloat(*)[4]) s;
diff --git a/mesalib/src/mesa/math/m_matrix.c b/mesalib/src/mesa/math/m_matrix.c
index 02aedbad8..00a6c814f 100644
--- a/mesalib/src/mesa/math/m_matrix.c
+++ b/mesalib/src/mesa/math/m_matrix.c
@@ -45,7 +45,6 @@
* \defgroup MatFlags MAT_FLAG_XXX-flags
*
* Bitmasks to indicate different kinds of 4x4 matrices in GLmatrix::flags
- * It would be nice to make all these flags private to m_matrix.c
*/
/*@{*/
#define MAT_FLAG_IDENTITY 0 /**< is an identity matrix flag.
@@ -296,19 +295,15 @@ static void print_matrix_floats( const GLfloat m[16] )
void
_math_matrix_print( const GLmatrix *m )
{
+ GLfloat prod[16];
+
_mesa_debug(NULL, "Matrix type: %s, flags: %x\n", types[m->type], m->flags);
print_matrix_floats(m->m);
_mesa_debug(NULL, "Inverse: \n");
- if (m->inv) {
- GLfloat prod[16];
- print_matrix_floats(m->inv);
- matmul4(prod, m->m, m->inv);
- _mesa_debug(NULL, "Mat * Inverse:\n");
- print_matrix_floats(prod);
- }
- else {
- _mesa_debug(NULL, " - not available\n");
- }
+ print_matrix_floats(m->inv);
+ matmul4(prod, m->m, m->inv);
+ _mesa_debug(NULL, "Mat * Inverse:\n");
+ print_matrix_floats(prod);
}
/*@}*/
@@ -333,7 +328,7 @@ _math_matrix_print( const GLmatrix *m )
/*@{*/
/**
- * Swaps the values of two floating pointer variables.
+ * Swaps the values of two floating point variables.
*
* Used by invert_matrix_general() to swap the row pointers.
*/
@@ -513,7 +508,7 @@ static GLboolean invert_matrix_3d_general( GLmatrix *mat )
det = pos + neg;
- if (det*det < 1e-25)
+ if (FABSF(det) < 1e-25)
return GL_FALSE;
det = 1.0F / det;
@@ -1141,9 +1136,7 @@ void
_math_matrix_set_identity( GLmatrix *mat )
{
memcpy( mat->m, Identity, 16*sizeof(GLfloat) );
-
- if (mat->inv)
- memcpy( mat->inv, Identity, 16*sizeof(GLfloat) );
+ memcpy( mat->inv, Identity, 16*sizeof(GLfloat) );
mat->type = MATRIX_IDENTITY;
mat->flags &= ~(MAT_DIRTY_FLAGS|
@@ -1444,17 +1437,9 @@ void
_math_matrix_copy( GLmatrix *to, const GLmatrix *from )
{
memcpy( to->m, from->m, sizeof(Identity) );
+ memcpy(to->inv, from->inv, 16 * sizeof(GLfloat));
to->flags = from->flags;
to->type = from->type;
-
- if (to->inv != 0) {
- if (from->inv == 0) {
- matrix_invert( to );
- }
- else {
- memcpy(to->inv, from->inv, sizeof(GLfloat)*16);
- }
- }
}
/**
@@ -1486,7 +1471,9 @@ _math_matrix_ctr( GLmatrix *m )
m->m = (GLfloat *) _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
if (m->m)
memcpy( m->m, Identity, sizeof(Identity) );
- m->inv = NULL;
+ m->inv = (GLfloat *) _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
+ if (m->inv)
+ memcpy( m->inv, Identity, sizeof(Identity) );
m->type = MATRIX_IDENTITY;
m->flags = 0;
}
@@ -1511,23 +1498,6 @@ _math_matrix_dtr( GLmatrix *m )
}
}
-/**
- * Allocate a matrix inverse.
- *
- * \param m matrix.
- *
- * Allocates the matrix inverse, GLmatrix::inv, and sets it to Identity.
- */
-void
-_math_matrix_alloc_inv( GLmatrix *m )
-{
- if (!m->inv) {
- m->inv = (GLfloat *) _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
- if (m->inv)
- memcpy( m->inv, Identity, 16 * sizeof(GLfloat) );
- }
-}
-
/*@}*/
diff --git a/mesalib/src/mesa/math/m_matrix.h b/mesalib/src/mesa/math/m_matrix.h
index e8e48aab7..9f4ea2586 100644
--- a/mesalib/src/mesa/math/m_matrix.h
+++ b/mesalib/src/mesa/math/m_matrix.h
@@ -74,7 +74,7 @@ enum GLmatrixtype {
*/
typedef struct {
GLfloat *m; /**< 16 matrix elements (16-byte aligned) */
- GLfloat *inv; /**< optional 16-element inverse (16-byte aligned) */
+ GLfloat *inv; /**< 16-element inverse (16-byte aligned) */
GLuint flags; /**< possible values determined by (of \link
* MatFlags MAT_FLAG_* flags\endlink)
*/
@@ -91,9 +91,6 @@ extern void
_math_matrix_dtr( GLmatrix *m );
extern void
-_math_matrix_alloc_inv( GLmatrix *m );
-
-extern void
_math_matrix_mul_matrix( GLmatrix *dest, const GLmatrix *a, const GLmatrix *b );
extern void