Module: Mesa Branch: gallium-resources Commit: 3f5363d4dc9d7ad48467ae82d58d5f3d9bd10698 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3f5363d4dc9d7ad48467ae82d58d5f3d9bd10698
Author: Keith Whitwell <[email protected]> Date: Wed Apr 7 17:26:52 2010 +0100 util: map_range and flush_range have offsets relative to start of buffer --- src/gallium/auxiliary/util/u_inlines.h | 23 ++++++++++++++++++++--- 1 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index 0ac8e70..66a8bf3 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -161,6 +161,7 @@ pipe_buffer_map_range(struct pipe_context *pipe, struct pipe_transfer **transfer) { struct pipe_box box; + char *map; assert(offset < buffer->width0); assert(offset + length <= buffer->width0); @@ -177,7 +178,14 @@ pipe_buffer_map_range(struct pipe_context *pipe, if (*transfer == NULL) return NULL; - return pipe->transfer_map( pipe, *transfer ); + map = pipe->transfer_map( pipe, *transfer ); + if (map == NULL) + return NULL; + + /* Match old screen->buffer_map_range() behaviour, return pointer + * to where the beginning of the buffer would be: + */ + return (void *)(map - offset); } @@ -209,10 +217,19 @@ pipe_buffer_flush_mapped_range(struct pipe_context *pipe, unsigned length) { struct pipe_box box; + int transfer_offset; assert(length); - - u_box_1d(offset, length, &box); + assert(transfer->box.x <= offset); + assert(transfer->box.x + transfer->box.width <= offset + length); + + /* Match old screen->buffer_flush_mapped_range() behaviour, where + * offset parameter is relative to the start of the buffer, not the + * mapped range. + */ + transfer_offset = offset - transfer->box.x; + + u_box_1d(transfer_offset, length, &box); pipe->transfer_flush_region(pipe, transfer, &box); } _______________________________________________ mesa-commit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-commit
