[Mesa-dev] [PATCH 02/10] r600g: use common interfaces in buffer_transfer_unmap

Marek Olšák maraeo at gmail.com
Fri Nov 29 09:55:21 PST 2013


From: Marek Olšák <marek.olsak at amd.com>

i.e. dma_copy and resource_copy_region.
---
 src/gallium/drivers/r600/evergreen_state.c |  6 ++++++
 src/gallium/drivers/r600/r600_blit.c       |  4 ++--
 src/gallium/drivers/r600/r600_buffer.c     | 18 ++++++++----------
 src/gallium/drivers/r600/r600_pipe.h       |  2 --
 src/gallium/drivers/r600/r600_state.c      |  6 ++++++
 5 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
index a4a4e3e..065ac6f 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -3769,6 +3769,12 @@ static boolean evergreen_dma_blit(struct pipe_context *ctx,
 	if (rctx->b.rings.dma.cs == NULL) {
 		return FALSE;
 	}
+
+	if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) {
+		evergreen_dma_copy(rctx, dst, src, dst_x, src_box->x, src_box->width);
+		return TRUE;
+	}
+
 	if (src->format != dst->format) {
 		return FALSE;
 	}
diff --git a/src/gallium/drivers/r600/r600_blit.c b/src/gallium/drivers/r600/r600_blit.c
index f33bb43..8680f79 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -599,8 +599,8 @@ static void r600_clear_depth_stencil(struct pipe_context *ctx,
 	r600_blitter_end(ctx);
 }
 
-void r600_copy_buffer(struct pipe_context *ctx, struct pipe_resource *dst, unsigned dstx,
-		      struct pipe_resource *src, const struct pipe_box *src_box)
+static void r600_copy_buffer(struct pipe_context *ctx, struct pipe_resource *dst, unsigned dstx,
+			     struct pipe_resource *src, const struct pipe_box *src_box)
 {
 	struct r600_context *rctx = (struct r600_context*)ctx;
 
diff --git a/src/gallium/drivers/r600/r600_buffer.c b/src/gallium/drivers/r600/r600_buffer.c
index 107538a..8d5c255 100644
--- a/src/gallium/drivers/r600/r600_buffer.c
+++ b/src/gallium/drivers/r600/r600_buffer.c
@@ -196,24 +196,22 @@ static void r600_buffer_transfer_unmap(struct pipe_context *pipe,
 	if (rtransfer->staging) {
 		struct pipe_resource *dst, *src;
 		unsigned soffset, doffset, size;
+		struct pipe_box box;
 
 		dst = transfer->resource;
 		src = &rtransfer->staging->b.b;
 		size = transfer->box.width;
 		doffset = transfer->box.x;
 		soffset = rtransfer->offset + transfer->box.x % R600_MAP_BUFFER_ALIGNMENT;
+
+		u_box_1d(soffset, size, &box);
+
 		/* Copy the staging buffer into the original one. */
-		if (rctx->b.rings.dma.cs && !(size % 4) && !(doffset % 4) && !(soffset % 4)) {
-			if (rctx->screen->b.chip_class >= EVERGREEN) {
-				evergreen_dma_copy(rctx, dst, src, doffset, soffset, size);
-			} else {
-				r600_dma_copy(rctx, dst, src, doffset, soffset, size);
-			}
+		if (!(size % 4) && !(doffset % 4) && !(soffset % 4) &&
+		    rctx->b.dma_copy(pipe, dst, 0, doffset, 0, 0, src, 0, &box)) {
+			/* DONE. */
 		} else {
-			struct pipe_box box;
-
-			u_box_1d(soffset, size, &box);
-			r600_copy_buffer(pipe, dst, doffset, src, &box);
+			pipe->resource_copy_region(pipe, dst, 0, doffset, 0, 0, src, 0, &box);
 		}
 		pipe_resource_reference((struct pipe_resource**)&rtransfer->staging, NULL);
 	}
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
index f0d4be4..d58cd2e 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -598,8 +598,6 @@ void evergreen_init_color_surface_rat(struct r600_context *rctx,
 void evergreen_update_db_shader_control(struct r600_context * rctx);
 
 /* r600_blit.c */
-void r600_copy_buffer(struct pipe_context *ctx, struct pipe_resource *dst, unsigned dstx,
-		      struct pipe_resource *src, const struct pipe_box *src_box);
 void r600_init_blit_functions(struct r600_context *rctx);
 void r600_decompress_depth_textures(struct r600_context *rctx,
 				    struct r600_samplerview_state *textures);
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index 41e9c5d..b938c33 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -3149,6 +3149,12 @@ static boolean r600_dma_blit(struct pipe_context *ctx,
 	if (rctx->b.rings.dma.cs == NULL) {
 		return FALSE;
 	}
+
+	if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) {
+		r600_dma_copy(rctx, dst, src, dst_x, src_box->x, src_box->width);
+		return TRUE;
+	}
+
 	if (src->format != dst->format) {
 		return FALSE;
 	}
-- 
1.8.3.2



More information about the mesa-dev mailing list