summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2013-11-14 07:28:09 -0800
committerIan Romanick <ian.d.romanick@intel.com>2013-11-23 12:39:45 -0800
commit9495fb4fff15c7f0e8b07bc101dd7a8ccfc6421c (patch)
tree60d3ef6432d2ac426c268e5be64e3331544e9478 /src/gallium
parent521c59f1327e8902e4bb9dc4f926a54a1cb26bd3 (diff)
r600g/compute: Fix handling of global buffers in r600_resource_copy_region()
Global buffers do not have an associate cs_buf handle, so we can't copy them using r600_copy_buffer() https://bugs.freedesktop.org/show_bug.cgi?id=64226 Reviewed-by: Marek Ol????k <marek.olsak@amd.com> CC: "10.0" <mesa-stable@lists.freedesktop.org> (cherry picked from commit 1b9511d7ce70a9f9cadd0c03bd0c916b88b6dd43)
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/r600/r600_blit.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/gallium/drivers/r600/r600_blit.c b/src/gallium/drivers/r600/r600_blit.c
index 124efa5d7df..fea33bccaa8 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -619,6 +619,36 @@ void r600_copy_buffer(struct pipe_context *ctx, struct pipe_resource *dst, unsig
}
}
+/**
+ * Global buffers are not really resources, they are are actually offsets
+ * into a single global resource (r600_screen::global_pool). The means
+ * they don't have their own cs_buf handle, so they cannot be passed
+ * to r600_copy_buffer() and must be handled separately.
+ *
+ * XXX: It should be possible to implement this function using
+ * r600_copy_buffer() by passing the memory_pool resource as both src
+ * and dst and updating dstx and src_box to point to the correct offsets.
+ * This would likely perform better than the current implementation.
+ */
+static void r600_copy_global_buffer(struct pipe_context *ctx,
+ struct pipe_resource *dst, unsigned
+ dstx, struct pipe_resource *src,
+ const struct pipe_box *src_box)
+{
+ struct pipe_box dst_box; struct pipe_transfer *src_pxfer,
+ *dst_pxfer;
+
+ u_box_1d(dstx, src_box->width, &dst_box);
+ void *src_ptr = ctx->transfer_map(ctx, src, 0, PIPE_TRANSFER_READ,
+ src_box, &src_pxfer);
+ void *dst_ptr = ctx->transfer_map(ctx, dst, 0, PIPE_TRANSFER_WRITE,
+ &dst_box, &dst_pxfer);
+ memcpy(dst_ptr, src_ptr, src_box->width);
+
+ ctx->transfer_unmap(ctx, src_pxfer);
+ ctx->transfer_unmap(ctx, dst_pxfer);
+}
+
static void r600_clear_buffer(struct pipe_context *ctx, struct pipe_resource *dst,
unsigned offset, unsigned size, unsigned value)
{
@@ -671,7 +701,12 @@ static void r600_resource_copy_region(struct pipe_context *ctx,
/* Handle buffers first. */
if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) {
- r600_copy_buffer(ctx, dst, dstx, src, src_box);
+ if ((src->bind & PIPE_BIND_GLOBAL) ||
+ (dst->bind & PIPE_BIND_GLOBAL)) {
+ r600_copy_global_buffer(ctx, dst, dstx, src, src_box);
+ } else {
+ r600_copy_buffer(ctx, dst, dstx, src, src_box);
+ }
return;
}