All the *Enqueue* functions that read/write buffers (except clEnqueueCopyBuffer) would map the associated resource, making it to be demoted if it was in the pool.
But we possitively know that this transfer will end before any kernel is launched, so there's no need to demote it. --- src/gallium/drivers/r600/evergreen_compute.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c index c0dd0f3..2d6b9d3 100644 --- a/src/gallium/drivers/r600/evergreen_compute.c +++ b/src/gallium/drivers/r600/evergreen_compute.c @@ -967,18 +967,28 @@ void *r600_compute_global_transfer_map( struct r600_resource_global* buffer = (struct r600_resource_global*)resource; - struct pipe_resource *dst; + struct pipe_resource *dst = + (struct pipe_resource *) buffer->chunk->real_buffer; unsigned offset = box->x; + /* If the item is already in the pool, and we are going + * to read/write it, map it directly without demoting it */ if (is_item_in_pool(buffer->chunk)) { - compute_memory_demote_item(pool, buffer->chunk, ctx_); + if (usage & PIPE_TRANSFER_MAP_DIRECTLY) { + dst = (struct pipe_resource *) buffer->chunk->pool->bo; + offset += (buffer->chunk->start_in_dw * 4); + } + else { + compute_memory_demote_item(pool, buffer->chunk, ctx_); + dst = (struct pipe_resource *) buffer->chunk->real_buffer; + } } - dst = (struct pipe_resource*)buffer->chunk->real_buffer; - - if (usage & PIPE_TRANSFER_READ) + if ((usage & PIPE_TRANSFER_READ) && !(usage & PIPE_TRANSFER_MAP_DIRECTLY)) buffer->chunk->status |= ITEM_MAPPED_FOR_READING; + usage &= ~PIPE_TRANSFER_MAP_DIRECTLY; + COMPUTE_DBG(rctx->screen, "* r600_compute_global_transfer_map()\n" "level = %u, usage = %u, box(x = %u, y = %u, z = %u " "width = %u, height = %u, depth = %u)\n", level, usage, -- 2.0.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev