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:
parent
9c84ca574d
commit
3175b63a0d
|
@ -600,8 +600,6 @@ intelDestroyContext(__DRIcontext * driContextPriv)
|
||||||
/* free the Mesa context */
|
/* free the Mesa context */
|
||||||
_mesa_free_context_data(&intel->ctx, true);
|
_mesa_free_context_data(&intel->ctx, true);
|
||||||
|
|
||||||
_math_matrix_dtr(&intel->ViewportMatrix);
|
|
||||||
|
|
||||||
ralloc_free(intel);
|
ralloc_free(intel);
|
||||||
driContextPriv->driverPrivate = NULL;
|
driContextPriv->driverPrivate = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -490,6 +490,4 @@ nv10_emit_projection(struct gl_context *ctx, int emit)
|
||||||
|
|
||||||
BEGIN_NV04(push, NV10_3D(PROJECTION_MATRIX(0)), 16);
|
BEGIN_NV04(push, NV10_3D(PROJECTION_MATRIX(0)), 16);
|
||||||
PUSH_DATAm(push, m.m);
|
PUSH_DATAm(push, m.m);
|
||||||
|
|
||||||
_math_matrix_dtr(&m);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -378,6 +378,4 @@ nv20_emit_projection(struct gl_context *ctx, int emit)
|
||||||
|
|
||||||
BEGIN_NV04(push, NV20_3D(PROJECTION_MATRIX(0)), 16);
|
BEGIN_NV04(push, NV20_3D(PROJECTION_MATRIX(0)), 16);
|
||||||
PUSH_DATAm(push, m.m);
|
PUSH_DATAm(push, m.m);
|
||||||
|
|
||||||
_math_matrix_dtr(&m);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -408,13 +408,5 @@ GLboolean r200CreateContext( gl_api api,
|
||||||
|
|
||||||
void r200DestroyContext( __DRIcontext *driContextPriv )
|
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);
|
radeonDestroyContext(driContextPriv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1012,17 +1012,10 @@ init_matrix_stack(struct gl_matrix_stack *stack,
|
||||||
* Free matrix stack.
|
* Free matrix stack.
|
||||||
*
|
*
|
||||||
* \param stack matrix stack.
|
* \param stack matrix stack.
|
||||||
*
|
|
||||||
* Calls _math_matrix_dtr() for each element of the matrix stack and
|
|
||||||
* frees the array.
|
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
free_matrix_stack( struct gl_matrix_stack *stack )
|
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);
|
free(stack->Stack);
|
||||||
stack->Stack = stack->Top = NULL;
|
stack->Stack = stack->Top = NULL;
|
||||||
stack->StackSize = 0;
|
stack->StackSize = 0;
|
||||||
|
@ -1071,8 +1064,7 @@ void _mesa_init_matrix( struct gl_context * ctx )
|
||||||
*
|
*
|
||||||
* \param ctx GL context.
|
* \param ctx GL context.
|
||||||
*
|
*
|
||||||
* Frees each of the matrix stacks and the combined modelview-projection
|
* Frees each of the matrix stacks.
|
||||||
* matrix.
|
|
||||||
*/
|
*/
|
||||||
void _mesa_free_matrix_data( struct gl_context *ctx )
|
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]);
|
free_matrix_stack(&ctx->TextureMatrixStack[i]);
|
||||||
for (i = 0; i < ARRAY_SIZE(ctx->ProgramMatrixStack); i++)
|
for (i = 0; i < ARRAY_SIZE(ctx->ProgramMatrixStack); i++)
|
||||||
free_matrix_stack(&ctx->ProgramMatrixStack[i]);
|
free_matrix_stack(&ctx->ProgramMatrixStack[i]);
|
||||||
/* combined Modelview*Projection matrix */
|
|
||||||
_math_matrix_dtr( &ctx->_ModelProjectMatrix );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1499,33 +1499,12 @@ _math_matrix_loadf( GLmatrix *mat, const GLfloat *m )
|
||||||
void
|
void
|
||||||
_math_matrix_ctr( GLmatrix *m )
|
_math_matrix_ctr( GLmatrix *m )
|
||||||
{
|
{
|
||||||
m->m = align_malloc( 16 * sizeof(GLfloat), 16 );
|
memcpy( m->m, Identity, sizeof(Identity) );
|
||||||
if (m->m)
|
memcpy( m->inv, Identity, sizeof(Identity) );
|
||||||
memcpy( m->m, Identity, sizeof(Identity) );
|
|
||||||
m->inv = align_malloc( 16 * sizeof(GLfloat), 16 );
|
|
||||||
if (m->inv)
|
|
||||||
memcpy( m->inv, Identity, sizeof(Identity) );
|
|
||||||
m->type = MATRIX_IDENTITY;
|
m->type = MATRIX_IDENTITY;
|
||||||
m->flags = 0;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -73,8 +73,8 @@ enum GLmatrixtype {
|
||||||
* Matrix type to represent 4x4 transformation matrices.
|
* Matrix type to represent 4x4 transformation matrices.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GLfloat *m; /**< 16 matrix elements (16-byte aligned) */
|
ALIGN16 GLfloat m[16]; /**< 16 matrix elements (16-byte aligned) */
|
||||||
GLfloat *inv; /**< 16-element inverse (16-byte aligned) */
|
ALIGN16 GLfloat inv[16]; /**< 16-element inverse (16-byte aligned) */
|
||||||
GLuint flags; /**< possible values determined by (of \link
|
GLuint flags; /**< possible values determined by (of \link
|
||||||
* MatFlags MAT_FLAG_* flags\endlink)
|
* MatFlags MAT_FLAG_* flags\endlink)
|
||||||
*/
|
*/
|
||||||
|
@ -87,9 +87,6 @@ typedef struct {
|
||||||
extern void
|
extern void
|
||||||
_math_matrix_ctr( GLmatrix *m );
|
_math_matrix_ctr( GLmatrix *m );
|
||||||
|
|
||||||
extern void
|
|
||||||
_math_matrix_dtr( GLmatrix *m );
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
_math_matrix_mul_matrix( GLmatrix *dest, const GLmatrix *a, const GLmatrix *b );
|
_math_matrix_mul_matrix( GLmatrix *dest, const GLmatrix *a, const GLmatrix *b );
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,6 @@
|
||||||
* _math_matrix_set_identity().
|
* _math_matrix_set_identity().
|
||||||
*/
|
*/
|
||||||
#define MATRIX_M 0
|
#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 */
|
#endif /* _M_VECTOR_ASM_H */
|
||||||
|
|
|
@ -113,8 +113,6 @@ _tnl_DestroyContext( struct gl_context *ctx )
|
||||||
struct tnl_shine_tab *s, *tmps;
|
struct tnl_shine_tab *s, *tmps;
|
||||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||||
|
|
||||||
_math_matrix_dtr(&tnl->_WindowMap);
|
|
||||||
|
|
||||||
/* Free lighting shininess exponentiation table */
|
/* Free lighting shininess exponentiation table */
|
||||||
foreach_s( s, tmps, tnl->_ShineTabList ) {
|
foreach_s( s, tmps, tnl->_ShineTabList ) {
|
||||||
free( s );
|
free( s );
|
||||||
|
|
Loading…
Reference in New Issue