added FLUSH_VERTICES() in _mesa_use_program()
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index 1914adb..8429600 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -842,6 +842,14 @@
 void
 _mesa_use_program(GLcontext *ctx, GLuint program)
 {
+   if (ctx->Shader.CurrentProgram &&
+       ctx->Shader.CurrentProgram->Name == program) {
+      /* no-op */
+      return;
+   }
+
+   FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+
    /* unbind old */
    if (ctx->Shader.CurrentProgram) {
       ctx->Shader.CurrentProgram->RefCount--;