glsl: avoid redundant state changes in _mesa_use_program()
authorBrian Paul <brianp@vmware.com>
Wed, 28 Oct 2009 02:09:33 +0000 (20:09 -0600)
committerBrian Paul <brianp@vmware.com>
Wed, 28 Oct 2009 02:10:59 +0000 (20:10 -0600)
src/mesa/shader/shader_api.c

index 30fa58e..453cd39 100644 (file)
@@ -1547,8 +1547,6 @@ _mesa_use_program(GLcontext *ctx, GLuint program)
       return;
    }
 
-   FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
-
    if (program) {
       shProg = _mesa_lookup_shader_program_err(ctx, program, "glUseProgram");
       if (!shProg) {
@@ -1569,7 +1567,10 @@ _mesa_use_program(GLcontext *ctx, GLuint program)
       shProg = NULL;
    }
 
-   _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentProgram, shProg);
+   if (ctx->Shader.CurrentProgram != shProg) {
+      FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
+      _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentProgram, shProg);
+   }
 }