diff options
author | Eric Anholt <[email protected]> | 2012-10-31 15:33:41 -0700 |
---|---|---|
committer | Andreas Boll <[email protected]> | 2013-01-20 15:08:27 +0100 |
commit | e6174a9fd91071841d432a6e63523840b97e4e0e (patch) | |
tree | a9ff74c4a37c66686caee4bd66c074fcd67c7cc6 /src | |
parent | 9e1050d72fb78b56b03304727abb122713a90ed1 (diff) |
mesa: Fix the core GL genned-name handling for glBindBufferBase()/Range().
This is part of fixing gl-3.1/genned-names.
v2: Fix a missing return value.
NOTE: This is a candidate for the 9.0 branch.
Reviewed-by: Kenneth Graunke <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
(cherry picked from commit 947d8ff4a7c4b7ffb4013056b48dbabe6b3931b0)
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/bufferobj.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index b4104ec0e8a..0e03b70f2e8 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -663,7 +663,7 @@ _mesa_free_buffer_objects( struct gl_context *ctx ) ctx->UniformBufferBindings = NULL; } -static void +static bool handle_bind_buffer_gen(struct gl_context *ctx, GLenum target, GLuint buffer, @@ -671,6 +671,11 @@ handle_bind_buffer_gen(struct gl_context *ctx, { struct gl_buffer_object *buf = *buf_handle; + if (!buf && ctx->API == API_OPENGL_CORE) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glBindBuffer(non-gen name)"); + return false; + } + if (!buf || buf == &DummyBufferObject) { /* If this is a new buffer object id, or one which was generated but * never used before, allocate a buffer object now. @@ -679,11 +684,13 @@ handle_bind_buffer_gen(struct gl_context *ctx, buf = ctx->Driver.NewBufferObject(ctx, buffer, target); if (!buf) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindBufferARB"); - return; + return false; } _mesa_HashInsert(ctx->Shared->BufferObjects, buffer, buf); *buf_handle = buf; } + + return true; } /** @@ -720,11 +727,8 @@ bind_buffer_object(struct gl_context *ctx, GLenum target, GLuint buffer) else { /* non-default buffer object */ newBufObj = _mesa_lookup_bufferobj(ctx, buffer); - if (newBufObj == NULL && ctx->API == API_OPENGL_CORE) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glBindBuffer(non-gen name)"); + if (!handle_bind_buffer_gen(ctx, target, buffer, &newBufObj)) return; - } - handle_bind_buffer_gen(ctx, target, buffer, &newBufObj); } /* bind new buffer */ @@ -2143,7 +2147,8 @@ _mesa_BindBufferRange(GLenum target, GLuint index, } else { bufObj = _mesa_lookup_bufferobj(ctx, buffer); } - handle_bind_buffer_gen(ctx, target, buffer, &bufObj); + if (!handle_bind_buffer_gen(ctx, target, buffer, &bufObj)) + return; if (!bufObj) { _mesa_error(ctx, GL_INVALID_OPERATION, @@ -2189,7 +2194,8 @@ _mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer) } else { bufObj = _mesa_lookup_bufferobj(ctx, buffer); } - handle_bind_buffer_gen(ctx, target, buffer, &bufObj); + if (!handle_bind_buffer_gen(ctx, target, buffer, &bufObj)) + return; if (!bufObj) { _mesa_error(ctx, GL_INVALID_OPERATION, |