mesa: don't compute the inverted projection matrix if not used

Only clip planes and GLSL built-in uniforms use it.

update_projection (called by _mesa_update_state) removes
the _math_matrix_analyse call, reducing the time spent
in _mesa_update_state.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8850>
This commit is contained in:
Marek Olšák 2021-02-01 14:03:46 -05:00 committed by Marge Bot
parent bc05833c8a
commit 9f632df4b2
3 changed files with 18 additions and 14 deletions

View File

@ -38,6 +38,7 @@
void
_mesa_update_clip_plane(struct gl_context *ctx, GLuint plane)
{
/* make sure the inverse is up to date */
if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top))
_math_matrix_analyse( ctx->ProjectionMatrixStack.Top );

View File

@ -914,8 +914,7 @@ _mesa_MatrixMultTransposedEXT( GLenum matrixMode, const GLdouble *m )
*
* \param ctx GL context.
*
* Calls _math_matrix_analyse() with the top-matrix of the projection matrix
* stack, and recomputes user clip positions if necessary.
* Recomputes user clip positions if necessary.
*
* \note This routine references __struct gl_contextRec::Tranform attribute
* values to compute userclip positions in clip space, but is only called on
@ -925,20 +924,22 @@ _mesa_MatrixMultTransposedEXT( GLenum matrixMode, const GLdouble *m )
static void
update_projection( struct gl_context *ctx )
{
GLbitfield mask;
_math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
/* Recompute clip plane positions in clipspace. This is also done
* in _mesa_ClipPlane().
*/
mask = ctx->Transform.ClipPlanesEnabled;
while (mask) {
const int p = u_bit_scan(&mask);
GLbitfield mask = ctx->Transform.ClipPlanesEnabled;
_mesa_transform_vector( ctx->Transform._ClipUserPlane[p],
ctx->Transform.EyeUserPlane[p],
ctx->ProjectionMatrixStack.Top->inv );
if (mask) {
/* make sure the inverse is up to date */
_math_matrix_analyse(ctx->ProjectionMatrixStack.Top);
do {
const int p = u_bit_scan(&mask);
_mesa_transform_vector(ctx->Transform._ClipUserPlane[p],
ctx->Transform.EyeUserPlane[p],
ctx->ProjectionMatrixStack.Top->inv);
} while (mask);
}
}

View File

@ -275,7 +275,8 @@ fetch_state(struct gl_context *ctx, const gl_state_index16 state[],
return;
}
case STATE_PROJECTION_MATRIX_INVERSE: {
const GLmatrix *matrix = ctx->ProjectionMatrixStack.Top;
GLmatrix *matrix = ctx->ProjectionMatrixStack.Top;
_math_matrix_analyse(matrix); /* make sure the inverse is up to date */
copy_matrix(value, matrix->inv, state[2], state[3]);
return;
}
@ -285,7 +286,8 @@ fetch_state(struct gl_context *ctx, const gl_state_index16 state[],
return;
}
case STATE_PROJECTION_MATRIX_INVTRANS: {
const GLmatrix *matrix = ctx->ProjectionMatrixStack.Top;
GLmatrix *matrix = ctx->ProjectionMatrixStack.Top;
_math_matrix_analyse(matrix); /* make sure the inverse is up to date */
copy_matrix_transposed(value, matrix->inv, state[2], state[3]);
return;
}