Mesa (master): r600g/compute: align items correctly

Tom Stellard tstellar at kemper.freedesktop.org
Tue Jun 10 19:31:04 UTC 2014


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

Author: Bruno Jiménez <brunojimen at gmail.com>
Date:   Mon May 19 18:14:56 2014 +0200

r600g/compute: align items correctly

Now, items whose size is a multiple of 1024 dw won't leave
1024 dw between itself and the following item

The rest of the cases is left as it was

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

---

 src/gallium/drivers/r600/compute_memory_pool.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/r600/compute_memory_pool.c b/src/gallium/drivers/r600/compute_memory_pool.c
index 01851ad..2050f28 100644
--- a/src/gallium/drivers/r600/compute_memory_pool.c
+++ b/src/gallium/drivers/r600/compute_memory_pool.c
@@ -30,6 +30,7 @@
 #include "util/u_transfer.h"
 #include "util/u_surface.h"
 #include "util/u_pack_color.h"
+#include "util/u_math.h"
 #include "util/u_memory.h"
 #include "util/u_inlines.h"
 #include "util/u_framebuffer.h"
@@ -41,6 +42,7 @@
 #include "evergreen_compute_internal.h"
 #include <inttypes.h>
 
+#define ITEM_ALIGNMENT 1024
 /**
  * Creates a new pool
  */
@@ -112,8 +114,7 @@ int64_t compute_memory_prealloc_chunk(
 				return last_end;
 			}
 
-			last_end = item->start_in_dw + item->size_in_dw;
-			last_end += (1024 - last_end % 1024);
+			last_end = item->start_in_dw + align(item->size_in_dw, ITEM_ALIGNMENT);
 		}
 	}
 
@@ -177,7 +178,7 @@ int compute_memory_grow_pool(struct compute_memory_pool* pool,
 		if (pool->shadow == NULL)
 			return -1;
 	} else {
-		new_size_in_dw += 1024 - (new_size_in_dw % 1024);
+		new_size_in_dw = align(new_size_in_dw, ITEM_ALIGNMENT);
 
 		COMPUTE_DBG(pool->screen, "  Aligned size = %d (%d bytes)\n",
 			new_size_in_dw, new_size_in_dw * 4);
@@ -323,7 +324,7 @@ int compute_memory_finalize_pending(struct compute_memory_pool* pool,
 				need = pool->size_in_dw / 10;
 			}
 
-			need += 1024 - (need % 1024);
+			need = align(need, ITEM_ALIGNMENT);
 
 			err = compute_memory_grow_pool(pool,
 					pipe,




More information about the mesa-commit mailing list