Mesa (master): gallium: Use consistent semantics for map ranges in gallium.
Jose Fonseca
jrfonseca at kemper.freedesktop.org
Wed Mar 4 21:46:43 UTC 2009
Module: Mesa
Branch: master
Commit: 2a1f29c22003e819914d386f2117d6e186f59f20
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2a1f29c22003e819914d386f2117d6e186f59f20
Author: José Fonseca <jfonseca at vmware.com>
Date: Wed Mar 4 17:48:26 2009 +0000
gallium: Use consistent semantics for map ranges in gallium.
Which are slightly different from ARB_map_buffer_range semantics, since
gallium still supports more than one mapping of the same buffer.
---
src/gallium/include/pipe/p_inlines.h | 19 ++++++++++---------
src/gallium/include/pipe/p_screen.h | 13 ++++++++++---
2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/src/gallium/include/pipe/p_inlines.h b/src/gallium/include/pipe/p_inlines.h
index 4e5252d..1232c87 100644
--- a/src/gallium/include/pipe/p_inlines.h
+++ b/src/gallium/include/pipe/p_inlines.h
@@ -85,13 +85,11 @@ pipe_buffer_map_range(struct pipe_screen *screen,
{
assert(offset < buf->size);
assert(offset + length <= buf->size);
+ assert(length);
if(screen->buffer_map_range)
return screen->buffer_map_range(screen, buf, offset, length, usage);
- else {
- uint8_t *map;
- map = screen->buffer_map(screen, buf, usage);
- return map ? map + offset : NULL;
- }
+ else
+ return screen->buffer_map(screen, buf, usage);
}
static INLINE void
@@ -102,6 +100,7 @@ pipe_buffer_flush_mapped_range(struct pipe_screen *screen,
{
assert(offset < buf->size);
assert(offset + length <= buf->size);
+ assert(length);
if(screen->buffer_flush_mapped_range)
screen->buffer_flush_mapped_range(screen, buf, offset, length);
}
@@ -116,11 +115,12 @@ pipe_buffer_write(struct pipe_screen *screen,
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);
assert(map);
if(map) {
- memcpy(map, data, size);
+ memcpy(map + offset, data, size);
pipe_buffer_flush_mapped_range(screen, buf, offset, size);
pipe_buffer_unmap(screen, buf);
}
@@ -136,11 +136,12 @@ pipe_buffer_read(struct pipe_screen *screen,
assert(offset < buf->size);
assert(offset + size <= buf->size);
-
+ assert(size);
+
map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_READ);
assert(map);
if(map) {
- memcpy(data, map, size);
+ memcpy(data, map + offset, size);
pipe_buffer_unmap(screen, buf);
}
}
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index d7e79ec..ed3a026 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -205,8 +205,10 @@ struct pipe_screen {
/**
* Map a subrange of the buffer data store into the client's address space.
*
- * Return pointer is always relative to offset 0, regardless of the
- * read/write ranges.
+ * The returned pointer is always relative to buffer start, regardless of
+ * the specified range. This is different from the ARB_map_buffer_range
+ * semantics because we don't forbid multiple mappings of the same buffer
+ * (yet).
*/
void *(*buffer_map_range)( struct pipe_screen *screen,
struct pipe_buffer *buf,
@@ -215,7 +217,12 @@ struct pipe_screen {
unsigned usage);
/**
- * written is the range that the client actually wrote.
+ * Notify a range that was actually written into.
+ *
+ * The range is relative to the buffer start, regardless of the range
+ * specified to buffer_map_range. This is different from the
+ * ARB_map_buffer_range semantics because we don't forbid multiple mappings
+ * of the same buffer (yet).
*/
void (*buffer_flush_mapped_range)( struct pipe_screen *screen,
struct pipe_buffer *buf,
More information about the mesa-commit
mailing list