diff options
author | Marek Olšák <[email protected]> | 2012-02-26 18:56:51 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2012-02-27 16:22:26 +0100 |
commit | 335facb502199353e6f73c8ba20a2bb4ff7bf336 (patch) | |
tree | 2d73dfc37eafa7259babb7b13986e13906931607 /src | |
parent | 615baedc778039a2dcd08bbc1b3006c9e5a111dc (diff) |
gallium/util: add fast path for buffers in u_default_transfer_inline_write
v2: fix indentation, add assertions
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/auxiliary/util/u_transfer.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/src/gallium/auxiliary/util/u_transfer.c b/src/gallium/auxiliary/util/u_transfer.c index 1fa8d945982..673a984fcb2 100644 --- a/src/gallium/auxiliary/util/u_transfer.c +++ b/src/gallium/auxiliary/util/u_transfer.c @@ -18,8 +18,6 @@ void u_default_transfer_inline_write( struct pipe_context *pipe, { struct pipe_transfer *transfer = NULL; uint8_t *map = NULL; - const uint8_t *src_data = data; - unsigned i; assert(!(usage & PIPE_TRANSFER_READ)); @@ -45,18 +43,29 @@ void u_default_transfer_inline_write( struct pipe_context *pipe, if (map == NULL) goto out; - for (i = 0; i < box->depth; i++) { - util_copy_rect(map, - resource->format, - transfer->stride, /* bytes */ - 0, 0, - box->width, - box->height, - src_data, - stride, /* bytes */ - 0, 0); - map += transfer->layer_stride; - src_data += layer_stride; + if (resource->target == PIPE_BUFFER) { + assert(box->height == 1); + assert(box->depth == 1); + + memcpy(map, data, box->width); + } + else { + const uint8_t *src_data = data; + unsigned i; + + for (i = 0; i < box->depth; i++) { + util_copy_rect(map, + resource->format, + transfer->stride, /* bytes */ + 0, 0, + box->width, + box->height, + src_data, + stride, /* bytes */ + 0, 0); + map += transfer->layer_stride; + src_data += layer_stride; + } } out: |