mesa: Set FLUSH_EXPLICIT_BIT flags when calling FlushMappedBufferRange.
authorJosé Fonseca <jfonseca@vmware.com>
Tue, 30 Jun 2009 14:09:34 +0000 (15:09 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Tue, 30 Jun 2009 14:33:53 +0000 (15:33 +0100)
As prescribed by ARB_map_buffer_range.

src/mesa/state_tracker/st_cb_bufferobjects.c
src/mesa/vbo/vbo_exec_draw.c

index 19a0e6736237b3f6fab4596442b549c0b2db4359..a627c0374adef78766c66d8a7bffbd5ec77b443d 100644 (file)
@@ -237,6 +237,9 @@ st_bufferobj_map_range(GLcontext *ctx, GLenum target,
    if (access & GL_MAP_READ_BIT)
       flags |= PIPE_BUFFER_USAGE_CPU_READ;
 
+   if (access & GL_MAP_FLUSH_EXPLICIT_BIT)
+      flags |= PIPE_BUFFER_USAGE_FLUSH_EXPLICIT;
+   
    /* ... other flags ...
     */
 
index da2d849ded70d4276baf84032a328657ea08e6d2..fdacb42e3571d9ffd395e992fff822602eea2de4 100644 (file)
@@ -268,9 +268,14 @@ static void vbo_exec_vtx_unmap( struct vbo_exec_context *exec )
 void vbo_exec_vtx_map( struct vbo_exec_context *exec )
 {
    GLcontext *ctx = exec->ctx;
-   GLenum target = GL_ARRAY_BUFFER_ARB;
-   GLenum access = GL_READ_WRITE_ARB;
-   GLenum usage = GL_STREAM_DRAW_ARB;
+   const GLenum target = GL_ARRAY_BUFFER_ARB;
+   const GLenum access = GL_READ_WRITE_ARB; /* for MapBuffer */
+   const GLenum accessRange = GL_MAP_WRITE_BIT |  /* for MapBufferRange */
+                              GL_MAP_INVALIDATE_RANGE_BIT |
+                              GL_MAP_UNSYNCHRONIZED_BIT |
+                              GL_MAP_FLUSH_EXPLICIT_BIT |
+                              MESA_MAP_NOWAIT_BIT;
+   const GLenum usage = GL_STREAM_DRAW_ARB;
    
    if (exec->vtx.bufferobj->Name == 0)
       return;
@@ -290,10 +295,7 @@ void vbo_exec_vtx_map( struct vbo_exec_context *exec )
                                                exec->vtx.buffer_used,
                                                (VBO_VERT_BUFFER_SIZE - 
                                                 exec->vtx.buffer_used),
-                                               (GL_MAP_WRITE_BIT |
-                                                GL_MAP_INVALIDATE_RANGE_BIT | 
-                                                GL_MAP_UNSYNCHRONIZED_BIT | 
-                                                MESA_MAP_NOWAIT_BIT),
+                                               accessRange,
                                                exec->vtx.bufferobj);
       exec->vtx.buffer_ptr = exec->vtx.buffer_map;
    }
@@ -305,8 +307,16 @@ void vbo_exec_vtx_map( struct vbo_exec_context *exec )
                              VBO_VERT_BUFFER_SIZE, 
                              NULL, usage, exec->vtx.bufferobj);
 
-      exec->vtx.buffer_map = 
-         (GLfloat *)ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj);
+
+      if (ctx->Driver.MapBufferRange)
+         exec->vtx.buffer_map = 
+            (GLfloat *)ctx->Driver.MapBufferRange(ctx, target,
+                                                  0, VBO_VERT_BUFFER_SIZE,
+                                                  accessRange,
+                                                  exec->vtx.bufferobj);
+      else
+         exec->vtx.buffer_map =
+            (GLfloat *)ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj);
       exec->vtx.buffer_ptr = exec->vtx.buffer_map;
    }