summaryrefslogtreecommitdiffstats
path: root/src/intel/vulkan/anv_allocator.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-04-23 19:15:42 -0700
committerJason Ekstrand <[email protected]>2017-05-04 19:07:54 -0700
commit8769fb48fb97731a8dc8fd6758834a9a1df22b75 (patch)
tree713c0adac60a31ea6f59169892ace7ba83312a1d /src/intel/vulkan/anv_allocator.c
parent12043ca6968f53970669586eca2f97baf8ea264a (diff)
anv/allocator: Add helpers for dealing with bucket sizes
Reviewed-by: Juan A. Suarez Romero <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_allocator.c')
-rw-r--r--src/intel/vulkan/anv_allocator.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c
index 66c68affc97..fb283cc25d3 100644
--- a/src/intel/vulkan/anv_allocator.c
+++ b/src/intel/vulkan/anv_allocator.c
@@ -671,18 +671,31 @@ anv_fixed_size_state_pool_alloc_new(struct anv_fixed_size_state_pool *pool,
}
}
-static struct anv_state
-anv_state_pool_alloc_no_vg(struct anv_state_pool *pool,
- uint32_t size, uint32_t align)
+static uint32_t
+anv_state_pool_get_bucket(uint32_t size)
{
- unsigned size_log2 = ilog2_round_up(size < align ? align : size);
+ unsigned size_log2 = ilog2_round_up(size);
assert(size_log2 <= ANV_MAX_STATE_SIZE_LOG2);
if (size_log2 < ANV_MIN_STATE_SIZE_LOG2)
size_log2 = ANV_MIN_STATE_SIZE_LOG2;
- unsigned bucket = size_log2 - ANV_MIN_STATE_SIZE_LOG2;
+ return size_log2 - ANV_MIN_STATE_SIZE_LOG2;
+}
+
+static uint32_t
+anv_state_pool_get_bucket_size(uint32_t bucket)
+{
+ uint32_t size_log2 = bucket + ANV_MIN_STATE_SIZE_LOG2;
+ return 1 << size_log2;
+}
+
+static struct anv_state
+anv_state_pool_alloc_no_vg(struct anv_state_pool *pool,
+ uint32_t size, uint32_t align)
+{
+ uint32_t bucket = anv_state_pool_get_bucket(MAX2(size, align));
struct anv_state state;
- state.alloc_size = 1 << size_log2;
+ state.alloc_size = anv_state_pool_get_bucket_size(bucket);
/* Try free list first. */
if (anv_free_list_pop(&pool->buckets[bucket].free_list,
@@ -737,10 +750,7 @@ static void
anv_state_pool_free_no_vg(struct anv_state_pool *pool, struct anv_state state)
{
assert(util_is_power_of_two(state.alloc_size));
- unsigned size_log2 = ilog2_round_up(state.alloc_size);
- assert(size_log2 >= ANV_MIN_STATE_SIZE_LOG2 &&
- size_log2 <= ANV_MAX_STATE_SIZE_LOG2);
- unsigned bucket = size_log2 - ANV_MIN_STATE_SIZE_LOG2;
+ unsigned bucket = anv_state_pool_get_bucket(state.alloc_size);
if (state.offset < 0) {
assert(state.alloc_size == pool->block_size);