vbo: unmap and remap immediate vbo before/after each draw.
authorKeith Whitwell <keith@tungstengraphics.com>
Tue, 18 Dec 2007 16:56:22 +0000 (16:56 +0000)
committerKeith Whitwell <keith@tungstengraphics.com>
Tue, 18 Dec 2007 16:56:22 +0000 (16:56 +0000)
Also use BufferData(NULL) to get fresh storage and avoid synchronous
operation where we would have to flush and wait for the fence after each
draw because of the map.

This will chew through a whole load of buffer space on small draws, so
it isn't a proper solution.  Need to support a no-fence or append mapping
mode to do this right, or use user buffers.

src/mesa/vbo/vbo_exec_draw.c

index 68aba1d..23a3658 100644 (file)
@@ -221,8 +221,18 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec )
       if (exec->vtx.copied.nr != exec->vtx.vert_count) {
         GLcontext *ctx = exec->ctx;
 
+        GLenum target = GL_ARRAY_BUFFER_ARB;
+        GLenum access = GL_READ_WRITE_ARB;
+        GLenum usage = GL_STREAM_DRAW_ARB;
+        GLsizei size = VBO_VERT_BUFFER_SIZE * sizeof(GLfloat);
+        
+        /* Before the unmap (why?)
+         */
         vbo_exec_bind_arrays( ctx );
 
+        ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj);
+        exec->vtx.buffer_map = NULL;
+
         vbo_context(ctx)->draw_prims( ctx, 
                                       exec->vtx.inputs, 
                                       exec->vtx.prim, 
@@ -230,6 +240,12 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec )
                                       NULL,
                                       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);
       }
    }