From 2d8db39301349f67e17fc1b21e5d33d5f44cd521 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 Jun 2000 22:10:00 +0000 Subject: added aligned memory allocations (Gareth Hughes) --- src/mesa/main/matrix.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/mesa/main/matrix.c') diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c index 5eb5bb43f0..5db2542a6e 100644 --- a/src/mesa/main/matrix.c +++ b/src/mesa/main/matrix.c @@ -1,4 +1,4 @@ -/* $Id: matrix.c,v 1.17 2000/04/08 18:57:45 brianp Exp $ */ +/* $Id: matrix.c,v 1.18 2000/06/27 22:10:00 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1562,16 +1562,23 @@ void gl_calculate_model_project_matrix( GLcontext *ctx ) void gl_matrix_ctr( GLmatrix *m ) { + if ( m->m == 0 ) { + m->m = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 ); + } + MEMCPY( m->m, Identity, sizeof(Identity) ); m->inv = 0; - MEMCPY( m->m, Identity, sizeof(Identity)); m->type = MATRIX_IDENTITY; m->flags = MAT_DIRTY_DEPENDENTS; } void gl_matrix_dtr( GLmatrix *m ) { - if (m->inv != 0) { - FREE(m->inv); + if ( m->m != 0 ) { + ALIGN_FREE( m->m ); + m->m = 0; + } + if ( m->inv != 0 ) { + ALIGN_FREE( m->inv ); m->inv = 0; } } @@ -1579,7 +1586,7 @@ void gl_matrix_dtr( GLmatrix *m ) #if 0 void gl_matrix_set_identity( GLmatrix *m ) { - MEMCPY( m->m, Identity, sizeof(Identity)); + MEMCPY( m->m, Identity, sizeof(Identity) ); m->type = MATRIX_IDENTITY; m->flags = MAT_DIRTY_DEPENDENTS; } @@ -1587,15 +1594,15 @@ void gl_matrix_set_identity( GLmatrix *m ) void gl_matrix_alloc_inv( GLmatrix *m ) { - if (m->inv == 0) { - m->inv = (GLfloat *)MALLOC(16*sizeof(GLfloat)); + if ( m->inv == 0 ) { + m->inv = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 ); MEMCPY( m->inv, Identity, 16 * sizeof(GLfloat) ); } } void gl_matrix_copy( GLmatrix *to, const GLmatrix *from ) { - MEMCPY( to->m, from->m, sizeof(Identity)); + MEMCPY( to->m, from->m, sizeof(Identity) ); to->flags = from->flags | MAT_DIRTY_DEPENDENTS; to->type = from->type; -- cgit v1.2.3