diff options
author | Jordan Justen <[email protected]> | 2018-04-01 13:57:13 -0700 |
---|---|---|
committer | Jordan Justen <[email protected]> | 2019-10-28 00:09:13 -0700 |
commit | 062022f2e4bc3024553db897e3984d1a16b28239 (patch) | |
tree | 1f74f8549d8859548cbe16e41accb4fc87a6a196 /src/intel/vulkan/anv_device.c | |
parent | c848ab45f3d27d7d20845f9fec49122f76fafeb5 (diff) |
anv: Implement aux-map allocator interface
This interface allows the aux-map code in the intel/common library to
allocate and free buffers.
Reworks:
* free gen_buffer in gen_aux_map_buffer_free. (Rafael)
Signed-off-by: Jordan Justen <[email protected]>
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_device.c')
-rw-r--r-- | src/intel/vulkan/anv_device.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 2bd3093bce8..9f7dc9aaaeb 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -43,6 +43,7 @@ #include "util/xmlpool.h" #include "git_sha1.h" #include "vk_util.h" +#include "common/gen_buffer_alloc.h" #include "common/gen_defines.h" #include "compiler/glsl_types.h" @@ -2390,6 +2391,47 @@ decode_get_bo(void *v_batch, bool ppgtt, uint64_t address) return (struct gen_batch_decode_bo) { }; } +struct gen_aux_map_buffer { + struct gen_buffer base; + struct anv_state state; +}; + +static struct gen_buffer * +gen_aux_map_buffer_alloc(void *driver_ctx, uint32_t size) +{ + struct gen_aux_map_buffer *buf = malloc(sizeof(struct gen_aux_map_buffer)); + if (!buf) + return NULL; + + struct anv_device *device = (struct anv_device*)driver_ctx; + assert(device->instance->physicalDevice.supports_48bit_addresses && + device->instance->physicalDevice.use_softpin); + + struct anv_state_pool *pool = &device->dynamic_state_pool; + buf->state = anv_state_pool_alloc(pool, size, size); + + buf->base.gpu = pool->block_pool.bo->offset + buf->state.offset; + buf->base.gpu_end = buf->base.gpu + buf->state.alloc_size; + buf->base.map = buf->state.map; + buf->base.driver_bo = &buf->state; + return &buf->base; +} + +static void +gen_aux_map_buffer_free(void *driver_ctx, struct gen_buffer *buffer) +{ + struct gen_aux_map_buffer *buf = (struct gen_aux_map_buffer*)buffer; + struct anv_device *device = (struct anv_device*)driver_ctx; + struct anv_state_pool *pool = &device->dynamic_state_pool; + anv_state_pool_free(pool, buf->state); + free(buf); +} + +static struct gen_mapped_pinned_buffer_alloc aux_map_allocator = { + .alloc = gen_aux_map_buffer_alloc, + .free = gen_aux_map_buffer_free, +}; + VkResult anv_CreateDevice( VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, |