diff options
author | Timothy Arceri <[email protected]> | 2017-04-04 15:40:06 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-04-06 08:25:36 +1000 |
commit | 8feb5bb40235abb39198025ea890934e04c21c1c (patch) | |
tree | 64ea71f422564e628538ab4906ec8e3ac201fc98 /src/mesa/main/bufferobj.c | |
parent | d1c1544a49e98431a7cab3d5fe89ac2ddbe4008d (diff) |
mesa: rework bind_buffer_object()
This allows internal users to pass buffer objects directly and
allows for KHR_no_error support to be more easily added.
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/mesa/main/bufferobj.c')
-rw-r--r-- | src/mesa/main/bufferobj.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 27eaf771a38..43dfebf63e6 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1013,18 +1013,13 @@ _mesa_handle_bind_buffer_gen(struct gl_context *ctx, * Called by glBindBuffer() and other functions. */ static void -bind_buffer_object(struct gl_context *ctx, GLenum target, GLuint buffer) +bind_buffer_object(struct gl_context *ctx, + struct gl_buffer_object **bindTarget, GLuint buffer) { struct gl_buffer_object *oldBufObj; struct gl_buffer_object *newBufObj = NULL; - struct gl_buffer_object **bindTarget = NULL; - bindTarget = get_buffer_target(ctx, target); - if (!bindTarget) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferARB(target %s)", - _mesa_enum_to_string(target)); - return; - } + assert(bindTarget); /* Get pointer to old buffer object (to be unbound) */ oldBufObj = *bindTarget; @@ -1049,12 +1044,8 @@ bind_buffer_object(struct gl_context *ctx, GLenum target, GLuint buffer) } /* record usage history */ - switch (target) { - case GL_PIXEL_PACK_BUFFER: + if (bindTarget == &ctx->Pack.BufferObj) { newBufObj->UsageHistory |= USAGE_PIXEL_PACK_BUFFER; - break; - default: - break; } /* bind new buffer */ @@ -1073,10 +1064,10 @@ _mesa_update_default_objects_buffer_objects(struct gl_context *ctx) /* Bind the NullBufferObj to remove references to those * in the shared context hash table. */ - bind_buffer_object( ctx, GL_ARRAY_BUFFER_ARB, 0); - bind_buffer_object( ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, 0); - bind_buffer_object( ctx, GL_PIXEL_PACK_BUFFER_ARB, 0); - bind_buffer_object( ctx, GL_PIXEL_UNPACK_BUFFER_ARB, 0); + bind_buffer_object(ctx, &ctx->Array.ArrayBufferObj, 0); + bind_buffer_object(ctx, &ctx->Array.VAO->IndexBufferObj, 0); + bind_buffer_object(ctx, &ctx->Pack.BufferObj, 0); + bind_buffer_object(ctx, &ctx->Unpack.BufferObj, 0); } @@ -1268,7 +1259,14 @@ _mesa_BindBuffer(GLenum target, GLuint buffer) _mesa_enum_to_string(target), buffer); } - bind_buffer_object(ctx, target, buffer); + struct gl_buffer_object **bindTarget = get_buffer_target(ctx, target); + if (!bindTarget) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferARB(target %s)", + _mesa_enum_to_string(target)); + return; + } + + bind_buffer_object(ctx, bindTarget, buffer); } |