anv: Drop anv_bo_init and anv_bo_init_new

BOs are now only ever allocated through the BO cache so there's no need
to have these exposed.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
This commit is contained in:
Jason Ekstrand 2019-10-28 18:03:32 -05:00
parent 853d3b59fd
commit 63d7a38630
3 changed files with 34 additions and 48 deletions

View file

@ -389,8 +389,11 @@ anv_block_pool_init(struct anv_block_pool *pool,
if (pool->fd == -1)
return vk_error(VK_ERROR_INITIALIZATION_FAILED);
anv_bo_init(&pool->wrapper_bo, 0, 0);
pool->wrapper_bo.is_wrapper = true;
pool->wrapper_bo = (struct anv_bo) {
.refcount = 1,
.offset = -1,
.is_wrapper = true,
};
pool->bo = &pool->wrapper_bo;
}
@ -1536,13 +1539,18 @@ anv_device_alloc_bo(struct anv_device *device,
/* The kernel is going to give us whole pages anyway */
size = align_u64(size, 4096);
struct anv_bo new_bo;
VkResult result = anv_bo_init_new(&new_bo, device, size);
if (result != VK_SUCCESS)
return result;
uint32_t gem_handle = anv_gem_create(device, size);
if (gem_handle == 0)
return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
new_bo.flags = bo_flags;
new_bo.is_external = (alloc_flags & ANV_BO_ALLOC_EXTERNAL);
struct anv_bo new_bo = {
.gem_handle = gem_handle,
.refcount = 1,
.offset = -1,
.size = size,
.flags = bo_flags,
.is_external = (alloc_flags & ANV_BO_ALLOC_EXTERNAL),
};
if (alloc_flags & ANV_BO_ALLOC_MAPPED) {
new_bo.map = anv_gem_mmap(device, new_bo.gem_handle, 0, size, 0);
@ -1634,12 +1642,16 @@ anv_device_import_bo_from_host_ptr(struct anv_device *device,
}
__sync_fetch_and_add(&bo->refcount, 1);
} else {
struct anv_bo new_bo;
anv_bo_init(&new_bo, gem_handle, size);
new_bo.map = host_ptr;
new_bo.flags = bo_flags;
new_bo.is_external = true;
new_bo.from_host_ptr = true;
struct anv_bo new_bo = {
.gem_handle = gem_handle,
.refcount = 1,
.offset = -1,
.size = size,
.map = host_ptr,
.flags = bo_flags,
.is_external = true,
.from_host_ptr = true,
};
if (!anv_vma_alloc(device, &new_bo)) {
anv_gem_close(device, new_bo.gem_handle);
@ -1735,10 +1747,14 @@ anv_device_import_bo(struct anv_device *device,
return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE);
}
struct anv_bo new_bo;
anv_bo_init(&new_bo, gem_handle, size);
new_bo.flags = bo_flags;
new_bo.is_external = true;
struct anv_bo new_bo = {
.gem_handle = gem_handle,
.refcount = 1,
.offset = -1,
.size = size,
.flags = bo_flags,
.is_external = true,
};
if (!anv_vma_alloc(device, &new_bo)) {
anv_gem_close(device, new_bo.gem_handle);

View file

@ -3037,18 +3037,6 @@ anv_vma_free(struct anv_device *device, struct anv_bo *bo)
bo->offset = 0;
}
VkResult
anv_bo_init_new(struct anv_bo *bo, struct anv_device *device, uint64_t size)
{
uint32_t gem_handle = anv_gem_create(device, size);
if (!gem_handle)
return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
anv_bo_init(bo, gem_handle, size);
return VK_SUCCESS;
}
VkResult anv_AllocateMemory(
VkDevice _device,
const VkMemoryAllocateInfo* pAllocateInfo,

View file

@ -647,22 +647,6 @@ struct anv_bo {
bool from_host_ptr:1;
};
static inline void
anv_bo_init(struct anv_bo *bo, uint32_t gem_handle, uint64_t size)
{
bo->gem_handle = gem_handle;
bo->refcount = 1;
bo->index = 0;
bo->offset = -1;
bo->size = size;
bo->map = NULL;
bo->flags = 0;
bo->is_external = false;
bo->is_wrapper = false;
bo->has_fixed_address = false;
bo->from_host_ptr = false;
}
static inline struct anv_bo *
anv_bo_unwrap(struct anv_bo *bo)
{
@ -1374,8 +1358,6 @@ int anv_gem_syncobj_wait(struct anv_device *device,
bool anv_vma_alloc(struct anv_device *device, struct anv_bo *bo);
void anv_vma_free(struct anv_device *device, struct anv_bo *bo);
VkResult anv_bo_init_new(struct anv_bo *bo, struct anv_device *device, uint64_t size);
struct anv_reloc_list {
uint32_t num_relocs;
uint32_t array_length;