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:
parent
bc05833c8a
commit
9f632df4b2
|
@ -38,6 +38,7 @@
|
||||||
void
|
void
|
||||||
_mesa_update_clip_plane(struct gl_context *ctx, GLuint plane)
|
_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))
|
if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top))
|
||||||
_math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
|
_math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
|
||||||
|
|
||||||
|
|
|
@ -914,8 +914,7 @@ _mesa_MatrixMultTransposedEXT( GLenum matrixMode, const GLdouble *m )
|
||||||
*
|
*
|
||||||
* \param ctx GL context.
|
* \param ctx GL context.
|
||||||
*
|
*
|
||||||
* Calls _math_matrix_analyse() with the top-matrix of the projection matrix
|
* Recomputes user clip positions if necessary.
|
||||||
* stack, and recomputes user clip positions if necessary.
|
|
||||||
*
|
*
|
||||||
* \note This routine references __struct gl_contextRec::Tranform attribute
|
* \note This routine references __struct gl_contextRec::Tranform attribute
|
||||||
* values to compute userclip positions in clip space, but is only called on
|
* 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
|
static void
|
||||||
update_projection( struct gl_context *ctx )
|
update_projection( struct gl_context *ctx )
|
||||||
{
|
{
|
||||||
GLbitfield mask;
|
|
||||||
|
|
||||||
_math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
|
|
||||||
|
|
||||||
/* Recompute clip plane positions in clipspace. This is also done
|
/* Recompute clip plane positions in clipspace. This is also done
|
||||||
* in _mesa_ClipPlane().
|
* in _mesa_ClipPlane().
|
||||||
*/
|
*/
|
||||||
mask = ctx->Transform.ClipPlanesEnabled;
|
GLbitfield mask = ctx->Transform.ClipPlanesEnabled;
|
||||||
while (mask) {
|
|
||||||
const int p = u_bit_scan(&mask);
|
|
||||||
|
|
||||||
_mesa_transform_vector( ctx->Transform._ClipUserPlane[p],
|
if (mask) {
|
||||||
ctx->Transform.EyeUserPlane[p],
|
/* make sure the inverse is up to date */
|
||||||
ctx->ProjectionMatrixStack.Top->inv );
|
_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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,7 +275,8 @@ fetch_state(struct gl_context *ctx, const gl_state_index16 state[],
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case STATE_PROJECTION_MATRIX_INVERSE: {
|
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]);
|
copy_matrix(value, matrix->inv, state[2], state[3]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -285,7 +286,8 @@ fetch_state(struct gl_context *ctx, const gl_state_index16 state[],
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case STATE_PROJECTION_MATRIX_INVTRANS: {
|
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]);
|
copy_matrix_transposed(value, matrix->inv, state[2], state[3]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue