diff options
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/include/pipe/p_inlines.h | 48 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_screen.h | 28 |
2 files changed, 70 insertions, 6 deletions
diff --git a/src/gallium/include/pipe/p_inlines.h b/src/gallium/include/pipe/p_inlines.h index a68b521429..1232c87968 100644 --- a/src/gallium/include/pipe/p_inlines.h +++ b/src/gallium/include/pipe/p_inlines.h @@ -60,7 +60,13 @@ pipe_buffer_map(struct pipe_screen *screen, struct pipe_buffer *buf, unsigned usage) { - return screen->buffer_map(screen, buf, usage); + if(screen->buffer_map_range) { + unsigned offset = 0; + unsigned length = buf->size; + return screen->buffer_map_range(screen, buf, offset, length, usage); + } + else + return screen->buffer_map(screen, buf, usage); } static INLINE void @@ -70,6 +76,35 @@ pipe_buffer_unmap(struct pipe_screen *screen, screen->buffer_unmap(screen, buf); } +static INLINE void * +pipe_buffer_map_range(struct pipe_screen *screen, + struct pipe_buffer *buf, + unsigned offset, + unsigned length, + unsigned usage) +{ + 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 + return screen->buffer_map(screen, buf, usage); +} + +static INLINE void +pipe_buffer_flush_mapped_range(struct pipe_screen *screen, + struct pipe_buffer *buf, + unsigned offset, + unsigned length) +{ + 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); +} + static INLINE void pipe_buffer_write(struct pipe_screen *screen, struct pipe_buffer *buf, @@ -80,11 +115,13 @@ pipe_buffer_write(struct pipe_screen *screen, assert(offset < buf->size); assert(offset + size <= buf->size); - - map = pipe_buffer_map(screen, buf, PIPE_BUFFER_USAGE_CPU_WRITE); + assert(size); + + map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_WRITE); assert(map); if(map) { memcpy(map + offset, data, size); + pipe_buffer_flush_mapped_range(screen, buf, offset, size); pipe_buffer_unmap(screen, buf); } } @@ -99,8 +136,9 @@ pipe_buffer_read(struct pipe_screen *screen, assert(offset < buf->size); assert(offset + size <= buf->size); - - map = pipe_buffer_map(screen, buf, PIPE_BUFFER_USAGE_CPU_READ); + assert(size); + + map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_READ); assert(map); if(map) { memcpy(data, map + offset, size); diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index 3688d58118..ed3a026023 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -202,9 +202,35 @@ struct pipe_screen { void *(*buffer_map)( struct pipe_screen *screen, struct pipe_buffer *buf, unsigned usage ); + /** + * Map a subrange of the buffer data store into the client's address space. + * + * 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, + unsigned offset, + unsigned length, + unsigned usage); + + /** + * 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, + unsigned offset, + unsigned length); void (*buffer_unmap)( struct pipe_screen *screen, - struct pipe_buffer *buf ); + struct pipe_buffer *buf ); void (*buffer_destroy)( struct pipe_buffer *buf ); |