From 6222eb3fcd12147ea2e7ccc20a71a921cebbb0d2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 25 Sep 2008 11:03:46 -0600 Subject: mesa: fix some VBO buffer object issues The VBO module may use a real VBO or a malloc'd buffer for vertex storage. Be careful not to accidentally replace the later with the former when drawing. Check if using a real VBO at destroy time to prevent a double-free. --- src/mesa/vbo/vbo_exec_draw.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_draw.c') diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index f497e9a5a5..92356ba977 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -242,8 +242,11 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec ) */ vbo_exec_bind_arrays( ctx ); - ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj); - exec->vtx.buffer_map = NULL; + /* if using a real VBO, unmap it before drawing */ + if (exec->vtx.bufferobj->Name) { + ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj); + exec->vtx.buffer_map = NULL; + } vbo_context(ctx)->draw_prims( ctx, exec->vtx.inputs, @@ -253,11 +256,12 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec ) 0, exec->vtx.vert_count - 1); - /* Get new data: - */ - ctx->Driver.BufferData(ctx, target, size, NULL, usage, exec->vtx.bufferobj); - exec->vtx.buffer_map - = ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj); + /* If using a real VBO, get new storage */ + if (exec->vtx.bufferobj->Name) { + ctx->Driver.BufferData(ctx, target, size, NULL, usage, exec->vtx.bufferobj); + exec->vtx.buffer_map = + ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj); + } } } -- cgit v1.2.3