vbo: second attempt - avoid getting buffer_ptr and buffer_map out of sync
This commit is contained in:
parent
89f1f8f0b8
commit
368ca83a3f
|
@ -675,6 +675,7 @@ void vbo_use_buffer_objects(GLcontext *ctx)
|
||||||
if (exec->vtx.buffer_map) {
|
if (exec->vtx.buffer_map) {
|
||||||
_mesa_align_free(exec->vtx.buffer_map);
|
_mesa_align_free(exec->vtx.buffer_map);
|
||||||
exec->vtx.buffer_map = NULL;
|
exec->vtx.buffer_map = NULL;
|
||||||
|
exec->vtx.buffer_ptr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate a real buffer object now */
|
/* 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);
|
ASSERT(!exec->vtx.buffer_map);
|
||||||
exec->vtx.buffer_map = (GLfloat *)ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE, 64);
|
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 );
|
vbo_exec_vtxfmt_init( exec );
|
||||||
|
|
||||||
|
@ -735,6 +737,7 @@ void vbo_exec_vtx_destroy( struct vbo_exec_context *exec )
|
||||||
if (exec->vtx.buffer_map) {
|
if (exec->vtx.buffer_map) {
|
||||||
ALIGN_FREE(exec->vtx.buffer_map);
|
ALIGN_FREE(exec->vtx.buffer_map);
|
||||||
exec->vtx.buffer_map = NULL;
|
exec->vtx.buffer_map = NULL;
|
||||||
|
exec->vtx.buffer_ptr = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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_used += (exec->vtx.buffer_ptr -
|
||||||
exec->vtx.buffer_map) * sizeof(float);
|
exec->vtx.buffer_map) * sizeof(float);
|
||||||
|
|
||||||
|
assert(exec->vtx.buffer_used <= VBO_VERT_BUFFER_SIZE);
|
||||||
|
assert(exec->vtx.buffer_ptr != NULL);
|
||||||
|
|
||||||
ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj);
|
ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj);
|
||||||
exec->vtx.buffer_map = NULL;
|
exec->vtx.buffer_map = NULL;
|
||||||
exec->vtx.buffer_ptr = NULL;
|
exec->vtx.buffer_ptr = NULL;
|
||||||
|
@ -264,6 +267,7 @@ void vbo_exec_vtx_map( struct vbo_exec_context *exec )
|
||||||
if (exec->vtx.buffer_map != NULL) {
|
if (exec->vtx.buffer_map != NULL) {
|
||||||
assert(0);
|
assert(0);
|
||||||
exec->vtx.buffer_map = NULL;
|
exec->vtx.buffer_map = NULL;
|
||||||
|
exec->vtx.buffer_ptr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VBO_VERT_BUFFER_SIZE > exec->vtx.buffer_used + 1024 &&
|
if (VBO_VERT_BUFFER_SIZE > exec->vtx.buffer_used + 1024 &&
|
||||||
|
@ -280,6 +284,7 @@ void vbo_exec_vtx_map( struct vbo_exec_context *exec )
|
||||||
GL_MAP_UNSYNCHRONIZED_BIT |
|
GL_MAP_UNSYNCHRONIZED_BIT |
|
||||||
MESA_MAP_NOWAIT_BIT),
|
MESA_MAP_NOWAIT_BIT),
|
||||||
exec->vtx.bufferobj);
|
exec->vtx.bufferobj);
|
||||||
|
exec->vtx.buffer_ptr = exec->vtx.buffer_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exec->vtx.buffer_map) {
|
if (exec->vtx.buffer_map) {
|
||||||
|
@ -294,6 +299,7 @@ void vbo_exec_vtx_map( struct vbo_exec_context *exec )
|
||||||
|
|
||||||
exec->vtx.buffer_map =
|
exec->vtx.buffer_map =
|
||||||
(GLfloat *)ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj);
|
(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);
|
if (0) _mesa_printf("map %d..\n", exec->vtx.buffer_used);
|
||||||
|
|
Loading…
Reference in New Issue