summaryrefslogtreecommitdiffstats
path: root/src/intel/vulkan
diff options
context:
space:
mode:
authorRafael Antognolli <[email protected]>2018-12-11 15:37:15 -0800
committerRafael Antognolli <[email protected]>2019-01-17 15:07:47 -0800
commit6a1dcfe73d070d42f19b1450b883e345c5aa001a (patch)
tree479b870d9c3d8681fef656c2a356dccda8e1c4da /src/intel/vulkan
parente8b6e0a5ba888d2b5d188cf06d962b6d8bc35332 (diff)
anv/allocator: Add helper to push states back to the state table.
The use of anv_state_table_add() combined with anv_state_table_push(), specially when adding a bunch of states to the table, is very verbose. So we add this helper that makes things easier to digest. We also already add the anv_state_table member in this commit, so things can compile properly, even though it's not used. v2: assert that the states are always aligned to their size (Jason) v3: Add "table" member to anv_state_pool in this commit. Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/intel/vulkan')
-rw-r--r--src/intel/vulkan/anv_allocator.c33
-rw-r--r--src/intel/vulkan/anv_private.h2
2 files changed, 35 insertions, 0 deletions
diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c
index e4b8dd56811..ce481fb45f1 100644
--- a/src/intel/vulkan/anv_allocator.c
+++ b/src/intel/vulkan/anv_allocator.c
@@ -948,6 +948,39 @@ anv_state_pool_get_bucket_size(uint32_t bucket)
return 1 << size_log2;
}
+/** Helper to push a chunk into the state table.
+ *
+ * It creates 'count' entries into the state table and update their sizes,
+ * offsets and maps, also pushing them as "free" states.
+ */
+static void
+anv_state_pool_return_blocks(struct anv_state_pool *pool,
+ uint32_t chunk_offset, uint32_t count,
+ uint32_t block_size)
+{
+ if (count == 0)
+ return;
+
+ /* Make sure we always return chunks aligned to the block_size */
+ assert(chunk_offset % block_size == 0);
+
+ uint32_t st_idx;
+ VkResult result = anv_state_table_add(&pool->table, &st_idx, count);
+ assert(result == VK_SUCCESS);
+ for (int i = 0; i < count; i++) {
+ /* update states that were added back to the state table */
+ struct anv_state *state_i = anv_state_table_get(&pool->table,
+ st_idx + i);
+ state_i->alloc_size = block_size;
+ state_i->offset = chunk_offset + block_size * i;
+ state_i->map = anv_block_pool_map(&pool->block_pool, state_i->offset);
+ }
+
+ uint32_t block_bucket = anv_state_pool_get_bucket(block_size);
+ anv_free_list_push2(&pool->buckets[block_bucket].free_list,
+ &pool->table, st_idx, count);
+}
+
static struct anv_state
anv_state_pool_alloc_no_vg(struct anv_state_pool *pool,
uint32_t size, uint32_t align)
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 129dd141d61..bdbd4aad7f4 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -731,6 +731,8 @@ struct anv_state_table {
struct anv_state_pool {
struct anv_block_pool block_pool;
+ struct anv_state_table table;
+
/* The size of blocks which will be allocated from the block pool */
uint32_t block_size;