From 01d7e3d5a25a7cc49b38f5561d00c2ff22c43e93 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 9 Feb 2010 14:25:41 +0100 Subject: mesa: Enable true refcounting for NullBufferObj. This object can be shared with another context, so we cannot just delete it when the owning context is being destroyed. Ensuring that buffer objects are properly refcounted guarantees NullBufferObj is destroyed when all references to it are removed. --- src/mesa/vbo/vbo_exec_api.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index f0a7eeadd0..8ee14be261 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -759,6 +759,7 @@ void vbo_use_buffer_objects(GLcontext *ctx) } /* Allocate a real buffer object now */ + _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL); exec->vtx.bufferobj = ctx->Driver.NewBufferObject(ctx, bufName, target); ctx->Driver.BufferData(ctx, target, size, NULL, usage, exec->vtx.bufferobj); } @@ -803,8 +804,19 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) { struct gl_client_array *arrays = exec->vtx.arrays; + unsigned i; + memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0])); memcpy(arrays + 16, vbo->generic_currval, 16 * sizeof(arrays[0])); + + for (i = 0; i < 16; ++i) { + arrays[i ].BufferObj = NULL; + arrays[i + 16].BufferObj = NULL; + _mesa_reference_buffer_object(ctx, &arrays[i ].BufferObj, + vbo->legacy_currval[i].BufferObj); + _mesa_reference_buffer_object(ctx, &arrays[i + 16].BufferObj, + vbo->generic_currval[i].BufferObj); + } } exec->vtx.vertex_size = 0; -- cgit v1.2.3