summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/arrayobj.c
diff options
context:
space:
mode:
authorFredrik Höglund <[email protected]>2015-03-02 18:25:45 +0100
committerFredrik Höglund <[email protected]>2015-05-08 15:31:02 +0200
commit6c37acfbedb88b460d2997f8b2d7b0e04a8782df (patch)
tree26ea46a6f300968164e5d52f39da95860c668579 /src/mesa/main/arrayobj.c
parent2830c2fbeb9601c1760a9fffe45cd04f8c635d25 (diff)
mesa: Keep track of the last looked-up VAO
This saves the cost of repeated hash table lookups when the same vertex array object is referenced in a sequence of calls such as: glVertexArrayAttribFormat(vao, ...); glVertexArrayAttribBinding(vao, ...); glEnableVertexArrayAttrib(vao, ...); ... Note that VAO's are container objects that are not shared between contexts. Reviewed-by: Laura Ekstrand <[email protected]>
Diffstat (limited to 'src/mesa/main/arrayobj.c')
-rw-r--r--src/mesa/main/arrayobj.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 33c6a459539..42214d8d6a0 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -100,20 +100,28 @@ _mesa_lookup_vao_err(struct gl_context *ctx, GLuint id, const char *caller)
return ctx->Array.DefaultVAO;
} else {
- struct gl_vertex_array_object *vao =
- (struct gl_vertex_array_object *)
- _mesa_HashLookup(ctx->Array.Objects, id);
+ struct gl_vertex_array_object *vao;
- /* The ARB_direct_state_access specification says:
- *
- * "An INVALID_OPERATION error is generated if <vaobj> is not
- * [compatibility profile: zero or] the name of an existing
- * vertex array object."
- */
- if (!vao || !vao->EverBound) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(non-existent vaobj=%u)", caller, id);
- return NULL;
+ if (ctx->Array.LastLookedUpVAO &&
+ ctx->Array.LastLookedUpVAO->Name == id) {
+ vao = ctx->Array.LastLookedUpVAO;
+ } else {
+ vao = (struct gl_vertex_array_object *)
+ _mesa_HashLookup(ctx->Array.Objects, id);
+
+ /* The ARB_direct_state_access specification says:
+ *
+ * "An INVALID_OPERATION error is generated if <vaobj> is not
+ * [compatibility profile: zero or] the name of an existing
+ * vertex array object."
+ */
+ if (!vao || !vao->EverBound) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(non-existent vaobj=%u)", caller, id);
+ return NULL;
+ }
+
+ _mesa_reference_vao(ctx, &ctx->Array.LastLookedUpVAO, vao);
}
return vao;
@@ -517,6 +525,9 @@ _mesa_DeleteVertexArrays(GLsizei n, const GLuint *ids)
/* The ID is immediately freed for re-use */
remove_array_object(ctx, obj);
+ if (ctx->Array.LastLookedUpVAO == obj)
+ _mesa_reference_vao(ctx, &ctx->Array.LastLookedUpVAO, NULL);
+
/* Unreference the array object.
* If refcount hits zero, the object will be deleted.
*/