mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 15:40:11 +01:00
vk/allocator: Assert that block_pool_grow succeeds
This commit is contained in:
parent
28804fb9e4
commit
682d11a6e8
1 changed files with 7 additions and 2 deletions
|
|
@ -313,20 +313,25 @@ anv_block_pool_alloc(struct anv_block_pool *pool)
|
||||||
uint32_t offset, block, size;
|
uint32_t offset, block, size;
|
||||||
|
|
||||||
/* Try free list first. */
|
/* Try free list first. */
|
||||||
if (anv_free_list_pop(&pool->free_list, &pool->map, &offset))
|
if (anv_free_list_pop(&pool->free_list, &pool->map, &offset)) {
|
||||||
|
assert(pool->map);
|
||||||
return offset;
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
size = pool->size;
|
size = pool->size;
|
||||||
block = __sync_fetch_and_add(&pool->next_block, pool->block_size);
|
block = __sync_fetch_and_add(&pool->next_block, pool->block_size);
|
||||||
if (block < size) {
|
if (block < size) {
|
||||||
|
assert(pool->map);
|
||||||
return block;
|
return block;
|
||||||
} else if (block == size) {
|
} else if (block == size) {
|
||||||
/* We allocated the first block outside the pool, we have to grow it.
|
/* We allocated the first block outside the pool, we have to grow it.
|
||||||
* pool->next_block acts a mutex: threads who try to allocate now will
|
* pool->next_block acts a mutex: threads who try to allocate now will
|
||||||
* get block indexes above the current limit and hit futex_wait
|
* get block indexes above the current limit and hit futex_wait
|
||||||
* below. */
|
* below. */
|
||||||
anv_block_pool_grow(pool);
|
int err = anv_block_pool_grow(pool);
|
||||||
|
assert(err == 0);
|
||||||
|
(void) err;
|
||||||
futex_wake(&pool->size, INT_MAX);
|
futex_wake(&pool->size, INT_MAX);
|
||||||
} else {
|
} else {
|
||||||
futex_wait(&pool->size, size);
|
futex_wait(&pool->size, size);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue