From ec978e002f59c8ed829e354f8ca8d9440df487f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 3 Feb 2021 13:03:24 -0500 Subject: [PATCH] mesa: only update fixed-func programs on texture matrix enablement changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should reduce fixed-func program key recomputations. I also update the fixed-func fragment program, which was incorrectly ignored because it's clearly used there. Reviewed-by: Zoltán Böszörményi Acked-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/mesa/main/state.c | 6 +++--- src/mesa/main/texstate.c | 8 +++++++- src/mesa/main/texstate.h | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 8ddc10200ba..2ec208c9dba 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -457,7 +457,7 @@ _mesa_update_state_locked( struct gl_context *ctx ) _mesa_update_modelview_project( ctx, new_state ); if (new_state & _NEW_TEXTURE_MATRIX) - _mesa_update_texture_matrices(ctx); + new_state |= _mesa_update_texture_matrices(ctx); if (new_state & (_NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE | _NEW_PROGRAM)) new_state |= _mesa_update_texture_state(ctx); @@ -493,8 +493,8 @@ _mesa_update_state_locked( struct gl_context *ctx ) } if (ctx->VertexProgram._UsesTnlProgram) { - prog_flags |= _NEW_FF_VERT_PROGRAM | _NEW_TEXTURE_MATRIX | - _NEW_TRANSFORM | _NEW_POINT | _NEW_FOG; + prog_flags |= _NEW_FF_VERT_PROGRAM | _NEW_TRANSFORM | _NEW_POINT | + _NEW_FOG; } if (new_state & prog_flags) { diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 3beb5363cf6..1e8baea06a3 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -387,10 +387,11 @@ _mesa_ClientActiveTexture(GLenum texture) * * \param ctx GL context. */ -void +GLbitfield _mesa_update_texture_matrices(struct gl_context *ctx) { GLuint u; + GLbitfield old_texmat_enabled = ctx->Texture._TexMatEnabled; ctx->Texture._TexMatEnabled = 0x0; @@ -404,6 +405,11 @@ _mesa_update_texture_matrices(struct gl_context *ctx) ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(u); } } + + if (old_texmat_enabled != ctx->Texture._TexMatEnabled) + return _NEW_FF_VERT_PROGRAM | _NEW_FF_FRAG_PROGRAM; + + return 0; } diff --git a/src/mesa/main/texstate.h b/src/mesa/main/texstate.h index 1244f77c9e9..bc9a6457305 100644 --- a/src/mesa/main/texstate.h +++ b/src/mesa/main/texstate.h @@ -109,7 +109,7 @@ _mesa_ClientActiveTexture( GLenum target ); */ /*@{*/ -extern void +extern GLbitfield _mesa_update_texture_matrices(struct gl_context *ctx); extern GLbitfield