dst = (struct pipe_resource *)item->real_buffer;
/* We transfer the memory from the item in the pool to the
- * temporary buffer */
- u_box_1d(item->start_in_dw * 4, item->size_in_dw * 4, &box);
+ * temporary buffer. Download is skipped for items:
+ * - Not mapped for reading or writing (PIPE_MAP_DISCARD_RANGE).
+ * - Not writable by the device. */
+ if ((item->status & (ITEM_MAPPED_FOR_READING|ITEM_MAPPED_FOR_WRITING)) &&
+ !(r600_resource(dst)->flags & RADEON_FLAG_READ_ONLY)) {
+
+ u_box_1d(item->start_in_dw * 4, item->size_in_dw * 4, &box);
- rctx->b.b.resource_copy_region(pipe,
- dst, 0, 0, 0, 0,
- src, 0, &box);
+ rctx->b.b.resource_copy_region(pipe,
+ dst, 0, 0, 0, 0,
+ src, 0, &box);
+ }
/* Remember to mark the buffer as 'pending' by setting start_in_dw to -1 */
item->start_in_dw = -1;
struct pipe_resource *dst = NULL;
unsigned offset = box->x;
+ if (usage & PIPE_MAP_READ)
+ buffer->chunk->status |= ITEM_MAPPED_FOR_READING;
+
+ if (usage & PIPE_MAP_WRITE)
+ buffer->chunk->status |= ITEM_MAPPED_FOR_WRITING;
+
if (is_item_in_pool(item)) {
compute_memory_demote_item(pool, item, ctx);
}
dst = (struct pipe_resource*)item->real_buffer;
- if (usage & PIPE_MAP_READ)
- buffer->chunk->status |= ITEM_MAPPED_FOR_READING;
-
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,
///TODO: do it better, mapping is not possible if the pool is too big
return pipe_buffer_map_range(ctx, dst,
- offset, box->width, usage, ptransfer);
+ offset, box->width, usage & ~PIPE_MAP_READ, ptransfer);
}
void r600_compute_global_transfer_unmap(struct pipe_context *ctx,