From f338de4018f2cfcb462f98c7d76bf6cc36ab6f47 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 22 Sep 2009 13:47:49 -0600 Subject: mesa: fix more buffer object error messages --- src/mesa/main/bufferobj.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/mesa/main/bufferobj.c') diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index b95e00af5b..189b5e1655 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1173,7 +1173,7 @@ _mesa_BufferDataARB(GLenum target, GLsizeiptrARB size, ASSERT(ctx->Driver.BufferData); if (!ctx->Driver.BufferData( ctx, target, size, data, usage, bufObj )) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBufferDataARB(access)"); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBufferDataARB()"); } } @@ -1262,7 +1262,7 @@ _mesa_MapBufferARB(GLenum target, GLenum access) ASSERT(ctx->Driver.MapBuffer); map = ctx->Driver.MapBuffer( ctx, target, access, bufObj ); if (!map) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(access)"); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(map failed)"); return NULL; } else { @@ -1593,7 +1593,7 @@ _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, map = ctx->Driver.MapBufferRange(ctx, target, offset, length, access, bufObj); if (!map) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(access)"); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(map failed)"); } else { /* The driver callback should have set all these fields. -- cgit v1.2.3 From dd5691e8020df30c47e6d0e43a68b4f301ea4ea9 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 Oct 2009 20:10:30 -0600 Subject: mesa: code refactoring to eliminate a switch stmt in bind_buffer_object() --- src/mesa/main/bufferobj.c | 111 +++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 66 deletions(-) (limited to 'src/mesa/main/bufferobj.c') diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 189b5e1655..52c4995b0a 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -52,51 +52,55 @@ /** - * Get the buffer object bound to the specified target in a GL context. - * - * \param ctx GL context - * \param target Buffer object target to be retrieved. Currently this must - * be either \c GL_ARRAY_BUFFER or \c GL_ELEMENT_ARRAY_BUFFER. - * \return A pointer to the buffer object bound to \c target in the + * Return pointer to address of a buffer object target. + * \param ctx the GL context + * \param target the buffer object target to be retrieved. + * \return pointer to pointer to the buffer object bound to \c target in the * specified context or \c NULL if \c target is invalid. */ -static INLINE struct gl_buffer_object * -get_buffer(GLcontext *ctx, GLenum target) +static INLINE struct gl_buffer_object ** +get_buffer_target(GLcontext *ctx, GLenum target) { - struct gl_buffer_object * bufObj = NULL; - switch (target) { - case GL_ARRAY_BUFFER_ARB: - bufObj = ctx->Array.ArrayBufferObj; - break; - case GL_ELEMENT_ARRAY_BUFFER_ARB: - bufObj = ctx->Array.ElementArrayBufferObj; - break; - case GL_PIXEL_PACK_BUFFER_EXT: - bufObj = ctx->Pack.BufferObj; - break; - case GL_PIXEL_UNPACK_BUFFER_EXT: - bufObj = ctx->Unpack.BufferObj; - break; - case GL_COPY_READ_BUFFER: - if (ctx->Extensions.ARB_copy_buffer) { - bufObj = ctx->CopyReadBuffer; - } - break; - case GL_COPY_WRITE_BUFFER: - if (ctx->Extensions.ARB_copy_buffer) { - bufObj = ctx->CopyWriteBuffer; - } - break; - default: - /* error must be recorded by caller */ - return NULL; + case GL_ARRAY_BUFFER_ARB: + return &ctx->Array.ArrayBufferObj; + case GL_ELEMENT_ARRAY_BUFFER_ARB: + return &ctx->Array.ElementArrayBufferObj; + case GL_PIXEL_PACK_BUFFER_EXT: + return &ctx->Pack.BufferObj; + case GL_PIXEL_UNPACK_BUFFER_EXT: + return &ctx->Unpack.BufferObj; + case GL_COPY_READ_BUFFER: + if (ctx->Extensions.ARB_copy_buffer) { + return &ctx->CopyReadBuffer; + } + break; + case GL_COPY_WRITE_BUFFER: + if (ctx->Extensions.ARB_copy_buffer) { + return &ctx->CopyWriteBuffer; + } + break; + default: + return NULL; } + return NULL; +} - /* bufObj should point to NullBufferObj or a user-created buffer object */ - ASSERT(bufObj); - return bufObj; +/** + * Get the buffer object bound to the specified target in a GL context. + * \param ctx the GL context + * \param target the buffer object target to be retrieved. + * \return pointer to the buffer object bound to \c target in the + * specified context or \c NULL if \c target is invalid. + */ +static INLINE struct gl_buffer_object * +get_buffer(GLcontext *ctx, GLenum target) +{ + struct gl_buffer_object **bufObj = get_buffer_target(ctx, target); + if (bufObj) + return *bufObj; + return NULL; } @@ -552,6 +556,7 @@ _mesa_init_buffer_objects( GLcontext *ctx ) /** * Bind the specified target to buffer for the specified context. + * Called by glBindBuffer() and other functions. */ static void bind_buffer_object(GLcontext *ctx, GLenum target, GLuint buffer) @@ -560,40 +565,14 @@ bind_buffer_object(GLcontext *ctx, GLenum target, GLuint buffer) struct gl_buffer_object *newBufObj = NULL; struct gl_buffer_object **bindTarget = NULL; - switch (target) { - case GL_ARRAY_BUFFER_ARB: - bindTarget = &ctx->Array.ArrayBufferObj; - break; - case GL_ELEMENT_ARRAY_BUFFER_ARB: - bindTarget = &ctx->Array.ElementArrayBufferObj; - break; - case GL_PIXEL_PACK_BUFFER_EXT: - bindTarget = &ctx->Pack.BufferObj; - break; - case GL_PIXEL_UNPACK_BUFFER_EXT: - bindTarget = &ctx->Unpack.BufferObj; - break; - case GL_COPY_READ_BUFFER: - if (ctx->Extensions.ARB_copy_buffer) { - bindTarget = &ctx->CopyReadBuffer; - } - break; - case GL_COPY_WRITE_BUFFER: - if (ctx->Extensions.ARB_copy_buffer) { - bindTarget = &ctx->CopyWriteBuffer; - } - break; - default: - ; /* no-op / we'll hit the follow error test next */ - } - + bindTarget = get_buffer_target(ctx, target); if (!bindTarget) { _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferARB(target 0x%x)"); return; } /* Get pointer to old buffer object (to be unbound) */ - oldBufObj = get_buffer(ctx, target); + oldBufObj = *bindTarget; if (oldBufObj && oldBufObj->Name == buffer) return; /* rebinding the same buffer object- no change */ -- cgit v1.2.3