[Mesa-dev] [RFC PATCH 06/14] anv/allocator: Add getters for anv_block_pool.

Jason Ekstrand jason at jlekstrand.net
Mon Dec 10 18:45:00 UTC 2018


On Fri, Dec 7, 2018 at 6:06 PM Rafael Antognolli <
rafael.antognolli at intel.com> wrote:

> We will need specially the anv_block_pool_map, to find the
> map relative to some BO that is not at the start of the block pool.
> ---
>  src/intel/vulkan/anv_allocator.c   | 23 ++++++++++++++++++++---
>  src/intel/vulkan/anv_batch_chain.c |  5 +++--
>  src/intel/vulkan/anv_private.h     |  7 +++++++
>  src/intel/vulkan/genX_blorp_exec.c |  5 +++--
>  4 files changed, 33 insertions(+), 7 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_allocator.c
> b/src/intel/vulkan/anv_allocator.c
> index cda6a1a9d25..acf3c80fbac 100644
> --- a/src/intel/vulkan/anv_allocator.c
> +++ b/src/intel/vulkan/anv_allocator.c
> @@ -601,6 +601,15 @@ anv_block_pool_expand_range(struct anv_block_pool
> *pool,
>     return VK_SUCCESS;
>  }
>
> +struct anv_pool_map
> +anv_block_pool_map(struct anv_block_pool *pool, int32_t offset)
> +{
> +   return (struct anv_pool_map) {
> +      .map = pool->map,
> +      .offset = offset,
> +   };
>

Every caller of this function adds the two together.  Why not just return
the ofsetted pointer?


> +}
> +
>  /** Grows and re-centers the block pool.
>   *
>   * We grow the block pool in one or both directions in such a way that the
> @@ -967,7 +976,9 @@ anv_state_pool_alloc_no_vg(struct anv_state_pool *pool,
>                                                                 st_idx +
> i);
>                 state_i->alloc_size = pool->block_size;
>                 state_i->offset = chunk_offset + pool->block_size * (i +
> 1);
> -               state_i->map = pool->block_pool.map + state_i->offset;
> +               struct anv_pool_map pool_map =
> anv_block_pool_map(&pool->block_pool,
> +
>  state_i->offset);
> +               state_i->map = pool_map.map + pool_map.offset;
>              }
>              anv_state_table_push(&pool->buckets[block_bucket].free_list,
>                                   &pool->table, st_idx, push_back);
> @@ -983,7 +994,9 @@ anv_state_pool_alloc_no_vg(struct anv_state_pool *pool,
>                                                              st_idx + i);
>              state_i->alloc_size = alloc_size;
>              state_i->offset = chunk_offset + alloc_size * (i + 1);
> -            state_i->map = pool->block_pool.map + state_i->offset;
> +            struct anv_pool_map pool_map =
> anv_block_pool_map(&pool->block_pool,
> +
> state_i->offset);
> +            state_i->map = pool_map.map + pool_map.offset;
>           }
>           anv_state_table_push(&pool->buckets[bucket].free_list,
>                                &pool->table, st_idx, push_back);
> @@ -1002,7 +1015,11 @@ anv_state_pool_alloc_no_vg(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 + offset;
> +
> +   struct anv_pool_map pool_map = anv_block_pool_map(&pool->block_pool,
> +                                                     state->offset);
> +   state->map = pool_map.map + pool_map.offset;
> +
>
>  done:
>     return *state;
> diff --git a/src/intel/vulkan/anv_batch_chain.c
> b/src/intel/vulkan/anv_batch_chain.c
> index a9f8c5b79b1..6c06858efe1 100644
> --- a/src/intel/vulkan/anv_batch_chain.c
> +++ b/src/intel/vulkan/anv_batch_chain.c
> @@ -679,8 +679,9 @@ 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;
> +   struct anv_pool_map pool_map =
> +      anv_block_pool_map(&anv_binding_table_pool(device)->block_pool,
> bt_block->offset + state.offset);
> +   state.map = pool_map.map + pool_map.offset;
>
>     cmd_buffer->bt_next += state.alloc_size;
>
> diff --git a/src/intel/vulkan/anv_private.h
> b/src/intel/vulkan/anv_private.h
> index 539523450ef..a364be8dad5 100644
> --- a/src/intel/vulkan/anv_private.h
> +++ b/src/intel/vulkan/anv_private.h
> @@ -749,6 +749,11 @@ struct anv_state_stream {
>     struct anv_state_stream_block *block_list;
>  };
>
> +struct anv_pool_map {
> +   void *map;
> +   int32_t offset;
> +};
> +
>  /* The block_pool functions exported for testing only.  The block pool
> should
>   * only be used via a state pool (see below).
>   */
> @@ -762,6 +767,8 @@ 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);
> +struct anv_pool_map 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,
> diff --git a/src/intel/vulkan/genX_blorp_exec.c
> b/src/intel/vulkan/genX_blorp_exec.c
> index c573e890946..5af6abb0894 100644
> --- a/src/intel/vulkan/genX_blorp_exec.c
> +++ b/src/intel/vulkan/genX_blorp_exec.c
> @@ -63,8 +63,9 @@ 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;
> +   struct anv_pool_map pool_map = anv_block_pool_map(
> +      &cmd_buffer->device->surface_state_pool.block_pool, ss_offset);
> +   void *dest = pool_map.map + pool_map.offset;
>     uint64_t val = ((struct anv_bo*)address.buffer)->offset +
> address.offset +
>        delta;
>     write_reloc(cmd_buffer->device, dest, val, false);
> --
> 2.17.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20181210/2a1e7026/attachment-0001.html>


More information about the mesa-dev mailing list