mesa: port the LastLookedUpVAO optimisation to _mesa_lookup_vao()
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 24 Aug 2017 13:53:34 +0000 (15:53 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 25 Aug 2017 09:11:54 +0000 (11:11 +0200)
It was only used in the errors path.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/main/arrayobj.c

index 600177cc5c950ab5435391ffaab88a3257a1d65b..88a5702f41253f179a6bd1be19e06d47bbdc663a 100644 (file)
 struct gl_vertex_array_object *
 _mesa_lookup_vao(struct gl_context *ctx, GLuint id)
 {
-   if (id == 0)
+   if (id == 0) {
       return NULL;
-   else
-      return (struct gl_vertex_array_object *)
-         _mesa_HashLookupLocked(ctx->Array.Objects, id);
+   } else {
+      struct gl_vertex_array_object *vao;
+
+      if (ctx->Array.LastLookedUpVAO &&
+          ctx->Array.LastLookedUpVAO->Name == id) {
+         vao = ctx->Array.LastLookedUpVAO;
+      } else {
+         vao = (struct gl_vertex_array_object *)
+            _mesa_HashLookupLocked(ctx->Array.Objects, id);
+
+         _mesa_reference_vao(ctx, &ctx->Array.LastLookedUpVAO, vao);
+      }
+
+      return vao;
+   }
 }