Module: Mesa
Branch: gallium-map-range
Commit: 579ef8ab1984d895867f547afa60b3bec4c4599a
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=579ef8ab1984d895867f547afa60b3bec4c4599a

Author: Keith Whitwell <[email protected]>
Date:   Wed Mar  4 16:06:05 2009 +0000

vbo: avoid getting buffer_ptr and buffer_map out of sync

---

 src/mesa/vbo/vbo_exec_api.c  |    3 +++
 src/mesa/vbo/vbo_exec_draw.c |    6 +++++-
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 9c2d065..a1e66ae 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -675,6 +675,7 @@ void vbo_use_buffer_objects(GLcontext *ctx)
    if (exec->vtx.buffer_map) {
       _mesa_align_free(exec->vtx.buffer_map);
       exec->vtx.buffer_map = NULL;
+      exec->vtx.buffer_ptr = NULL;
    }
 
    /* Allocate a real buffer object now */
@@ -700,6 +701,7 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec )
 
    ASSERT(!exec->vtx.buffer_map);
    exec->vtx.buffer_map = (GLfloat *)ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE, 64);
+   exec->vtx.buffer_ptr = exec->vtx.buffer_map;
 
    vbo_exec_vtxfmt_init( exec );
 
@@ -735,6 +737,7 @@ 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;
+         exec->vtx.buffer_ptr = NULL;
       }
    }
 }
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index 38b6c56..4b44b30 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -243,7 +243,10 @@ static void vbo_exec_vtx_unmap( struct vbo_exec_context 
*exec )
 
       exec->vtx.buffer_used += (exec->vtx.buffer_ptr -
                                 exec->vtx.buffer_map) * sizeof(float);
-            
+
+       
+      assert(exec->vtx.buffer_ptr != NULL);
+      
       ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj);
       exec->vtx.buffer_map = NULL;
       exec->vtx.buffer_ptr = NULL;
@@ -296,6 +299,7 @@ void vbo_exec_vtx_map( struct vbo_exec_context *exec )
          (GLfloat *)ctx->Driver.MapBuffer(ctx, target, access, 
exec->vtx.bufferobj);
    }
 
+   exec->vtx.buffer_ptr = exec->vtx.buffer_map;
    if (0) _mesa_printf("map %d..\n", exec->vtx.buffer_used);
 }
 

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to