summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2012-07-25 07:33:19 -0600
committerBrian Paul <[email protected]>2012-07-26 13:59:44 -0600
commit66d9ac5ac7896538d38f57950888a0184c933925 (patch)
tree5633a18dcb754bcf292c3ff8d2667e7849262c77 /src
parent50db8129152f3d5ea8db13d55f82673d53bf1b8f (diff)
mesa: remove _math_matrix_alloc_inv()
Always allocate space for the inverse matrix in _math_matrix_ctr() since we were always calling _math_matrix_alloc_inv() anyway. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/matrix.c4
-rw-r--r--src/mesa/math/m_matrix.c51
-rw-r--r--src/mesa/math/m_matrix.h5
-rw-r--r--src/mesa/program/prog_statevars.c1
4 files changed, 13 insertions, 48 deletions
diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c
index f479a22b073..b09fa4d3d81 100644
--- a/src/mesa/main/matrix.c
+++ b/src/mesa/main/matrix.c
@@ -658,8 +658,7 @@ void _mesa_update_modelview_project( struct gl_context *ctx, GLuint new_state )
* \param dirtyFlag dirty flag.
*
* Allocates an array of \p maxDepth elements for the matrix stack and calls
- * _math_matrix_ctr() and _math_matrix_alloc_inv() for each element to
- * initialize it.
+ * _math_matrix_ctr() for each element to initialize it.
*/
static void
init_matrix_stack( struct gl_matrix_stack *stack,
@@ -674,7 +673,6 @@ init_matrix_stack( struct gl_matrix_stack *stack,
stack->Stack = (GLmatrix *) CALLOC(maxDepth * sizeof(GLmatrix));
for (i = 0; i < maxDepth; i++) {
_math_matrix_ctr(&stack->Stack[i]);
- _math_matrix_alloc_inv(&stack->Stack[i]);
}
stack->Top = stack->Stack;
}
diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c
index ffbdcdb4c96..58a691cbf4d 100644
--- a/src/mesa/math/m_matrix.c
+++ b/src/mesa/math/m_matrix.c
@@ -296,19 +296,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);
}
/*@}*/
@@ -1141,9 +1137,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 +1438,9 @@ void
_math_matrix_copy( GLmatrix *to, const GLmatrix *from )
{
memcpy( to->m, from->m, sizeof(Identity) );
+ memcpy(to->inv, from->inv, sizeof(from->inv));
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 +1472,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 +1499,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/src/mesa/math/m_matrix.h b/src/mesa/math/m_matrix.h
index e8e48aab75a..9f4ea258640 100644
--- a/src/mesa/math/m_matrix.h
+++ b/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
diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c
index e881c097aab..3d133867423 100644
--- a/src/mesa/program/prog_statevars.c
+++ b/src/mesa/program/prog_statevars.c
@@ -323,7 +323,6 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
modifier == STATE_MATRIX_INVTRANS) {
/* Be sure inverse is up to date:
*/
- _math_matrix_alloc_inv( (GLmatrix *) matrix );
_math_matrix_analyse( (GLmatrix*) matrix );
m = matrix->inv;
}