summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r600/evergreen_compute.c
diff options
context:
space:
mode:
authorBruno JimĂ©nez <[email protected]>2014-06-18 17:01:51 +0200
committerTom Stellard <[email protected]>2014-06-20 13:43:28 -0400
commit0038402753b6a5c2a56f66ae0ffe25a9eb1d1b63 (patch)
tree43f4a6bf5128e7581169348fd705bb3426a9a899 /src/gallium/drivers/r600/evergreen_compute.c
parent96a95f48eaf8af2c6ace51531bdd5bfbcf71165e (diff)
r600g/compute: Add an intermediate resource for OpenCL buffers
This patch changes completely the way buffers are added to the compute_memory_pool. Before this, whenever we were going to map a buffer or write to or read from it, it would get placed into the pool. Now, every unallocated buffer has its own r600_resource until it is allocated in the pool. NOTE: This patch also increase the GPU memory usage at the moment of putting every buffer in it's place. More or less, the memory usage is ~2x(sum of every buffer size) v2: Cleanup v3: Use temporary variables to avoid so many castings in functions, as suggested by Tom Stellard 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.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c
index a2abf1546dd..c152e54146a 100644
--- a/src/gallium/drivers/r600/evergreen_compute.c
+++ b/src/gallium/drivers/r600/evergreen_compute.c
@@ -958,6 +958,17 @@ void *r600_compute_global_transfer_map(
struct r600_resource_global* buffer =
(struct r600_resource_global*)resource;
+ 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);
+ }
+
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,
@@ -967,8 +978,6 @@ void *r600_compute_global_transfer_map(
"%u (box.x)\n", buffer->chunk->id, box->x);
- compute_memory_finalize_pending(pool, ctx_);
-
assert(resource->target == PIPE_BUFFER);
assert(resource->bind & PIPE_BIND_GLOBAL);
assert(box->x >= 0);
@@ -976,9 +985,8 @@ void *r600_compute_global_transfer_map(
assert(box->z == 0);
///TODO: do it better, mapping is not possible if the pool is too big
- return pipe_buffer_map_range(ctx_, (struct pipe_resource*)buffer->chunk->pool->bo,
- box->x + (buffer->chunk->start_in_dw * 4),
- box->width, usage, ptransfer);
+ return pipe_buffer_map_range(ctx_, dst,
+ offset, box->width, usage, ptransfer);
}
void r600_compute_global_transfer_unmap(