summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2009-06-08 16:11:29 +0100
committerKeith Whitwell <[email protected]>2009-06-08 16:27:43 +0100
commit0d3c8fbf12289a8cc081c2d68e810c4bf29d1f8d (patch)
tree85dd404787171b3d98ca3eab80a8f947252000ec
parentfce4ee12a620de4ece35cef62a4562bbd4895557 (diff)
mesa/vbo: drop all references to vbo on destroy
We were adding references to the input arrays, but failing to drop them on destruction. This could lead to a 64kb buffer being leaked each context destruction.
-rw-r--r--src/mesa/vbo/vbo_exec_api.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 5d35ec9c111..a8a09859a03 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -727,19 +727,32 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec )
void vbo_exec_vtx_destroy( struct vbo_exec_context *exec )
{
- if (exec->vtx.bufferobj->Name) {
- /* using a real VBO for vertex data */
- GLcontext *ctx = exec->ctx;
- _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL);
- }
- else {
- /* just using malloc'd space for vertex data */
- if (exec->vtx.buffer_map) {
+ /* using a real VBO for vertex data */
+ GLcontext *ctx = exec->ctx;
+ unsigned i;
+
+ /* True VBOs should already be unmapped
+ */
+ if (exec->vtx.buffer_map) {
+ assert (exec->vtx.bufferobj->Name == 0);
+ if (exec->vtx.bufferobj->Name == 0) {
ALIGN_FREE(exec->vtx.buffer_map);
exec->vtx.buffer_map = NULL;
exec->vtx.buffer_ptr = NULL;
}
}
+
+ /* Drop any outstanding reference to the vertex buffer
+ */
+ for (i = 0; i < Elements(exec->vtx.arrays); i++) {
+ _mesa_reference_buffer_object(ctx,
+ &exec->vtx.arrays[i].BufferObj,
+ NULL);
+ }
+
+ /* Free the vertex buffer:
+ */
+ _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL);
}
void vbo_exec_BeginVertices( GLcontext *ctx )