summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/bufferobj.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2012-06-14 16:37:22 -0700
committerEric Anholt <[email protected]>2012-06-21 10:57:56 -0700
commit5527c2d22027e9e27e55372d8adf2ba4ff855b53 (patch)
tree4175b5a16c7ac2d37315503bb25ff99f326921b1 /src/mesa/main/bufferobj.c
parentc5c696e7fbce2e0b598ed5d4b1d73f086a664a57 (diff)
mesa: Add indexed binding points for uniform buffer objects.
Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/main/bufferobj.c')
-rw-r--r--src/mesa/main/bufferobj.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index b646baa41a1..3fc29086204 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -603,6 +603,8 @@ _mesa_copy_buffer_subdata(struct gl_context *ctx,
void
_mesa_init_buffer_objects( struct gl_context *ctx )
{
+ GLuint i;
+
memset(&DummyBufferObject, 0, sizeof(DummyBufferObject));
_glthread_INIT_MUTEX(DummyBufferObject.Mutex);
DummyBufferObject.RefCount = 1000*1000*1000; /* never delete */
@@ -614,16 +616,43 @@ _mesa_init_buffer_objects( struct gl_context *ctx )
ctx->Shared->NullBufferObj);
_mesa_reference_buffer_object(ctx, &ctx->CopyWriteBuffer,
ctx->Shared->NullBufferObj);
+
+ ctx->UniformBufferBindings = calloc(ctx->Const.MaxUniformBufferBindings,
+ sizeof(*ctx->UniformBufferBindings));
+
+ _mesa_reference_buffer_object(ctx, &ctx->UniformBuffer,
+ ctx->Shared->NullBufferObj);
+
+ for (i = 0; i < ctx->Const.MaxUniformBufferBindings; i++) {
+ _mesa_reference_buffer_object(ctx,
+ &ctx->UniformBufferBindings[i].BufferObject,
+ ctx->Shared->NullBufferObj);
+ ctx->UniformBufferBindings[i].Offset = -1;
+ ctx->UniformBufferBindings[i].Size = -1;
+ }
}
void
_mesa_free_buffer_objects( struct gl_context *ctx )
{
+ GLuint i;
+
_mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj, NULL);
_mesa_reference_buffer_object(ctx, &ctx->CopyReadBuffer, NULL);
_mesa_reference_buffer_object(ctx, &ctx->CopyWriteBuffer, NULL);
+
+ _mesa_reference_buffer_object(ctx, &ctx->UniformBuffer, NULL);
+
+ for (i = 0; i < ctx->Const.MaxUniformBufferBindings; i++) {
+ _mesa_reference_buffer_object(ctx,
+ &ctx->UniformBufferBindings[i].BufferObject,
+ NULL);
+ }
+
+ free(ctx->UniformBufferBindings);
+ ctx->UniformBufferBindings = NULL;
}