<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Fri, Dec 7, 2018 at 6:06 PM Rafael Antognolli <<a href="mailto:rafael.antognolli@intel.com">rafael.antognolli@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">We will need specially the anv_block_pool_map, to find the<br>
map relative to some BO that is not at the start of the block pool.<br>
---<br>
src/intel/vulkan/anv_allocator.c | 23 ++++++++++++++++++++---<br>
src/intel/vulkan/anv_batch_chain.c | 5 +++--<br>
src/intel/vulkan/anv_private.h | 7 +++++++<br>
src/intel/vulkan/genX_blorp_exec.c | 5 +++--<br>
4 files changed, 33 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c<br>
index cda6a1a9d25..acf3c80fbac 100644<br>
--- a/src/intel/vulkan/anv_allocator.c<br>
+++ b/src/intel/vulkan/anv_allocator.c<br>
@@ -601,6 +601,15 @@ anv_block_pool_expand_range(struct anv_block_pool *pool,<br>
return VK_SUCCESS;<br>
}<br>
<br>
+struct anv_pool_map<br>
+anv_block_pool_map(struct anv_block_pool *pool, int32_t offset)<br>
+{<br>
+ return (struct anv_pool_map) {<br>
+ .map = pool->map,<br>
+ .offset = offset,<br>
+ };<br></blockquote><div><br></div><div>Every caller of this function adds the two together. Why not just return the ofsetted pointer?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+}<br>
+<br>
/** Grows and re-centers the block pool.<br>
*<br>
* We grow the block pool in one or both directions in such a way that the<br>
@@ -967,7 +976,9 @@ anv_state_pool_alloc_no_vg(struct anv_state_pool *pool,<br>
st_idx + i);<br>
state_i->alloc_size = pool->block_size;<br>
state_i->offset = chunk_offset + pool->block_size * (i + 1);<br>
- state_i->map = pool->block_pool.map + state_i->offset;<br>
+ struct anv_pool_map pool_map = anv_block_pool_map(&pool->block_pool,<br>
+ state_i->offset);<br>
+ state_i->map = pool_map.map + pool_map.offset;<br>
}<br>
anv_state_table_push(&pool->buckets[block_bucket].free_list,<br>
&pool->table, st_idx, push_back);<br>
@@ -983,7 +994,9 @@ anv_state_pool_alloc_no_vg(struct anv_state_pool *pool,<br>
st_idx + i);<br>
state_i->alloc_size = alloc_size;<br>
state_i->offset = chunk_offset + alloc_size * (i + 1);<br>
- state_i->map = pool->block_pool.map + state_i->offset;<br>
+ struct anv_pool_map pool_map = anv_block_pool_map(&pool->block_pool,<br>
+ state_i->offset);<br>
+ state_i->map = pool_map.map + pool_map.offset;<br>
}<br>
anv_state_table_push(&pool->buckets[bucket].free_list,<br>
&pool->table, st_idx, push_back);<br>
@@ -1002,7 +1015,11 @@ anv_state_pool_alloc_no_vg(struct anv_state_pool *pool,<br>
state = anv_state_table_get(&pool->table, idx);<br>
state->offset = offset;<br>
state->alloc_size = alloc_size;<br>
- state->map = pool->block_pool.map + offset;<br>
+<br>
+ struct anv_pool_map pool_map = anv_block_pool_map(&pool->block_pool,<br>
+ state->offset);<br>
+ state->map = pool_map.map + pool_map.offset;<br>
+<br>
<br>
done:<br>
return *state;<br>
diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c<br>
index a9f8c5b79b1..6c06858efe1 100644<br>
--- a/src/intel/vulkan/anv_batch_chain.c<br>
+++ b/src/intel/vulkan/anv_batch_chain.c<br>
@@ -679,8 +679,9 @@ anv_cmd_buffer_alloc_binding_table(struct anv_cmd_buffer *cmd_buffer,<br>
return (struct anv_state) { 0 };<br>
<br>
state.offset = cmd_buffer->bt_next;<br>
- state.map = anv_binding_table_pool(device)->block_pool.map +<br>
- bt_block->offset + state.offset;<br>
+ struct anv_pool_map pool_map =<br>
+ anv_block_pool_map(&anv_binding_table_pool(device)->block_pool, bt_block->offset + state.offset);<br>
+ state.map = pool_map.map + pool_map.offset;<br>
<br>
cmd_buffer->bt_next += state.alloc_size;<br>
<br>
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h<br>
index 539523450ef..a364be8dad5 100644<br>
--- a/src/intel/vulkan/anv_private.h<br>
+++ b/src/intel/vulkan/anv_private.h<br>
@@ -749,6 +749,11 @@ struct anv_state_stream {<br>
struct anv_state_stream_block *block_list;<br>
};<br>
<br>
+struct anv_pool_map {<br>
+ void *map;<br>
+ int32_t offset;<br>
+};<br>
+<br>
/* The block_pool functions exported for testing only. The block pool should<br>
* only be used via a state pool (see below).<br>
*/<br>
@@ -762,6 +767,8 @@ int32_t anv_block_pool_alloc(struct anv_block_pool *pool,<br>
uint32_t block_size);<br>
int32_t anv_block_pool_alloc_back(struct anv_block_pool *pool,<br>
uint32_t block_size);<br>
+struct anv_pool_map anv_block_pool_map(struct anv_block_pool *pool,<br>
+ int32_t offset);<br>
<br>
VkResult anv_state_pool_init(struct anv_state_pool *pool,<br>
struct anv_device *device,<br>
diff --git a/src/intel/vulkan/genX_blorp_exec.c b/src/intel/vulkan/genX_blorp_exec.c<br>
index c573e890946..5af6abb0894 100644<br>
--- a/src/intel/vulkan/genX_blorp_exec.c<br>
+++ b/src/intel/vulkan/genX_blorp_exec.c<br>
@@ -63,8 +63,9 @@ blorp_surface_reloc(struct blorp_batch *batch, uint32_t ss_offset,<br>
if (result != VK_SUCCESS)<br>
anv_batch_set_error(&cmd_buffer->batch, result);<br>
<br>
- void *dest = cmd_buffer->device->surface_state_pool.block_pool.map +<br>
- ss_offset;<br>
+ struct anv_pool_map pool_map = anv_block_pool_map(<br>
+ &cmd_buffer->device->surface_state_pool.block_pool, ss_offset);<br>
+ void *dest = pool_map.map + pool_map.offset;<br>
uint64_t val = ((struct anv_bo*)address.buffer)->offset + address.offset +<br>
delta;<br>
write_reloc(cmd_buffer->device, dest, val, false);<br>
-- <br>
2.17.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div></div>