summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/arrayobj.c
diff options
context:
space:
mode:
authorFredrik Höglund <fredrik@kde.org>2015-03-02 18:24:36 +0100
committerFredrik Höglund <fredrik@kde.org>2015-05-08 15:31:02 +0200
commit2830c2fbeb9601c1760a9fffe45cd04f8c635d25 (patch)
tree2bd944d34a0ff96a07a961b4f9e6791131ed1bc2 /src/mesa/main/arrayobj.c
parenta1f48268b4ee166eb9fde21bceaaef12a6e0c89a (diff)
downloadexternal_mesa3d-2830c2fbeb9601c1760a9fffe45cd04f8c635d25.zip
external_mesa3d-2830c2fbeb9601c1760a9fffe45cd04f8c635d25.tar.gz
external_mesa3d-2830c2fbeb9601c1760a9fffe45cd04f8c635d25.tar.bz2
mesa: Add _mesa_lookup_vao_err
This is a convenience function that generates GL_INVALID_OPERATION when the array object doesn't exist. Reviewed-by: Laura Ekstrand <laura@jlekstrand.net>
Diffstat (limited to 'src/mesa/main/arrayobj.c')
-rw-r--r--src/mesa/main/arrayobj.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index ea56154..33c6a45 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -75,6 +75,53 @@ _mesa_lookup_vao(struct gl_context *ctx, GLuint id)
/**
+ * Looks up the array object for the given ID.
+ *
+ * Unlike _mesa_lookup_vao, this function generates a GL_INVALID_OPERATION
+ * error if the array object does not exist. It also returns the default
+ * array object when ctx is a compatibility profile context and id is zero.
+ */
+struct gl_vertex_array_object *
+_mesa_lookup_vao_err(struct gl_context *ctx, GLuint id, const char *caller)
+{
+ /* The ARB_direct_state_access specification says:
+ *
+ * "<vaobj> is [compatibility profile:
+ * zero, indicating the default vertex array object, or]
+ * the name of the vertex array object."
+ */
+ if (id == 0) {
+ if (ctx->API == API_OPENGL_CORE) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(zero is not valid vaobj name in a core profile "
+ "context)", caller);
+ return NULL;
+ }
+
+ return ctx->Array.DefaultVAO;
+ } else {
+ struct gl_vertex_array_object *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;
+ }
+
+ return vao;
+ }
+}
+
+
+/**
* For all the vertex binding points in the array object, unbind any pointers
* to any buffer objects (VBOs).
* This is done just prior to array object destruction.