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;
}
/* 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);
}
__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);
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);
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,
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)
{
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;