diff options
author | Jason Ekstrand <[email protected]> | 2015-09-15 17:46:09 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-09-17 17:44:20 -0700 |
commit | 5f57ff7e18c1c545aafcdc267bc22594cef81d3c (patch) | |
tree | 6536d4e30554c531e6c1d23a682c687dd4abdbc3 /src/vulkan/tests | |
parent | 15624fcf55bff9d16f3eaa461e4a3010bbe0e4ba (diff) |
anv/allocator: Make the block pool double-ended
This allows us to allocate from either side of the block pool in a
consistent way. If you use the previous block_pool_alloc function, you
will get offsets from the start of the pool as normal. If you use the new
block_pool_alloc_back function, you will get a negative index that
corresponds to something in the "back" of the pool.
Diffstat (limited to 'src/vulkan/tests')
-rw-r--r-- | src/vulkan/tests/block_pool_no_free.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/vulkan/tests/block_pool_no_free.c b/src/vulkan/tests/block_pool_no_free.c index 71eb90103ef..01c23e21b2d 100644 --- a/src/vulkan/tests/block_pool_no_free.c +++ b/src/vulkan/tests/block_pool_no_free.c @@ -34,14 +34,18 @@ struct job { unsigned id; struct anv_block_pool *pool; uint32_t blocks[BLOCKS_PER_THREAD]; + uint32_t back_blocks[BLOCKS_PER_THREAD]; } jobs[NUM_THREADS]; + static void *alloc_blocks(void *_job) { struct job *job = _job; - for (unsigned i = 0; i < BLOCKS_PER_THREAD; i++) + for (unsigned i = 0; i < BLOCKS_PER_THREAD; i++) { job->blocks[i] = anv_block_pool_alloc(job->pool); + job->back_blocks[i] = -anv_block_pool_alloc_back(job->pool); + } return NULL; } @@ -98,10 +102,15 @@ static void run_test() for (unsigned i = 0; i < NUM_THREADS; i++) pthread_join(jobs[i].thread, NULL); + /* Validate that the block allocations were monotonic */ uint32_t *block_ptrs[NUM_THREADS]; for (unsigned i = 0; i < NUM_THREADS; i++) block_ptrs[i] = jobs[i].blocks; + validate_monotonic(block_ptrs); + /* Validate that the back block allocations were monotonic */ + for (unsigned i = 0; i < NUM_THREADS; i++) + block_ptrs[i] = jobs[i].back_blocks; validate_monotonic(block_ptrs); anv_block_pool_finish(&pool); |