Mesa (master): anv/allocator: Remove pool->map.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jan 17 23:12:26 UTC 2019
Module: Mesa
Branch: master
Commit: fc3f58832015cbb177179e7f3420d3611479b4a9
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fc3f58832015cbb177179e7f3420d3611479b4a9
Author: Rafael Antognolli <rafael.antognolli at intel.com>
Date: Wed Dec 19 10:26:44 2018 -0800
anv/allocator: Remove pool->map.
After switching to using anv_state_table, there are very few places left
still using pool->map directly. We want to avoid that because it won't
be always the right map once we split it into multiple BOs.
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
---
src/intel/vulkan/anv_allocator.c | 8 +++-----
src/intel/vulkan/anv_private.h | 10 ----------
src/intel/vulkan/tests/block_pool_no_free.c | 8 ++++----
3 files changed, 7 insertions(+), 19 deletions(-)
diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c
index 05179d39e2..35ef41f5bb 100644
--- a/src/intel/vulkan/anv_allocator.c
+++ b/src/intel/vulkan/anv_allocator.c
@@ -556,8 +556,7 @@ anv_block_pool_expand_range(struct anv_block_pool *pool,
#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
@@ -605,7 +604,7 @@ anv_block_pool_expand_range(struct anv_block_pool *pool,
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.
@@ -751,7 +750,6 @@ anv_block_pool_alloc_new(struct anv_block_pool *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
@@ -1061,7 +1059,7 @@ anv_state_pool_alloc_back(struct anv_state_pool *pool)
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));
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 1321e6b280..9df5f87594 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -647,16 +647,6 @@ struct anv_block_pool {
*/
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;
/**
diff --git a/src/intel/vulkan/tests/block_pool_no_free.c b/src/intel/vulkan/tests/block_pool_no_free.c
index 787abf0582..9cd3e83b46 100644
--- a/src/intel/vulkan/tests/block_pool_no_free.c
+++ b/src/intel/vulkan/tests/block_pool_no_free.c
@@ -47,13 +47,13 @@ static void *alloc_blocks(void *_job)
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;
@@ -61,11 +61,11 @@ static void *alloc_blocks(void *_job)
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);
}
More information about the mesa-commit
mailing list