diff options
author | Rafael Antognolli <[email protected]> | 2018-12-04 15:37:33 -0800 |
---|---|---|
committer | Rafael Antognolli <[email protected]> | 2019-01-17 15:08:19 -0800 |
commit | dfc9ab2ccd93863387073e7eb5c50c29f0abb68f (patch) | |
tree | 59b7509c9c9f043e4aa851da9e600f836e4554f7 /src/intel/vulkan/tests | |
parent | 7ed0898a8d43340011095586af3be53380bb084c (diff) |
anv/allocator: Add padding information.
It's possible that we still have some space left in the block pool, but
we try to allocate a state larger than that state. This means such state
would start somewhere within the range of the old block_pool, and end
after that range, within the range of the new size.
That's fine when we use userptr, since the memory in the block pool is
CPU mapped continuously. However, by the end of this series, we will
have the block_pool split into different BOs, with different CPU
mapping ranges that are not necessarily continuous. So we must avoid
such case of a given state being part of two different BOs in the block
pool.
This commit solves the issue by detecting that we are growing the
block_pool even though we are not at the end of the range. If that
happens, we don't use the space left at the end of the old size, and
consider it as "padding" that can't be used in the allocation. We update
the size requested from the block pool to take the padding into account,
and return the offset after the padding, which happens to be at the
start of the new address range.
Additionally, we return the amount of padding we used, so the caller
knows that this happens and can return that padding back into a list of
free states, that can be reused later. This way we hopefully don't waste
any space, but also avoid having a state split between two different
BOs.
v3:
- Calculate offset + padding at anv_block_pool_alloc_new (Jason).
v4:
- Remove extra "leftover".
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/intel/vulkan/tests')
-rw-r--r-- | src/intel/vulkan/tests/block_pool_no_free.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/intel/vulkan/tests/block_pool_no_free.c b/src/intel/vulkan/tests/block_pool_no_free.c index 9cd3e83b462..dd1856ea714 100644 --- a/src/intel/vulkan/tests/block_pool_no_free.c +++ b/src/intel/vulkan/tests/block_pool_no_free.c @@ -46,7 +46,7 @@ static void *alloc_blocks(void *_job) int32_t block, *data; for (unsigned i = 0; i < BLOCKS_PER_THREAD; i++) { - block = anv_block_pool_alloc(job->pool, block_size); + block = anv_block_pool_alloc(job->pool, block_size, NULL); data = anv_block_pool_map(job->pool, block); *data = block; assert(block >= 0); |