venus: adjust device resources init order

queue init involves fence creation, and we need to do that at the last
to prepare for other resource creation dependencies involved in fence
creation.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Chad Versace <chadversary@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16731>
This commit is contained in:
Yiwei Zhang 2022-05-19 21:54:42 +00:00 committed by Marge Bot
parent cf55a3f70e
commit 4cf87d8822
2 changed files with 13 additions and 15 deletions

View File

@ -291,10 +291,6 @@ vn_device_init(struct vn_device *dev,
if (result != VK_SUCCESS)
return result;
result = vn_device_init_queues(dev, create_info);
if (result != VK_SUCCESS)
goto out_destroy_device;
for (uint32_t i = 0; i < ARRAY_SIZE(dev->memory_pools); i++) {
struct vn_device_memory_pool *pool = &dev->memory_pools[i];
mtx_init(&pool->mutex, mtx_plain);
@ -304,17 +300,19 @@ vn_device_init(struct vn_device *dev,
if (result != VK_SUCCESS)
goto out_memory_pool_fini;
result = vn_device_init_queues(dev, create_info);
if (result != VK_SUCCESS)
goto out_buffer_cache_fini;
return VK_SUCCESS;
out_buffer_cache_fini:
vn_buffer_cache_fini(dev);
out_memory_pool_fini:
for (uint32_t i = 0; i < ARRAY_SIZE(dev->memory_pools); i++)
vn_device_memory_pool_fini(dev, i);
for (uint32_t i = 0; i < dev->queue_count; i++)
vn_queue_fini(&dev->queues[i]);
vk_free(alloc, dev->queues);
out_destroy_device:
vn_call_vkDestroyDevice(instance, dev_handle, NULL);
return result;
@ -373,14 +371,14 @@ vn_DestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator)
if (!dev)
return;
for (uint32_t i = 0; i < dev->queue_count; i++)
vn_queue_fini(&dev->queues[i]);
vn_buffer_cache_fini(dev);
for (uint32_t i = 0; i < ARRAY_SIZE(dev->memory_pools); i++)
vn_device_memory_pool_fini(dev, i);
for (uint32_t i = 0; i < dev->queue_count; i++)
vn_queue_fini(&dev->queues[i]);
/* We must emit vkDestroyDevice before freeing dev->queues. Otherwise,
* another thread might reuse their object ids while they still refer to
* the queues in the renderer.

View File

@ -23,12 +23,12 @@ struct vn_device {
struct vn_physical_device *physical_device;
struct vn_renderer *renderer;
struct vn_queue *queues;
uint32_t queue_count;
struct vn_device_memory_pool memory_pools[VK_MAX_MEMORY_TYPES];
struct vn_buffer_cache buffer_cache;
struct vn_queue *queues;
uint32_t queue_count;
};
VK_DEFINE_HANDLE_CASTS(vn_device,
base.base.base,