Mesa (mesa_7_7_branch): gallium: New inline to write buffers which avoids synchronization.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Thu Jan 21 23:27:44 UTC 2010


Module: Mesa
Branch: mesa_7_7_branch
Commit: a8477fb00c1a7b8bfefb5779bc05c51cdb29cdb5
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a8477fb00c1a7b8bfefb5779bc05c51cdb29cdb5

Author: José Fonseca <jfonseca at vmware.com>
Date:   Thu Jan 21 09:30:22 2010 -0800

gallium: New inline to write buffers which avoids synchronization.

---

 src/gallium/include/pipe/p_inlines.h |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/src/gallium/include/pipe/p_inlines.h b/src/gallium/include/pipe/p_inlines.h
index 11ed46c..72f5c1d 100644
--- a/src/gallium/include/pipe/p_inlines.h
+++ b/src/gallium/include/pipe/p_inlines.h
@@ -129,6 +129,37 @@ pipe_buffer_write(struct pipe_screen *screen,
    }
 }
 
+/**
+ * Special case for writing non-overlapping ranges.
+ *
+ * We can avoid GPU/CPU synchronization when writing range that has never
+ * been written before.
+ */
+static INLINE void
+pipe_buffer_write_nooverlap(struct pipe_screen *screen,
+                            struct pipe_buffer *buf,
+                            unsigned offset, unsigned size,
+                            const void *data)
+{
+   void *map;
+
+   assert(offset < buf->size);
+   assert(offset + size <= buf->size);
+   assert(size);
+
+   map = pipe_buffer_map_range(screen, buf, offset, size,
+                               PIPE_BUFFER_USAGE_CPU_WRITE |
+                               PIPE_BUFFER_USAGE_FLUSH_EXPLICIT |
+                               PIPE_BUFFER_USAGE_DISCARD |
+                               PIPE_BUFFER_USAGE_UNSYNCHRONIZED);
+   assert(map);
+   if(map) {
+      memcpy((uint8_t *)map + offset, data, size);
+      pipe_buffer_flush_mapped_range(screen, buf, offset, size);
+      pipe_buffer_unmap(screen, buf);
+   }
+}
+
 static INLINE void
 pipe_buffer_read(struct pipe_screen *screen,
                  struct pipe_buffer *buf,




More information about the mesa-commit mailing list