summaryrefslogtreecommitdiffstats
path: root/src/vulkan/anv_allocator.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-09-23 14:20:04 -0700
committerJason Ekstrand <[email protected]>2015-09-24 08:41:47 -0700
commit429665823d6f9ed401d9a74cd77877619d0ff782 (patch)
tree2cd0611ceaa7f685991363405d0058b4c40d4d8e /src/vulkan/anv_allocator.c
parent76be58efce858614d10709ac2952329495d1ed8f (diff)
anv/allocator: Do a better job of centering bi-directional block pools
Diffstat (limited to 'src/vulkan/anv_allocator.c')
-rw-r--r--src/vulkan/anv_allocator.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/vulkan/anv_allocator.c b/src/vulkan/anv_allocator.c
index 57b42eb4202..cbd2b6d0f51 100644
--- a/src/vulkan/anv_allocator.c
+++ b/src/vulkan/anv_allocator.c
@@ -388,6 +388,9 @@ anv_block_pool_grow(struct anv_block_pool *pool, struct anv_block_state *state)
*/
center_bo_offset = 0;
} else {
+ /* Try to "center" the allocation based on how much is currently in
+ * use on each side of the center line.
+ */
center_bo_offset = ((uint64_t)size * back_used) / total_used;
/* Align down to a multiple of both the block size and page size */
@@ -396,6 +399,14 @@ anv_block_pool_grow(struct anv_block_pool *pool, struct anv_block_state *state)
center_bo_offset &= ~(granularity - 1);
assert(center_bo_offset >= back_used);
+
+ /* Make sure we don't shrink the back end of the pool */
+ if (center_bo_offset < pool->back_state.end)
+ center_bo_offset = pool->back_state.end;
+
+ /* Make sure that we don't shrink the front end of the pool */
+ if (size - center_bo_offset < pool->state.end)
+ center_bo_offset = size - pool->state.end;
}
assert(center_bo_offset % pool->block_size == 0);
@@ -403,7 +414,7 @@ anv_block_pool_grow(struct anv_block_pool *pool, struct anv_block_state *state)
/* Assert that we only ever grow the pool */
assert(center_bo_offset >= pool->back_state.end);
- assert(size - center_bo_offset >= pool->back_state.end);
+ assert(size - center_bo_offset >= pool->state.end);
cleanup = anv_vector_add(&pool->mmap_cleanups);
if (!cleanup)