summaryrefslogtreecommitdiffstats
path: root/src/gallium/include/pipe
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2009-02-24 11:30:25 +0000
committerJosé Fonseca <[email protected]>2009-02-24 11:30:25 +0000
commit693fac8ae2e5812265222b1335695bd33b90bd8a (patch)
treedf1bf997bcec57a8b9db1451c8fb40c488221ef0 /src/gallium/include/pipe
parentc5dd8634c8d3487a171cd129c2b7ac6e205e72a7 (diff)
gallium: Add pipe_buffer_write/read inlines.
Saves code, and will simplify future interface changes.
Diffstat (limited to 'src/gallium/include/pipe')
-rw-r--r--src/gallium/include/pipe/p_inlines.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/gallium/include/pipe/p_inlines.h b/src/gallium/include/pipe/p_inlines.h
index ffbe2d7612a..4eb928d882f 100644
--- a/src/gallium/include/pipe/p_inlines.h
+++ b/src/gallium/include/pipe/p_inlines.h
@@ -161,6 +161,44 @@ pipe_buffer_unmap(struct pipe_screen *screen,
screen->buffer_unmap(screen, buf);
}
+static INLINE void
+pipe_buffer_write(struct pipe_screen *screen,
+ struct pipe_buffer *buf,
+ unsigned offset, unsigned size,
+ const void *data)
+{
+ uint8_t *map;
+
+ assert(offset < buf->size);
+ assert(offset + size <= buf->size);
+
+ map = pipe_buffer_map(screen, buf, PIPE_BUFFER_USAGE_CPU_WRITE);
+ assert(map);
+ if(map) {
+ memcpy(map + offset, data, size);
+ pipe_buffer_unmap(screen, buf);
+ }
+}
+
+static INLINE void
+pipe_buffer_read(struct pipe_screen *screen,
+ struct pipe_buffer *buf,
+ unsigned offset, unsigned size,
+ void *data)
+{
+ uint8_t *map;
+
+ assert(offset < buf->size);
+ assert(offset + size <= buf->size);
+
+ map = pipe_buffer_map(screen, buf, PIPE_BUFFER_USAGE_CPU_READ);
+ assert(map);
+ if(map) {
+ memcpy(data, map + offset, size);
+ pipe_buffer_unmap(screen, buf);
+ }
+}
+
/* XXX: thread safety issues!
*/
static INLINE void