This will be necessary to know how many mappings for read it has, as
the spec allows to have as many as desired.
---
 src/gallium/drivers/r600/compute_memory_pool.c | 5 +++--
 src/gallium/drivers/r600/compute_memory_pool.h | 1 +
 src/gallium/drivers/r600/evergreen_compute.c   | 3 +--
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/r600/compute_memory_pool.c 
b/src/gallium/drivers/r600/compute_memory_pool.c
index 0ee8ceb..497ff90 100644
--- a/src/gallium/drivers/r600/compute_memory_pool.c
+++ b/src/gallium/drivers/r600/compute_memory_pool.c
@@ -403,11 +403,12 @@ int compute_memory_promote_item(struct 
compute_memory_pool *pool,
                                dst, 0, item->start_in_dw * 4, 0 ,0,
                                src, 0, &box);
 
-               /* We check if the item is mapped for reading.
+               /* We check if the item is mapped. At this point, only
+                * buffers mapped for reading should still be mapped.
                 * In this case, we need to keep the temporary buffer 'alive'
                 * because it is possible to keep a map active for reading
                 * while a kernel (that reads from it) executes */
-               if (!(item->status & ITEM_MAPPED_FOR_READING)) {
+               if (item->map_count == 0) {
                        pool->screen->b.b.resource_destroy(screen, src);
                        item->real_buffer = NULL;
                }
diff --git a/src/gallium/drivers/r600/compute_memory_pool.h 
b/src/gallium/drivers/r600/compute_memory_pool.h
index 161ddd5..8fcd75b 100644
--- a/src/gallium/drivers/r600/compute_memory_pool.h
+++ b/src/gallium/drivers/r600/compute_memory_pool.h
@@ -41,6 +41,7 @@ struct compute_memory_item
        int64_t id;             /**< ID of the memory chunk */
 
        uint32_t status;        /**< Will track the status of the item */
+       uint32_t map_count;     /**< Will track the number of maps done to the 
item */
 
        /** Start pointer in dwords relative in the pool bo. If an item
         * is unallocated, then this value must be -1 to indicate this. */
diff --git a/src/gallium/drivers/r600/evergreen_compute.c 
b/src/gallium/drivers/r600/evergreen_compute.c
index 1970414..f50f94a 100644
--- a/src/gallium/drivers/r600/evergreen_compute.c
+++ b/src/gallium/drivers/r600/evergreen_compute.c
@@ -986,8 +986,7 @@ void *r600_compute_global_transfer_map(
 
        dst = (struct pipe_resource*)item->real_buffer;
 
-       if (usage & PIPE_TRANSFER_READ)
-               buffer->chunk->status |= ITEM_MAPPED_FOR_READING;
+       item->map_count++;
 
        COMPUTE_DBG(rctx->screen, "* r600_compute_global_transfer_map()\n"
                        "level = %u, usage = %u, box(x = %u, y = %u, z = %u "
-- 
2.0.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to