Mesa (main): venus: adjust device resources init order

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 16 19:06:12 UTC 2022


Module: Mesa
Branch: main
Commit: 4cf87d88229bb9eb51b3037fceccfc258843c4cc
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4cf87d88229bb9eb51b3037fceccfc258843c4cc

Author: Yiwei Zhang <zzyiwei at chromium.org>
Date:   Thu May 19 21:54:42 2022 +0000

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 at chromium.org>
Reviewed-by: Ryan Neph <ryanneph at google.com>
Reviewed-by: Chad Versace <chadversary at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16731>

---

 src/virtio/vulkan/vn_device.c | 22 ++++++++++------------
 src/virtio/vulkan/vn_device.h |  6 +++---
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/src/virtio/vulkan/vn_device.c b/src/virtio/vulkan/vn_device.c
index b71d0f5eea0..f1ffe2ed296 100644
--- a/src/virtio/vulkan/vn_device.c
+++ b/src/virtio/vulkan/vn_device.c
@@ -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.
diff --git a/src/virtio/vulkan/vn_device.h b/src/virtio/vulkan/vn_device.h
index d3875f73ee1..2a070630aa3 100644
--- a/src/virtio/vulkan/vn_device.h
+++ b/src/virtio/vulkan/vn_device.h
@@ -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,



More information about the mesa-commit mailing list