mesa: don't allocate matrices with malloc

There is no reason for it. This removes a pointer indirection.

Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6946>
This commit is contained in:
Marek Olšák 2020-09-28 08:53:42 -04:00 committed by Marge Bot
parent 9c84ca574d
commit 3175b63a0d
9 changed files with 6 additions and 56 deletions

View File

@ -600,8 +600,6 @@ intelDestroyContext(__DRIcontext * driContextPriv)
/* free the Mesa context */
_mesa_free_context_data(&intel->ctx, true);
_math_matrix_dtr(&intel->ViewportMatrix);
ralloc_free(intel);
driContextPriv->driverPrivate = NULL;
}

View File

@ -490,6 +490,4 @@ nv10_emit_projection(struct gl_context *ctx, int emit)
BEGIN_NV04(push, NV10_3D(PROJECTION_MATRIX(0)), 16);
PUSH_DATAm(push, m.m);
_math_matrix_dtr(&m);
}

View File

@ -378,6 +378,4 @@ nv20_emit_projection(struct gl_context *ctx, int emit)
BEGIN_NV04(push, NV20_3D(PROJECTION_MATRIX(0)), 16);
PUSH_DATAm(push, m.m);
_math_matrix_dtr(&m);
}

View File

@ -408,13 +408,5 @@ GLboolean r200CreateContext( gl_api api,
void r200DestroyContext( __DRIcontext *driContextPriv )
{
int i;
r200ContextPtr rmesa = (r200ContextPtr)driContextPriv->driverPrivate;
if (rmesa)
{
for ( i = 0 ; i < R200_MAX_TEXTURE_UNITS ; i++ ) {
_math_matrix_dtr( &rmesa->TexGenMatrix[i] );
}
}
radeonDestroyContext(driContextPriv);
}

View File

@ -1012,17 +1012,10 @@ init_matrix_stack(struct gl_matrix_stack *stack,
* Free matrix stack.
*
* \param stack matrix stack.
*
* Calls _math_matrix_dtr() for each element of the matrix stack and
* frees the array.
*/
static void
free_matrix_stack( struct gl_matrix_stack *stack )
{
GLuint i;
for (i = 0; i < stack->StackSize; i++) {
_math_matrix_dtr(&stack->Stack[i]);
}
free(stack->Stack);
stack->Stack = stack->Top = NULL;
stack->StackSize = 0;
@ -1071,8 +1064,7 @@ void _mesa_init_matrix( struct gl_context * ctx )
*
* \param ctx GL context.
*
* Frees each of the matrix stacks and the combined modelview-projection
* matrix.
* Frees each of the matrix stacks.
*/
void _mesa_free_matrix_data( struct gl_context *ctx )
{
@ -1084,8 +1076,6 @@ void _mesa_free_matrix_data( struct gl_context *ctx )
free_matrix_stack(&ctx->TextureMatrixStack[i]);
for (i = 0; i < ARRAY_SIZE(ctx->ProgramMatrixStack); i++)
free_matrix_stack(&ctx->ProgramMatrixStack[i]);
/* combined Modelview*Projection matrix */
_math_matrix_dtr( &ctx->_ModelProjectMatrix );
}

View File

@ -1499,33 +1499,12 @@ _math_matrix_loadf( GLmatrix *mat, const GLfloat *m )
void
_math_matrix_ctr( GLmatrix *m )
{
m->m = align_malloc( 16 * sizeof(GLfloat), 16 );
if (m->m)
memcpy( m->m, Identity, sizeof(Identity) );
m->inv = align_malloc( 16 * sizeof(GLfloat), 16 );
if (m->inv)
memcpy( m->inv, Identity, sizeof(Identity) );
memcpy( m->m, Identity, sizeof(Identity) );
memcpy( m->inv, Identity, sizeof(Identity) );
m->type = MATRIX_IDENTITY;
m->flags = 0;
}
/**
* Matrix destructor.
*
* \param m matrix.
*
* Frees the data in a GLmatrix.
*/
void
_math_matrix_dtr( GLmatrix *m )
{
align_free( m->m );
m->m = NULL;
align_free( m->inv );
m->inv = NULL;
}
/*@}*/

View File

@ -73,8 +73,8 @@ enum GLmatrixtype {
* Matrix type to represent 4x4 transformation matrices.
*/
typedef struct {
GLfloat *m; /**< 16 matrix elements (16-byte aligned) */
GLfloat *inv; /**< 16-element inverse (16-byte aligned) */
ALIGN16 GLfloat m[16]; /**< 16 matrix elements (16-byte aligned) */
ALIGN16 GLfloat inv[16]; /**< 16-element inverse (16-byte aligned) */
GLuint flags; /**< possible values determined by (of \link
* MatFlags MAT_FLAG_* flags\endlink)
*/
@ -87,9 +87,6 @@ typedef struct {
extern void
_math_matrix_ctr( GLmatrix *m );
extern void
_math_matrix_dtr( GLmatrix *m );
extern void
_math_matrix_mul_matrix( GLmatrix *dest, const GLmatrix *a, const GLmatrix *b );

View File

@ -52,6 +52,6 @@
* _math_matrix_set_identity().
*/
#define MATRIX_M 0
#define MATRIX_INV (MATRIX_M + MATH_ASM_PTR_SIZE)
#define MATRIX_INV (MATRIX_M + 16 * 4)
#endif /* _M_VECTOR_ASM_H */

View File

@ -113,8 +113,6 @@ _tnl_DestroyContext( struct gl_context *ctx )
struct tnl_shine_tab *s, *tmps;
TNLcontext *tnl = TNL_CONTEXT(ctx);
_math_matrix_dtr(&tnl->_WindowMap);
/* Free lighting shininess exponentiation table */
foreach_s( s, tmps, tnl->_ShineTabList ) {
free( s );