ctx->UniformBufferBindings = NULL;
}
+static void
+handle_bind_buffer_gen(struct gl_context *ctx,
+ GLenum target,
+ GLuint buffer,
+ struct gl_buffer_object **buf_handle)
+{
+ struct gl_buffer_object *buf = *buf_handle;
+
+ 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.
+ */
+ ASSERT(ctx->Driver.NewBufferObject);
+ buf = ctx->Driver.NewBufferObject(ctx, buffer, target);
+ if (!buf) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindBufferARB");
+ return;
+ }
+ _mesa_HashInsert(ctx->Shared->BufferObjects, buffer, buf);
+ *buf_handle = buf;
+ }
+}
/**
* Bind the specified target to buffer for the specified context.
else {
/* non-default buffer object */
newBufObj = _mesa_lookup_bufferobj(ctx, buffer);
- if (!newBufObj || newBufObj == &DummyBufferObject) {
- /* If this is a new buffer object id, or one which was generated but
- * never used before, allocate a buffer object now.
- */
- ASSERT(ctx->Driver.NewBufferObject);
- newBufObj = ctx->Driver.NewBufferObject(ctx, buffer, target);
- if (!newBufObj) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindBufferARB");
- return;
- }
- _mesa_HashInsert(ctx->Shared->BufferObjects, buffer, newBufObj);
- }
+ 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 (!bufObj) {
_mesa_error(ctx, GL_INVALID_OPERATION,
} else {
bufObj = _mesa_lookup_bufferobj(ctx, buffer);
}
+ handle_bind_buffer_gen(ctx, target, buffer, &bufObj);
if (!bufObj) {
_mesa_error(ctx, GL_INVALID_OPERATION,