assert(util_is_power_of_two(block_size));
pool->device = device;
- pool->bo.gem_handle = 0;
- pool->bo.offset = 0;
- pool->bo.size = 0;
- pool->bo.is_winsys_bo = false;
+ anv_bo_init(&pool->bo, 0, 0);
pool->block_size = block_size;
pool->free_list = ANV_FREE_LIST_EMPTY;
pool->back_free_list = ANV_FREE_LIST_EMPTY;
* values back into pool. */
pool->map = map + center_bo_offset;
pool->center_bo_offset = center_bo_offset;
- pool->bo.gem_handle = gem_handle;
- pool->bo.size = size;
+ anv_bo_init(&pool->bo, gem_handle, size);
pool->bo.map = map;
- pool->bo.index = 0;
done:
pthread_mutex_unlock(&pool->device->mutex);
VkResult
anv_bo_init_new(struct anv_bo *bo, struct anv_device *device, uint64_t size)
{
- bo->gem_handle = anv_gem_create(device, size);
- if (!bo->gem_handle)
+ uint32_t gem_handle = anv_gem_create(device, size);
+ if (!gem_handle)
return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
- bo->map = NULL;
- bo->index = 0;
- bo->offset = 0;
- bo->size = size;
- bo->is_winsys_bo = false;
+ anv_bo_init(bo, gem_handle, size);
return VK_SUCCESS;
}
if (mem == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
- mem->bo.gem_handle = anv_gem_fd_to_handle(device, pCreateInfo->fd);
- if (!mem->bo.gem_handle) {
+ uint32_t gem_handle = anv_gem_fd_to_handle(device, pCreateInfo->fd);
+ if (!gem_handle) {
result = vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
goto fail;
}
- mem->bo.map = NULL;
- mem->bo.index = 0;
- mem->bo.offset = 0;
- mem->bo.size = pCreateInfo->strideInBytes * pCreateInfo->extent.height;
+ uint64_t size = pCreateInfo->strideInBytes * pCreateInfo->extent.height;
+
+ anv_bo_init(&mem->bo, gem_handle, size);
anv_image_create(_device,
&(struct anv_image_create_info) {
bool is_winsys_bo;
};
+static inline void
+anv_bo_init(struct anv_bo *bo, uint32_t gem_handle, uint64_t size)
+{
+ bo->gem_handle = gem_handle;
+ bo->index = 0;
+ bo->offset = 0;
+ bo->size = size;
+ bo->map = NULL;
+ bo->is_winsys_bo = false;
+}
+
/* Represents a lock-free linked list of "free" things. This is used by
* both the block pool and the state pools. Unfortunately, in order to
* solve the ABA problem, we can't use a single uint32_t head.