r600g/compute: Map only against intermediate buffers
authorBruno Jiménez <brunojimen@gmail.com>
Wed, 18 Jun 2014 15:01:58 +0000 (17:01 +0200)
committerTom Stellard <thomas.stellard@amd.com>
Fri, 20 Jun 2014 17:44:08 +0000 (13:44 -0400)
With this we can assure that mapped buffers will never change
its position when relocating the pool.

This patch should finally solve the mapping bug.

v2: Use the new is_item_in_pool util function,
    as suggested by Tom Stellard

Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
src/gallium/drivers/r600/evergreen_compute.c

index 8657071e4c6356893b15f7cef3f2d716d37e69e5..c0dd0f349144f756cecc4b8019b00e2802845e8f 100644 (file)
@@ -970,14 +970,12 @@ void *r600_compute_global_transfer_map(
        struct pipe_resource *dst;
        unsigned offset = box->x;
 
-       if (buffer->chunk->real_buffer) {
-               dst = (struct pipe_resource*)buffer->chunk->real_buffer;
-       }
-       else {
-               dst = (struct pipe_resource*)buffer->chunk->pool->bo;
-               offset += (buffer->chunk->start_in_dw * 4);
+       if (is_item_in_pool(buffer->chunk)) {
+               compute_memory_demote_item(pool, buffer->chunk, ctx_);
        }
 
+       dst = (struct pipe_resource*)buffer->chunk->real_buffer;
+
        if (usage & PIPE_TRANSFER_READ)
                buffer->chunk->status |= ITEM_MAPPED_FOR_READING;