diff options
author | José Fonseca <[email protected]> | 2009-03-03 18:52:16 +0000 |
---|---|---|
committer | José Fonseca <[email protected]> | 2009-03-03 18:52:16 +0000 |
commit | 190db8b4c36bffcaae996538e250eb144242c064 (patch) | |
tree | 343961a348f175735b391444d3c2565117265af0 /src/gallium | |
parent | 1d4d27802d1e0e51d5f91fe9cb1ae9b6d57cae30 (diff) |
gallium: Massage the interface to more closely resemble ARB_map_buffer_range
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/include/pipe/p_inlines.h | 78 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_screen.h | 29 |
2 files changed, 36 insertions, 71 deletions
diff --git a/src/gallium/include/pipe/p_inlines.h b/src/gallium/include/pipe/p_inlines.h index a7ce0c2c277..1f19867bdf9 100644 --- a/src/gallium/include/pipe/p_inlines.h +++ b/src/gallium/include/pipe/p_inlines.h @@ -152,13 +152,9 @@ pipe_buffer_map(struct pipe_screen *screen, unsigned usage) { if(screen->buffer_map_range) { - struct pipe_buffer_range read; - struct pipe_buffer_range write; - read.offset = 0; - read.size = usage & PIPE_BUFFER_USAGE_CPU_READ ? buf->size : 0; - write.offset = 0; - write.size = usage & PIPE_BUFFER_USAGE_CPU_WRITE ? buf->size : 0; - return screen->buffer_map_range(screen, buf, read, write, usage); + 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); @@ -168,42 +164,33 @@ static INLINE void pipe_buffer_unmap(struct pipe_screen *screen, struct pipe_buffer *buf) { - if(screen->buffer_unmap_range) { - struct pipe_buffer_range written; - written.offset = 0; - written.size = buf->size; - screen->buffer_unmap_range(screen, buf, written); - } - else - screen->buffer_unmap(screen, buf); + screen->buffer_unmap(screen, buf); } static INLINE void * pipe_buffer_map_range(struct pipe_screen *screen, struct pipe_buffer *buf, - struct pipe_buffer_range read, - struct pipe_buffer_range write) + unsigned offset, + unsigned length, + unsigned usage) { - unsigned usage = 0; - if(read.size) - usage |= PIPE_BUFFER_USAGE_CPU_READ; - if(write.size) - usage |= PIPE_BUFFER_USAGE_CPU_WRITE; if(screen->buffer_map_range) - return screen->buffer_map_range(screen, buf, read, write, usage); - else - return screen->buffer_map(screen, buf, usage); + 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; + } } static INLINE void -pipe_buffer_unmap_range(struct pipe_screen *screen, - struct pipe_buffer *buf, - struct pipe_buffer_range written) +pipe_buffer_flush_mapped_range(struct pipe_screen *screen, + struct pipe_buffer *buf, + unsigned offset, + unsigned length) { - if(screen->buffer_unmap_range) - screen->buffer_unmap_range(screen, buf, written); - else - screen->buffer_unmap(screen, buf); + if(screen->buffer_flush_mapped_range) + screen->buffer_flush_mapped_range(screen, buf, offset, length); } static INLINE void @@ -212,23 +199,17 @@ pipe_buffer_write(struct pipe_screen *screen, unsigned offset, unsigned size, const void *data) { - struct pipe_buffer_range read; - struct pipe_buffer_range write; uint8_t *map; assert(offset < buf->size); assert(offset + size <= buf->size); - read.offset = 0; - read.size = 0; - write.offset = offset; - write.size = size; - - map = pipe_buffer_map_range(screen, buf, read, write); + 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_unmap_range(screen, buf, write); + memcpy(map, data, size); + pipe_buffer_flush_mapped_range(screen, buf, offset, size); + pipe_buffer_unmap(screen, buf); } } @@ -238,23 +219,16 @@ pipe_buffer_read(struct pipe_screen *screen, unsigned offset, unsigned size, void *data) { - struct pipe_buffer_range read; - struct pipe_buffer_range write; uint8_t *map; assert(offset < buf->size); assert(offset + size <= buf->size); - read.offset = offset; - read.size = size; - write.offset = 0; - write.size = 0; - - map = pipe_buffer_map_range(screen, buf, read, write); + map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_READ); assert(map); if(map) { - memcpy(data, map + offset, size); - pipe_buffer_unmap_range(screen, buf, write); + memcpy(data, map, 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 69db80ee3f3..48f6b69d921 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -56,13 +56,6 @@ struct pipe_buffer; -struct pipe_buffer_range -{ - unsigned offset; - unsigned size; -}; - - /** * Gallium screen/adapter context. Basically everything * hardware-specific that doesn't actually require a rendering @@ -216,10 +209,6 @@ struct pipe_screen { void *(*buffer_map)( struct pipe_screen *screen, struct pipe_buffer *buf, unsigned usage ); - - void (*buffer_unmap)( struct pipe_screen *screen, - struct pipe_buffer *buf ); - /** * Map a subrange of the buffer data store into the client's address space. * @@ -228,18 +217,20 @@ struct pipe_screen { */ void *(*buffer_map_range)( struct pipe_screen *screen, struct pipe_buffer *buf, - struct pipe_buffer_range read, - struct pipe_buffer_range write, - unsigned usage /* XXX: deprecated? */); + unsigned offset, + unsigned length, + unsigned usage); /** - * Unmap a buffer. - * * written is the range that the client actually wrote. */ - void (*buffer_unmap_range)( struct pipe_screen *screen, - struct pipe_buffer *buf, - struct pipe_buffer_range written); + 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 ); void (*buffer_destroy)( struct pipe_screen *screen, struct pipe_buffer *buf ); |