[Mesa-dev] [PATCH 04/11] mesa: Make handle_bind_buffer_gen() non-static

Fredrik Höglund fredrik at kde.org
Tue Nov 5 14:50:50 PST 2013


...and rename it to _mesa_bind_buffer_gen().

This is so the function can be called from _mesa_BindVertexBuffer().

This patch also adds a caller parameter so we can report the right
entry point in error messages.

Based on a patch by Eric Anholt.

Reviewed-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/mesa/main/bufferobj.c |   24 ++++++++++++++----------
 src/mesa/main/bufferobj.h |    9 ++++++++-
 2 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 54bba1a..15ec40c 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -655,16 +655,17 @@ _mesa_free_buffer_objects( struct gl_context *ctx )
    }
 }
 
-static bool
-handle_bind_buffer_gen(struct gl_context *ctx,
-		       GLenum target,
-		       GLuint buffer,
-		       struct gl_buffer_object **buf_handle)
+bool
+_mesa_handle_bind_buffer_gen(struct gl_context *ctx,
+                             GLenum target,
+                             GLuint buffer,
+                             struct gl_buffer_object **buf_handle,
+                             const char *caller)
 {
    struct gl_buffer_object *buf = *buf_handle;
 
    if (!buf && ctx->API == API_OPENGL_CORE) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glBindBuffer(non-gen name)");
+      _mesa_error(ctx, GL_INVALID_OPERATION, "%s(non-gen name)", caller);
       return false;
    }
 
@@ -675,7 +676,7 @@ handle_bind_buffer_gen(struct gl_context *ctx,
       ASSERT(ctx->Driver.NewBufferObject);
       buf = ctx->Driver.NewBufferObject(ctx, buffer, target);
       if (!buf) {
-	 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindBufferARB");
+	 _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", caller);
 	 return false;
       }
       _mesa_HashInsert(ctx->Shared->BufferObjects, buffer, buf);
@@ -719,7 +720,8 @@ bind_buffer_object(struct gl_context *ctx, GLenum target, GLuint buffer)
    else {
       /* non-default buffer object */
       newBufObj = _mesa_lookup_bufferobj(ctx, buffer);
-      if (!handle_bind_buffer_gen(ctx, target, buffer, &newBufObj))
+      if (!_mesa_handle_bind_buffer_gen(ctx, target, buffer,
+                                        &newBufObj, "glBindBuffer"))
          return;
    }
    
@@ -2181,7 +2183,8 @@ _mesa_BindBufferRange(GLenum target, GLuint index,
    } else {
       bufObj = _mesa_lookup_bufferobj(ctx, buffer);
    }
-   if (!handle_bind_buffer_gen(ctx, target, buffer, &bufObj))
+   if (!_mesa_handle_bind_buffer_gen(ctx, target, buffer,
+                                     &bufObj, "glBindBufferRange"))
       return;
 
    if (!bufObj) {
@@ -2227,7 +2230,8 @@ _mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer)
    } else {
       bufObj = _mesa_lookup_bufferobj(ctx, buffer);
    }
-   if (!handle_bind_buffer_gen(ctx, target, buffer, &bufObj))
+   if (!_mesa_handle_bind_buffer_gen(ctx, target, buffer,
+                                     &bufObj, "glBindBufferBase"))
       return;
 
    if (!bufObj) {
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index 9b582f8c..0b898a2 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -28,7 +28,7 @@
 #ifndef BUFFEROBJ_H
 #define BUFFEROBJ_H
 
-
+#include <stdbool.h>
 #include "mtypes.h"
 
 
@@ -62,6 +62,13 @@ _mesa_init_buffer_objects( struct gl_context *ctx );
 extern void
 _mesa_free_buffer_objects( struct gl_context *ctx );
 
+extern bool
+_mesa_handle_bind_buffer_gen(struct gl_context *ctx,
+                             GLenum target,
+                             GLuint buffer,
+                             struct gl_buffer_object **buf_handle,
+                             const char *caller);
+
 extern void
 _mesa_update_default_objects_buffer_objects(struct gl_context *ctx);
 
-- 
1.7.10.4



More information about the mesa-dev mailing list