summaryrefslogtreecommitdiffstats
path: root/src/mesa/vbo/vbo_exec_api.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2008-09-25 11:03:46 -0600
committerBrian Paul <[email protected]>2008-09-25 11:03:46 -0600
commit6222eb3fcd12147ea2e7ccc20a71a921cebbb0d2 (patch)
tree2eeb08f6228a0d81f75aa7a79aca43046536b9de /src/mesa/vbo/vbo_exec_api.c
parent507ef82077891a7b833c1c3e82c61299cf281ee8 (diff)
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.
Diffstat (limited to 'src/mesa/vbo/vbo_exec_api.c')
-rw-r--r--src/mesa/vbo/vbo_exec_api.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 5513ef94491..d48f5230cb9 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -699,8 +699,8 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec )
&exec->vtx.bufferobj,
ctx->Array.NullBufferObj);
+ ASSERT(!exec->vtx.buffer_map);
exec->vtx.buffer_map = ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE * sizeof(GLfloat), 64);
-
vbo_exec_vtxfmt_init( exec );
/* Hook our functions into the dispatch table.
@@ -725,9 +725,17 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec )
void vbo_exec_vtx_destroy( struct vbo_exec_context *exec )
{
- if (exec->vtx.buffer_map) {
- ALIGN_FREE(exec->vtx.buffer_map);
- exec->vtx.buffer_map = NULL;
+ 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) {
+ ALIGN_FREE(exec->vtx.buffer_map);
+ exec->vtx.buffer_map = NULL;
+ }
}
}