st/mesa: Make use of the new PIPE_TRANSFER_DISCARD_* for buffer object.
authorMathias Fröhlich <Mathias.Froehlich@web.de>
Sat, 26 Feb 2011 07:20:34 +0000 (08:20 +0100)
committerMarek Olšák <maraeo@gmail.com>
Tue, 15 Mar 2011 14:39:31 +0000 (15:39 +0100)
In memory mapping buffer objects make use of
PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE and PIPE_TRANSFER_DISCARD_RANGE
when appropriate.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
src/mesa/state_tracker/st_cb_bufferobjects.c

index 12528f49ff7ea8c13cf0c16cec14eb147ae67af0..b9b606d539c4a39d384ff08b41b7967ebc2b4632 100644 (file)
@@ -301,11 +301,15 @@ st_bufferobj_map_range(struct gl_context *ctx, GLenum target,
    if (access & GL_MAP_FLUSH_EXPLICIT_BIT)
       flags |= PIPE_TRANSFER_FLUSH_EXPLICIT;
 
-   if (access & GL_MAP_INVALIDATE_RANGE_BIT)
-      flags |= PIPE_TRANSFER_DISCARD;
-
-   if (access & GL_MAP_INVALIDATE_BUFFER_BIT)
-      flags |= PIPE_TRANSFER_DISCARD;
+   if (access & GL_MAP_INVALIDATE_BUFFER_BIT) {
+      flags |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
+   }
+   else if (access & GL_MAP_INVALIDATE_RANGE_BIT) {
+      if (offset == 0 && length == obj->Size)
+         flags |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
+      else
+         flags |= PIPE_TRANSFER_DISCARD_RANGE;
+   }
    
    if (access & GL_MAP_UNSYNCHRONIZED_BIT)
       flags |= PIPE_TRANSFER_UNSYNCHRONIZED;