ctx->UniformBufferBindings = NULL;
}
-static void
+static bool
handle_bind_buffer_gen(struct gl_context *ctx,
GLenum target,
GLuint buffer,
{
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.
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;
}
/**
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 */
} 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,
} 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,