mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 07:18:17 +02:00
mesa: allocate GLmatrix aligned to 16 bytes
The declaration has:
typedef struct {
alignas(16) GLfloat m[16]; /**< 16 matrix elements (16-byte aligned) */
alignas(16) GLfloat inv[16]; /**< 16-element inverse (16-byte aligned) */
...
} GLmatrix;
We should honor that.
Fixes: 3175b63a0d - mesa: don't allocate matrices with malloc
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10237
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33856>
This commit is contained in:
parent
1493f88f88
commit
7655826243
1 changed files with 5 additions and 4 deletions
|
|
@ -311,8 +311,9 @@ push_matrix(struct gl_context *ctx, struct gl_matrix_stack *stack,
|
|||
if (stack->Depth + 1 >= stack->StackSize) {
|
||||
unsigned new_stack_size = stack->StackSize * 2;
|
||||
unsigned i;
|
||||
GLmatrix *new_stack = realloc(stack->Stack,
|
||||
sizeof(*new_stack) * new_stack_size);
|
||||
GLmatrix *new_stack =
|
||||
os_realloc_aligned(stack->Stack, stack->StackSize * sizeof(GLmatrix),
|
||||
new_stack_size * sizeof(GLmatrix), 16);
|
||||
|
||||
if (!new_stack) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
|
||||
|
|
@ -1008,7 +1009,7 @@ init_matrix_stack(struct gl_matrix_stack *stack,
|
|||
stack->MaxDepth = maxDepth;
|
||||
stack->DirtyFlag = dirtyFlag;
|
||||
/* The stack will be dynamically resized at glPushMatrix() time */
|
||||
stack->Stack = calloc(1, sizeof(GLmatrix));
|
||||
stack->Stack = os_malloc_aligned(sizeof(GLmatrix), 16);
|
||||
stack->StackSize = 1;
|
||||
_math_matrix_ctr(&stack->Stack[0]);
|
||||
stack->Top = stack->Stack;
|
||||
|
|
@ -1023,7 +1024,7 @@ init_matrix_stack(struct gl_matrix_stack *stack,
|
|||
static void
|
||||
free_matrix_stack( struct gl_matrix_stack *stack )
|
||||
{
|
||||
free(stack->Stack);
|
||||
os_free_aligned(stack->Stack);
|
||||
stack->Stack = stack->Top = NULL;
|
||||
stack->StackSize = 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue