[Mesa-dev] [PATCH 01/21] main: Add utility function _mesa_lookup_bufferobj_err().

Laura Ekstrand laura at jlekstrand.net
Wed Jan 21 17:40:14 PST 2015


---
 src/mesa/main/bufferobj.c | 19 +++++++++++++++++++
 src/mesa/main/bufferobj.h |  4 ++++
 2 files changed, 23 insertions(+)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 0c1ce98..aea7f1d 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1001,6 +1001,25 @@ _mesa_lookup_bufferobj_locked(struct gl_context *ctx, GLuint buffer)
       _mesa_HashLookupLocked(ctx->Shared->BufferObjects, buffer);
 }
 
+/**
+ * A convenience function for direct state access functions that throws
+ * GL_INVALID_OPERATION if buffer is not the name of a buffer object in the
+ * hash table.
+ */
+struct gl_buffer_object *
+_mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer,
+                           const char *func)
+{
+   struct gl_buffer_object *bufObj;
+
+   bufObj = _mesa_lookup_bufferobj(ctx, buffer);
+   if (!bufObj)
+      _mesa_error(ctx, GL_INVALID_OPERATION, "%s(non-generated buffer name)",
+                  func);
+
+   return bufObj;
+}
+
 
 void
 _mesa_begin_bufferobj_lookups(struct gl_context *ctx)
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index fe294fc..b4e1c10 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -89,6 +89,10 @@ _mesa_lookup_bufferobj(struct gl_context *ctx, GLuint buffer);
 extern struct gl_buffer_object *
 _mesa_lookup_bufferobj_locked(struct gl_context *ctx, GLuint buffer);
 
+extern struct gl_buffer_object *
+_mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer,
+                           const char *func);
+
 extern void
 _mesa_begin_bufferobj_lookups(struct gl_context *ctx);
 
-- 
2.1.0



More information about the mesa-dev mailing list