Mesa (master): r600g/compute: Allow compute_memory_defrag to defragment between resources

Tom Stellard tstellar at kemper.freedesktop.org
Fri Jul 25 16:43:38 UTC 2014


Module: Mesa
Branch: master
Commit: d6b89aef26cfe0d2b76132102bc986cecb2f80d8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d6b89aef26cfe0d2b76132102bc986cecb2f80d8

Author: Bruno Jiménez <brunojimen at gmail.com>
Date:   Sat Jul 19 19:35:50 2014 +0200

r600g/compute: Allow compute_memory_defrag to defragment between resources

This will be used in the following patch to avoid duplicated code

Reviewed-by: Tom Stellard <thomas.stellard at amd.com>

---

 src/gallium/drivers/r600/compute_memory_pool.c |   11 ++++++-----
 src/gallium/drivers/r600/compute_memory_pool.h |    1 +
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/r600/compute_memory_pool.c b/src/gallium/drivers/r600/compute_memory_pool.c
index 1c75dd9..a66ead5 100644
--- a/src/gallium/drivers/r600/compute_memory_pool.c
+++ b/src/gallium/drivers/r600/compute_memory_pool.c
@@ -268,7 +268,8 @@ int compute_memory_finalize_pending(struct compute_memory_pool* pool,
 	}
 
 	if (pool->status & POOL_FRAGMENTED) {
-		compute_memory_defrag(pool, pipe);
+		struct pipe_resource *src = (struct pipe_resource *)pool->bo;
+		compute_memory_defrag(pool, src, src, pipe);
 	}
 
 	if (pool->size_in_dw < allocated + unallocated) {
@@ -303,20 +304,20 @@ int compute_memory_finalize_pending(struct compute_memory_pool* pool,
  * \param pool	The pool to be defragmented
  */
 void compute_memory_defrag(struct compute_memory_pool *pool,
+	struct pipe_resource *src, struct pipe_resource *dst,
 	struct pipe_context *pipe)
 {
 	struct compute_memory_item *item;
-	struct pipe_resource *src = (struct pipe_resource *)pool->bo;
 	int64_t last_pos;
 
 	COMPUTE_DBG(pool->screen, "* compute_memory_defrag()\n");
 
 	last_pos = 0;
 	LIST_FOR_EACH_ENTRY(item, pool->item_list, link) {
-		if (item->start_in_dw != last_pos) {
-			assert(last_pos < item->start_in_dw);
+		if (src != dst || item->start_in_dw != last_pos) {
+			assert(last_pos <= item->start_in_dw);
 
-			compute_memory_move_item(pool, src, src,
+			compute_memory_move_item(pool, src, dst,
 					item, last_pos, pipe);
 		}
 
diff --git a/src/gallium/drivers/r600/compute_memory_pool.h b/src/gallium/drivers/r600/compute_memory_pool.h
index 822bfbe..5f1d72b 100644
--- a/src/gallium/drivers/r600/compute_memory_pool.h
+++ b/src/gallium/drivers/r600/compute_memory_pool.h
@@ -91,6 +91,7 @@ int compute_memory_finalize_pending(struct compute_memory_pool* pool,
 	struct pipe_context * pipe);
 
 void compute_memory_defrag(struct compute_memory_pool *pool,
+	struct pipe_resource *src, struct pipe_resource *dst,
 	struct pipe_context *pipe);
 
 int compute_memory_promote_item(struct compute_memory_pool *pool,




More information about the mesa-commit mailing list