anv: Add a new bo_pool_init helper
This ensures that we're always setting all of the fields in anv_bo Signed-off-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Cc: "13.0" <mesa-stable@lists.freedesktop.org>
This commit is contained in:
@@ -253,10 +253,7 @@ anv_block_pool_init(struct anv_block_pool *pool,
|
|||||||
assert(util_is_power_of_two(block_size));
|
assert(util_is_power_of_two(block_size));
|
||||||
|
|
||||||
pool->device = device;
|
pool->device = device;
|
||||||
pool->bo.gem_handle = 0;
|
anv_bo_init(&pool->bo, 0, 0);
|
||||||
pool->bo.offset = 0;
|
|
||||||
pool->bo.size = 0;
|
|
||||||
pool->bo.is_winsys_bo = false;
|
|
||||||
pool->block_size = block_size;
|
pool->block_size = block_size;
|
||||||
pool->free_list = ANV_FREE_LIST_EMPTY;
|
pool->free_list = ANV_FREE_LIST_EMPTY;
|
||||||
pool->back_free_list = ANV_FREE_LIST_EMPTY;
|
pool->back_free_list = ANV_FREE_LIST_EMPTY;
|
||||||
@@ -463,10 +460,8 @@ anv_block_pool_grow(struct anv_block_pool *pool, struct anv_block_state *state)
|
|||||||
* values back into pool. */
|
* values back into pool. */
|
||||||
pool->map = map + center_bo_offset;
|
pool->map = map + center_bo_offset;
|
||||||
pool->center_bo_offset = center_bo_offset;
|
pool->center_bo_offset = center_bo_offset;
|
||||||
pool->bo.gem_handle = gem_handle;
|
anv_bo_init(&pool->bo, gem_handle, size);
|
||||||
pool->bo.size = size;
|
|
||||||
pool->bo.map = map;
|
pool->bo.map = map;
|
||||||
pool->bo.index = 0;
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
pthread_mutex_unlock(&pool->device->mutex);
|
pthread_mutex_unlock(&pool->device->mutex);
|
||||||
|
@@ -1146,15 +1146,11 @@ VkResult anv_DeviceWaitIdle(
|
|||||||
VkResult
|
VkResult
|
||||||
anv_bo_init_new(struct anv_bo *bo, struct anv_device *device, uint64_t size)
|
anv_bo_init_new(struct anv_bo *bo, struct anv_device *device, uint64_t size)
|
||||||
{
|
{
|
||||||
bo->gem_handle = anv_gem_create(device, size);
|
uint32_t gem_handle = anv_gem_create(device, size);
|
||||||
if (!bo->gem_handle)
|
if (!gem_handle)
|
||||||
return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||||
|
|
||||||
bo->map = NULL;
|
anv_bo_init(bo, gem_handle, size);
|
||||||
bo->index = 0;
|
|
||||||
bo->offset = 0;
|
|
||||||
bo->size = size;
|
|
||||||
bo->is_winsys_bo = false;
|
|
||||||
|
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@@ -49,16 +49,15 @@ VkResult anv_CreateDmaBufImageINTEL(
|
|||||||
if (mem == NULL)
|
if (mem == NULL)
|
||||||
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
|
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||||
|
|
||||||
mem->bo.gem_handle = anv_gem_fd_to_handle(device, pCreateInfo->fd);
|
uint32_t gem_handle = anv_gem_fd_to_handle(device, pCreateInfo->fd);
|
||||||
if (!mem->bo.gem_handle) {
|
if (!gem_handle) {
|
||||||
result = vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
result = vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
mem->bo.map = NULL;
|
uint64_t size = pCreateInfo->strideInBytes * pCreateInfo->extent.height;
|
||||||
mem->bo.index = 0;
|
|
||||||
mem->bo.offset = 0;
|
anv_bo_init(&mem->bo, gem_handle, size);
|
||||||
mem->bo.size = pCreateInfo->strideInBytes * pCreateInfo->extent.height;
|
|
||||||
|
|
||||||
anv_image_create(_device,
|
anv_image_create(_device,
|
||||||
&(struct anv_image_create_info) {
|
&(struct anv_image_create_info) {
|
||||||
|
@@ -270,6 +270,17 @@ struct anv_bo {
|
|||||||
bool is_winsys_bo;
|
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
|
/* 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
|
* 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.
|
* solve the ABA problem, we can't use a single uint32_t head.
|
||||||
|
Reference in New Issue
Block a user