u_upload_mgr: Use PIPE_TRANSFER_FLUSH_EXPLICIT.
authorJosé Fonseca <jfonseca@vmware.com>
Thu, 10 Feb 2011 20:53:55 +0000 (20:53 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Thu, 10 Feb 2011 20:55:10 +0000 (20:55 +0000)
This can avoid DMAing the whole buffer when just a fraction was changed.

src/gallium/auxiliary/util/u_upload_mgr.c

index 865dab864b39dac6bee238d848e5594d8a93c83e..69b11f9bb774b4113fad034c3cfff37300f2efb7 100644 (file)
@@ -85,6 +85,10 @@ void u_upload_flush( struct u_upload_mgr *upload )
 {
    /* Unmap and unreference the upload buffer. */
    if (upload->transfer) {
+      if (upload->size) {
+         pipe_buffer_flush_mapped_range(upload->pipe, upload->transfer,
+                                        0, upload->size);
+      }
       pipe_transfer_unmap(upload->pipe, upload->transfer);
       pipe_transfer_destroy(upload->pipe, upload->transfer);
       upload->transfer = NULL;
@@ -122,8 +126,11 @@ u_upload_alloc_buffer( struct u_upload_mgr *upload,
       goto fail;
 
    /* Map the new buffer. */
-   upload->map = pipe_buffer_map(upload->pipe, upload->buffer,
-                                 PIPE_TRANSFER_WRITE, &upload->transfer);
+   upload->map = pipe_buffer_map_range(upload->pipe, upload->buffer,
+                                       0, size,
+                                       PIPE_TRANSFER_WRITE |
+                                       PIPE_TRANSFER_FLUSH_EXPLICIT,
+                                       &upload->transfer);
    
    upload->size = size;