summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorFredrik Höglund <[email protected]>2013-11-15 19:45:43 +0100
committerFredrik Höglund <[email protected]>2014-05-02 02:53:26 +0200
commit19f7eeb6fb7a690c6c2fd43259813070a1e5ee2d (patch)
tree39ee4cdf570a1a4666b75e608c00b9916c1cad5a /src/mesa/main
parent4f30c0ba806a14f5892e28988f86be9ca7745ffb (diff)
mesa: Refactor set_atomic_buffer_binding()
Make set_atomic_buffer_binding() just update the binding, and move the code that does validation, flushes the vertices etc. into a new bind_atomic_buffer() function. Reviewed-by: Francisco Jerez <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/bufferobj.c56
1 files changed, 40 insertions, 16 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 65fa740a438..4d53e5c793e 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -2613,13 +2613,45 @@ bind_buffer_base_uniform_buffer(struct gl_context *ctx,
set_ubo_binding(ctx, index, bufObj, 0, 0, GL_TRUE);
}
+/**
+ * Binds a buffer object to an atomic buffer binding point.
+ *
+ * The caller is responsible for validating the offset,
+ * flushing the vertices and updating NewDriverState.
+ */
static void
set_atomic_buffer_binding(struct gl_context *ctx,
- unsigned index,
+ struct gl_atomic_buffer_binding *binding,
struct gl_buffer_object *bufObj,
GLintptr offset,
- GLsizeiptr size,
- const char *name)
+ GLsizeiptr size)
+{
+ _mesa_reference_buffer_object(ctx, &binding->BufferObject, bufObj);
+
+ if (bufObj == ctx->Shared->NullBufferObj) {
+ binding->Offset = -1;
+ binding->Size = -1;
+ } else {
+ binding->Offset = offset;
+ binding->Size = size;
+ }
+}
+
+/**
+ * Binds a buffer object to an atomic buffer binding point.
+ *
+ * Unlike set_atomic_buffer_binding(), this function also validates the
+ * index and offset, flushes vertices, and updates NewDriverState.
+ * It also checks if the binding has actually changing before
+ * updating it.
+ */
+static void
+bind_atomic_buffer(struct gl_context *ctx,
+ unsigned index,
+ struct gl_buffer_object *bufObj,
+ GLintptr offset,
+ GLsizeiptr size,
+ const char *name)
{
struct gl_atomic_buffer_binding *binding;
@@ -2647,15 +2679,7 @@ set_atomic_buffer_binding(struct gl_context *ctx,
FLUSH_VERTICES(ctx, 0);
ctx->NewDriverState |= ctx->DriverFlags.NewAtomicBuffer;
- _mesa_reference_buffer_object(ctx, &binding->BufferObject, bufObj);
-
- if (bufObj == ctx->Shared->NullBufferObj) {
- binding->Offset = -1;
- binding->Size = -1;
- } else {
- binding->Offset = offset;
- binding->Size = size;
- }
+ set_atomic_buffer_binding(ctx, binding, bufObj, offset, size);
}
void GLAPIENTRY
@@ -2697,8 +2721,8 @@ _mesa_BindBufferRange(GLenum target, GLuint index,
bind_buffer_range_uniform_buffer(ctx, index, bufObj, offset, size);
return;
case GL_ATOMIC_COUNTER_BUFFER:
- set_atomic_buffer_binding(ctx, index, bufObj, offset, size,
- "glBindBufferRange");
+ bind_atomic_buffer(ctx, index, bufObj, offset, size,
+ "glBindBufferRange");
return;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferRange(target)");
@@ -2761,8 +2785,8 @@ _mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer)
bind_buffer_base_uniform_buffer(ctx, index, bufObj);
return;
case GL_ATOMIC_COUNTER_BUFFER:
- set_atomic_buffer_binding(ctx, index, bufObj, 0, 0,
- "glBindBufferBase");
+ bind_atomic_buffer(ctx, index, bufObj, 0, 0,
+ "glBindBufferBase");
return;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferBase(target)");