summaryrefslogtreecommitdiffstats
path: root/src/intel
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2019-10-28 18:03:32 -0500
committerJason Ekstrand <[email protected]>2019-10-31 13:46:09 +0000
commit63d7a38630ca17ac8c15c231f1afd75259f3417a (patch)
tree29256bdec69f5e3f7ec9fff117f8985f3bab4307 /src/intel
parent853d3b59fdafc10ebe462c1f15362451855c2a71 (diff)
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 <[email protected]>
Diffstat (limited to 'src/intel')
-rw-r--r--src/intel/vulkan/anv_allocator.c54
-rw-r--r--src/intel/vulkan/anv_device.c12
-rw-r--r--src/intel/vulkan/anv_private.h18
3 files changed, 35 insertions, 49 deletions
diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c
index 6729a8874e9..5b7464a6056 100644
--- a/src/intel/vulkan/anv_allocator.c
+++ b/src/intel/vulkan/anv_allocator.c
@@ -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;
-
- new_bo.flags = bo_flags;
- new_bo.is_external = (alloc_flags & ANV_BO_ALLOC_EXTERNAL);
+ uint32_t gem_handle = anv_gem_create(device, size);
+ if (gem_handle == 0)
+ return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
+
+ 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);
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index cba2cbe74b9..c0b153a0578 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -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,
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index ec8fc1b0c12..34f556ad2b4 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -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;