mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-01 14:00:16 +01:00
mesa: make glPopMatrix a no-op if the matrix hasn't changed
This happens a lot with viewperf because glMultMatrixf contains identity matrices. Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18828>
This commit is contained in:
parent
0b00a158ad
commit
e6ecd22140
2 changed files with 15 additions and 1 deletions
|
|
@ -122,6 +122,7 @@ static void matrix_frustum(struct gl_matrix_stack* stack,
|
|||
(GLfloat) left, (GLfloat) right,
|
||||
(GLfloat) bottom, (GLfloat) top,
|
||||
(GLfloat) nearval, (GLfloat) farval);
|
||||
stack->ChangedSincePush = true;
|
||||
ctx->NewState |= stack->DirtyFlag;
|
||||
}
|
||||
|
||||
|
|
@ -203,6 +204,7 @@ matrix_ortho(struct gl_matrix_stack* stack,
|
|||
(GLfloat) left, (GLfloat) right,
|
||||
(GLfloat) bottom, (GLfloat) top,
|
||||
(GLfloat) nearval, (GLfloat) farval );
|
||||
stack->ChangedSincePush = true;
|
||||
ctx->NewState |= stack->DirtyFlag;
|
||||
}
|
||||
|
||||
|
|
@ -328,6 +330,7 @@ push_matrix(struct gl_context *ctx, struct gl_matrix_stack *stack,
|
|||
&stack->Stack[stack->Depth]);
|
||||
stack->Depth++;
|
||||
stack->Top = &(stack->Stack[stack->Depth]);
|
||||
stack->ChangedSincePush = false;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -377,7 +380,8 @@ pop_matrix( struct gl_context *ctx, struct gl_matrix_stack *stack )
|
|||
/* If the popped matrix is the same as the current one, treat it as
|
||||
* a no-op change.
|
||||
*/
|
||||
if (memcmp(stack->Top, &stack->Stack[stack->Depth],
|
||||
if (stack->ChangedSincePush &&
|
||||
memcmp(stack->Top, &stack->Stack[stack->Depth],
|
||||
sizeof(GLmatrix))) {
|
||||
FLUSH_VERTICES(ctx, 0, 0);
|
||||
ctx->NewState |= stack->DirtyFlag;
|
||||
|
|
@ -450,6 +454,7 @@ _mesa_load_identity_matrix(struct gl_context *ctx, struct gl_matrix_stack *stack
|
|||
FLUSH_VERTICES(ctx, 0, 0);
|
||||
|
||||
_math_matrix_set_identity(stack->Top);
|
||||
stack->ChangedSincePush = true;
|
||||
ctx->NewState |= stack->DirtyFlag;
|
||||
}
|
||||
|
||||
|
|
@ -495,6 +500,7 @@ _mesa_load_matrix(struct gl_context *ctx, struct gl_matrix_stack *stack,
|
|||
if (memcmp(m, stack->Top->m, 16 * sizeof(GLfloat)) != 0) {
|
||||
FLUSH_VERTICES(ctx, 0, 0);
|
||||
_math_matrix_loadf(stack->Top, m);
|
||||
stack->ChangedSincePush = true;
|
||||
ctx->NewState |= stack->DirtyFlag;
|
||||
}
|
||||
}
|
||||
|
|
@ -583,6 +589,7 @@ matrix_mult(struct gl_matrix_stack *stack, const GLfloat *m, const char* caller)
|
|||
|
||||
FLUSH_VERTICES(ctx, 0, 0);
|
||||
_math_matrix_mul_floats(stack->Top, m);
|
||||
stack->ChangedSincePush = true;
|
||||
ctx->NewState |= stack->DirtyFlag;
|
||||
}
|
||||
|
||||
|
|
@ -628,6 +635,7 @@ matrix_rotate(struct gl_matrix_stack *stack, GLfloat angle,
|
|||
FLUSH_VERTICES(ctx, 0, 0);
|
||||
if (angle != 0.0F) {
|
||||
_math_matrix_rotate(stack->Top, angle, x, y, z);
|
||||
stack->ChangedSincePush = true;
|
||||
ctx->NewState |=stack->DirtyFlag;
|
||||
}
|
||||
}
|
||||
|
|
@ -688,6 +696,7 @@ _mesa_Scalef( GLfloat x, GLfloat y, GLfloat z )
|
|||
|
||||
FLUSH_VERTICES(ctx, 0, 0);
|
||||
_math_matrix_scale( ctx->CurrentStack->Top, x, y, z);
|
||||
ctx->CurrentStack->ChangedSincePush = true;
|
||||
ctx->NewState |= ctx->CurrentStack->DirtyFlag;
|
||||
}
|
||||
|
||||
|
|
@ -704,6 +713,7 @@ _mesa_MatrixScalefEXT( GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z )
|
|||
|
||||
FLUSH_VERTICES(ctx, 0, 0);
|
||||
_math_matrix_scale(stack->Top, x, y, z);
|
||||
stack->ChangedSincePush = true;
|
||||
ctx->NewState |= stack->DirtyFlag;
|
||||
}
|
||||
|
||||
|
|
@ -728,6 +738,7 @@ _mesa_Translatef( GLfloat x, GLfloat y, GLfloat z )
|
|||
|
||||
FLUSH_VERTICES(ctx, 0, 0);
|
||||
_math_matrix_translate( ctx->CurrentStack->Top, x, y, z);
|
||||
ctx->CurrentStack->ChangedSincePush = true;
|
||||
ctx->NewState |= ctx->CurrentStack->DirtyFlag;
|
||||
}
|
||||
|
||||
|
|
@ -743,6 +754,7 @@ _mesa_MatrixTranslatefEXT( GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z )
|
|||
|
||||
FLUSH_VERTICES(ctx, 0, 0);
|
||||
_math_matrix_translate(stack->Top, x, y, z);
|
||||
stack->ChangedSincePush = true;
|
||||
ctx->NewState |= stack->DirtyFlag;
|
||||
}
|
||||
|
||||
|
|
@ -1004,6 +1016,7 @@ init_matrix_stack(struct gl_matrix_stack *stack,
|
|||
stack->StackSize = 1;
|
||||
_math_matrix_ctr(&stack->Stack[0]);
|
||||
stack->Top = stack->Stack;
|
||||
stack->ChangedSincePush = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2791,6 +2791,7 @@ struct gl_matrix_stack
|
|||
GLuint Depth; /**< 0 <= Depth < MaxDepth */
|
||||
GLuint MaxDepth; /**< size of Stack[] array */
|
||||
GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
|
||||
bool ChangedSincePush;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue