mesa: only update fixed-func programs on texture matrix enablement changes
authorMarek Olšák <marek.olsak@amd.com>
Wed, 3 Feb 2021 18:03:24 +0000 (13:03 -0500)
committerMarge Bot <eric+marge@anholt.net>
Fri, 26 Feb 2021 23:38:02 +0000 (23:38 +0000)
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 <zboszor@gmail.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8850>

src/mesa/main/state.c
src/mesa/main/texstate.c
src/mesa/main/texstate.h

index 8ddc102..2ec208c 100644 (file)
@@ -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) {
index 3beb536..1e8baea 100644 (file)
@@ -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;
 }
 
 
index 1244f77..bc9a645 100644 (file)
@@ -109,7 +109,7 @@ _mesa_ClientActiveTexture( GLenum target );
  */
 /*@{*/
 
-extern void
+extern GLbitfield
 _mesa_update_texture_matrices(struct gl_context *ctx);
 
 extern GLbitfield