anv/allocator: Add getter for anv_block_pool.
authorRafael Antognolli <rafael.antognolli@intel.com>
Wed, 21 Nov 2018 19:24:59 +0000 (11:24 -0800)
committerRafael Antognolli <rafael.antognolli@intel.com>
Thu, 17 Jan 2019 23:07:43 +0000 (15:07 -0800)
We will need the anv_block_pool_map to find the map relative to some BO
that is not at the start of the block pool.

v2: just return a pointer instead of a struct (Jason)
v4: Update comment (Jason)

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/vulkan/anv_allocator.c
src/intel/vulkan/anv_batch_chain.c
src/intel/vulkan/anv_private.h
src/intel/vulkan/genX_blorp_exec.c

index 04ef05f5fae6bd56419489f1ea860f688857a6df..e4b8dd56811f3e3435e75999ca95106bd3cac938 100644 (file)
@@ -652,6 +652,18 @@ anv_block_pool_expand_range(struct anv_block_pool *pool,
    return VK_SUCCESS;
 }
 
+/** Returns current memory map of the block pool.
+ *
+ * The returned pointer points to the map for the memory at the specified
+ * offset. The offset parameter is relative to the "center" of the block pool
+ * rather than the start of the block pool BO map.
+ */
+void*
+anv_block_pool_map(struct anv_block_pool *pool, int32_t offset)
+{
+   return pool->map + offset;
+}
+
 /** Grows and re-centers the block pool.
  *
  * We grow the block pool in one or both directions in such a way that the
@@ -1021,7 +1033,7 @@ anv_state_pool_alloc_no_vg(struct anv_state_pool *pool,
                                                       pool->block_size);
 
 done:
-   state.map = pool->block_pool.map + state.offset;
+   state.map = anv_block_pool_map(&pool->block_pool, state.offset);
    return state;
 }
 
index a41305bc6d134d5f2f9b55a6b43fc5bdc7a393d8..c5f05e5a256313ecfe4f118cc5ddd697c66ac685 100644 (file)
@@ -678,8 +678,8 @@ anv_cmd_buffer_alloc_binding_table(struct anv_cmd_buffer *cmd_buffer,
       return (struct anv_state) { 0 };
 
    state.offset = cmd_buffer->bt_next;
-   state.map = anv_binding_table_pool(device)->block_pool.map +
-      bt_block->offset + state.offset;
+   state.map = anv_block_pool_map(&anv_binding_table_pool(device)->block_pool,
+                                  bt_block->offset + state.offset);
 
    cmd_buffer->bt_next += state.alloc_size;
 
index d88cb54aaf7e72d794c522f32b5a8c38ab51fd2f..129dd141d61fb22e14532fa7a15ce5d94156ac92 100644 (file)
@@ -771,6 +771,7 @@ int32_t anv_block_pool_alloc(struct anv_block_pool *pool,
                              uint32_t block_size);
 int32_t anv_block_pool_alloc_back(struct anv_block_pool *pool,
                                   uint32_t block_size);
+void* anv_block_pool_map(struct anv_block_pool *pool, int32_t offset);
 
 VkResult anv_state_pool_init(struct anv_state_pool *pool,
                              struct anv_device *device,
index f5e9e424eb9ef2ac638a161ef13e14caa6e1ca12..1782125ab5dab029455181265c76b510d1cdd8b6 100644 (file)
@@ -63,8 +63,8 @@ blorp_surface_reloc(struct blorp_batch *batch, uint32_t ss_offset,
    if (result != VK_SUCCESS)
       anv_batch_set_error(&cmd_buffer->batch, result);
 
-   void *dest = cmd_buffer->device->surface_state_pool.block_pool.map +
-      ss_offset;
+   void *dest = anv_block_pool_map(
+      &cmd_buffer->device->surface_state_pool.block_pool, ss_offset);
    uint64_t val = ((struct anv_bo*)address.buffer)->offset + address.offset +
       delta;
    write_reloc(cmd_buffer->device, dest, val, false);