diff options
author | Brian Paul <[email protected]> | 2016-08-12 10:44:22 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2016-09-17 10:08:59 -0600 |
commit | ce3b34b72702195694ee8fc64c8259d4a16711ab (patch) | |
tree | 2855e336d6835137cbef993860ca8ab3d692a550 | |
parent | b7bee2505239ef1a14fecde5b73ffdab67694aa2 (diff) |
svga: optimize memcpy() in svga_buffer_update_hw()
When we migrate a buffer from sw/malloc storage to a hardware buffer,
don't memcpy the whole buffer, just copy the part we've written to.
Reviewed-by: Charmaine Lee <[email protected]>
-rw-r--r-- | src/gallium/drivers/svga/svga_resource_buffer_upload.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/gallium/drivers/svga/svga_resource_buffer_upload.c b/src/gallium/drivers/svga/svga_resource_buffer_upload.c index e1e65c1ccb3..7ecf95c1af7 100644 --- a/src/gallium/drivers/svga/svga_resource_buffer_upload.c +++ b/src/gallium/drivers/svga/svga_resource_buffer_upload.c @@ -620,6 +620,7 @@ svga_buffer_update_hw(struct svga_context *svga, struct svga_buffer *sbuf) enum pipe_error ret; boolean retry; void *map; + unsigned i; assert(sbuf->swbuf); if (!sbuf->swbuf) @@ -639,7 +640,13 @@ svga_buffer_update_hw(struct svga_context *svga, struct svga_buffer *sbuf) return PIPE_ERROR; } - memcpy(map, sbuf->swbuf, sbuf->b.b.width0); + /* Copy data from malloc'd swbuf to the new hardware buffer */ + for (i = 0; i < sbuf->map.num_ranges; i++) { + unsigned start = sbuf->map.ranges[i].start; + unsigned len = sbuf->map.ranges[i].end - start; + memcpy((uint8_t *) map + start, (uint8_t *) sbuf->swbuf + start, len); + } + svga_buffer_hw_storage_unmap(svga, sbuf); /* This user/malloc buffer is now indistinguishable from a gpu buffer */ |