#endif
/* Now that we successfull allocated everything, we can write the new
- * values back into pool. */
- pool->map = map + center_bo_offset;
+ * center_bo_offset back into pool. */
pool->center_bo_offset = center_bo_offset;
/* For block pool BOs we have to be a bit careful about where we place them
void*
anv_block_pool_map(struct anv_block_pool *pool, int32_t offset)
{
- return pool->map + offset;
+ return pool->bo.map + pool->center_bo_offset + offset;
}
/** Grows and re-centers the block pool.
while (1) {
state.u64 = __sync_fetch_and_add(&pool_state->u64, block_size);
if (state.next + block_size <= state.end) {
- assert(pool->map);
return state.next;
} else if (state.next <= state.end) {
/* We allocated the first block outside the pool so we have to grow
state = anv_state_table_get(&pool->table, idx);
state->offset = offset;
state->alloc_size = alloc_size;
- state->map = pool->block_pool.map + state->offset;
+ state->map = anv_block_pool_map(&pool->block_pool, state->offset);
done:
VG(VALGRIND_MEMPOOL_ALLOC(pool, state->map, state->alloc_size));
*/
uint32_t center_bo_offset;
- /* Current memory map of the block pool. This pointer may or may not
- * point to the actual beginning of the block pool memory. If
- * anv_block_pool_alloc_back has ever been called, then this pointer
- * will point to the "center" position of the buffer and all offsets
- * (negative or positive) given out by the block pool alloc functions
- * will be valid relative to this pointer.
- *
- * In particular, map == bo.map + center_offset
- */
- void *map;
int fd;
/**
for (unsigned i = 0; i < BLOCKS_PER_THREAD; i++) {
block = anv_block_pool_alloc(job->pool, block_size);
- data = job->pool->map + block;
+ data = anv_block_pool_map(job->pool, block);
*data = block;
assert(block >= 0);
job->blocks[i] = block;
block = anv_block_pool_alloc_back(job->pool, block_size);
- data = job->pool->map + block;
+ data = anv_block_pool_map(job->pool, block);
*data = block;
assert(block < 0);
job->back_blocks[i] = -block;
for (unsigned i = 0; i < BLOCKS_PER_THREAD; i++) {
block = job->blocks[i];
- data = job->pool->map + block;
+ data = anv_block_pool_map(job->pool, block);
assert(*data == block);
block = -job->back_blocks[i];
- data = job->pool->map + block;
+ data = anv_block_pool_map(job->pool, block);
assert(*data == block);
}