diff options
author | Bruno Jiménez <[email protected]> | 2014-06-19 20:20:02 +0200 |
---|---|---|
committer | Tom Stellard <[email protected]> | 2014-06-24 12:37:36 -0400 |
commit | c997007f66d402aea5a76da5b260b49a91c0fce1 (patch) | |
tree | 91dc4bc9c7d21a43f2d220796094dcf7197ead90 /src/gallium/drivers/r600/evergreen_compute.c | |
parent | fec2a08eae67806d47a435eca8395eb250ccddb4 (diff) |
r600g/compute: Defer the creation of the temporary resource
For the first use of a buffer, we will only need the temporary
resource in the case that a user wants to write/map to this buffer.
But in the cases where the user creates a buffer to act as an
output of a kernel, then we were creating an unneeded resource,
because it will contain garbage, and would be copied to the pool,
and destroyed when promoting.
This patch avoids the creation and copies of resources in
this case.
Reviewed-by: Tom Stellard <[email protected]>
Diffstat (limited to 'src/gallium/drivers/r600/evergreen_compute.c')
-rw-r--r-- | src/gallium/drivers/r600/evergreen_compute.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c index 5c115dcb282..12e9c85586d 100644 --- a/src/gallium/drivers/r600/evergreen_compute.c +++ b/src/gallium/drivers/r600/evergreen_compute.c @@ -970,14 +970,21 @@ void *r600_compute_global_transfer_map( struct r600_resource_global* buffer = (struct r600_resource_global*)resource; - struct pipe_resource *dst; + struct compute_memory_item *item = buffer->chunk; + struct pipe_resource *dst = NULL; unsigned offset = box->x; - if (is_item_in_pool(buffer->chunk)) { - compute_memory_demote_item(pool, buffer->chunk, ctx_); + if (is_item_in_pool(item)) { + compute_memory_demote_item(pool, item, ctx_); + } + else { + if (item->real_buffer == NULL) { + item->real_buffer = (struct r600_resource*) + r600_compute_buffer_alloc_vram(pool->screen, item->size_in_dw * 4); + } } - dst = (struct pipe_resource*)buffer->chunk->real_buffer; + dst = (struct pipe_resource*)item->real_buffer; if (usage & PIPE_TRANSFER_READ) buffer->chunk->status |= ITEM_MAPPED_FOR_READING; @@ -988,7 +995,7 @@ void *r600_compute_global_transfer_map( box->x, box->y, box->z, box->width, box->height, box->depth); COMPUTE_DBG(rctx->screen, "Buffer id = %u offset = " - "%u (box.x)\n", buffer->chunk->id, box->x); + "%u (box.x)\n", item->id, box->x); assert(resource->target == PIPE_BUFFER); |