mesa: Implement and use FlushMappedBufferRange.
authorJosé Fonseca <jfonseca@vmware.com>
Wed, 4 Mar 2009 11:59:00 +0000 (11:59 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Wed, 4 Mar 2009 11:59:00 +0000 (11:59 +0000)
src/mesa/state_tracker/st_cb_bufferobjects.c
src/mesa/vbo/vbo_exec_draw.c

index 526fc9587344f3fb5d5f5e1e1000d85146f0ae4b..2765ec24b7af685bc3c9441a231b912f77cc16f9 100644 (file)
@@ -233,14 +233,24 @@ st_bufferobj_map_range(GLcontext *ctx, GLenum target,
       flags |= PIPE_BUFFER_USAGE_DONTBLOCK;
 
    map = pipe_buffer_map_range(pipe->screen, st_obj->buffer, offset, length, flags);
-   /* FIXME: some code expects this to point to the buffer start, which means that
-    * the range might not be respected in all circumstances
+   /* this is expected to point to the buffer start, in order to calculate the
+    * vertices offsets 
     */
    obj->Pointer = map ? map - offset : NULL;
    return map;
 }
 
 
+static void
+st_bufferobj_flush_mapped_range(GLcontext *ctx, GLenum target, 
+                                GLintptr offset, GLsizeiptr length,
+                                struct gl_buffer_object *obj)
+{
+   struct pipe_context *pipe = st_context(ctx)->pipe;
+   struct st_buffer_object *st_obj = st_buffer_object(obj);
+
+   pipe_buffer_flush_mapped_range(pipe->screen, st_obj->buffer, offset, length);
+}
 
 
 /**
@@ -268,5 +278,6 @@ st_init_bufferobject_functions(struct dd_function_table *functions)
    functions->GetBufferSubData = st_bufferobj_get_subdata;
    functions->MapBuffer = st_bufferobj_map;
    functions->MapBufferRange = st_bufferobj_map_range;
+   functions->FlushMappedBufferRange = st_bufferobj_flush_mapped_range;
    functions->UnmapBuffer = st_bufferobj_unmap;
 }
index b08909c76fb7d412628bd470f37be7631ebd992b..c85e142a5a7e026871eccfb238ff033bf9e0f2b3 100644 (file)
@@ -240,6 +240,13 @@ static void vbo_exec_vtx_unmap( struct vbo_exec_context *exec )
 
    if (exec->vtx.bufferobj->Name) {
       GLcontext *ctx = exec->ctx;
+      GLintptr offset = exec->vtx.buffer_used;
+      GLsizeiptr length = (exec->vtx.buffer_ptr - exec->vtx.buffer_map) * sizeof(float);
+      
+      if(ctx->Driver.FlushMappedBufferRange)
+         ctx->Driver.FlushMappedBufferRange(ctx, target,
+                                            offset, length,
+                                            exec->vtx.bufferobj);
 
       exec->vtx.buffer_used += (exec->vtx.buffer_ptr -
                                 exec->vtx.buffer_map) * sizeof(float);