From 4cb0da89a5064b4c0817ae276eb68e2db8a4512c Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Sat, 9 Sep 2023 18:30:07 -0700 Subject: [PATCH] venus: use common vk_queue object This change only updates the object base to be vk_queue. Signed-off-by: Yiwei Zhang Part-of: --- src/virtio/vulkan/vn_common.h | 30 ++++++++++++++++++++++++++++++ src/virtio/vulkan/vn_device.c | 7 +++++-- src/virtio/vulkan/vn_queue.h | 4 ++-- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/virtio/vulkan/vn_common.h b/src/virtio/vulkan/vn_common.h index 4e38fed3d74..774d344ea4c 100644 --- a/src/virtio/vulkan/vn_common.h +++ b/src/virtio/vulkan/vn_common.h @@ -40,6 +40,7 @@ #include "vk_instance.h" #include "vk_object.h" #include "vk_physical_device.h" +#include "vk_queue.h" #include "vk_util.h" #include "vn_entrypoints.h" @@ -139,6 +140,12 @@ struct vn_device_base { vn_object_id id; }; +/* base class of vn_queue */ +struct vn_queue_base { + struct vk_queue base; + vn_object_id id; +}; + /* base class of other driver objects */ struct vn_object_base { struct vk_object_base base; @@ -307,6 +314,24 @@ vn_device_base_fini(struct vn_device_base *dev) vk_device_finish(&dev->base); } +static inline VkResult +vn_queue_base_init(struct vn_queue_base *queue, + struct vn_device_base *dev, + const VkDeviceQueueCreateInfo *queue_info, + uint32_t queue_index) +{ + VkResult result = + vk_queue_init(&queue->base, &dev->base, queue_info, queue_index); + queue->id = (uintptr_t)queue; + return result; +} + +static inline void +vn_queue_base_fini(struct vn_queue_base *queue) +{ + vk_queue_finish(&queue->base); +} + static inline void vn_object_base_init(struct vn_object_base *obj, VkObjectType type, @@ -336,6 +361,9 @@ vn_object_set_id(void *obj, vn_object_id id, VkObjectType type) case VK_OBJECT_TYPE_DEVICE: ((struct vn_device_base *)obj)->id = id; break; + case VK_OBJECT_TYPE_QUEUE: + ((struct vn_queue_base *)obj)->id = id; + break; default: ((struct vn_object_base *)obj)->id = id; break; @@ -353,6 +381,8 @@ vn_object_get_id(const void *obj, VkObjectType type) return ((struct vn_physical_device_base *)obj)->id; case VK_OBJECT_TYPE_DEVICE: return ((struct vn_device_base *)obj)->id; + case VK_OBJECT_TYPE_QUEUE: + return ((struct vn_queue_base *)obj)->id; default: return ((struct vn_object_base *)obj)->id; } diff --git a/src/virtio/vulkan/vn_device.c b/src/virtio/vulkan/vn_device.c index c5cace68ea6..50e3ccf5870 100644 --- a/src/virtio/vulkan/vn_device.c +++ b/src/virtio/vulkan/vn_device.c @@ -35,7 +35,7 @@ vn_queue_fini(struct vn_queue *queue) if (queue->sparse_semaphore != VK_NULL_HANDLE) { vn_DestroySemaphore(dev_handle, queue->sparse_semaphore, NULL); } - vn_object_base_fini(&queue->base); + vn_queue_base_fini(&queue->base); } static VkResult @@ -44,7 +44,10 @@ vn_queue_init(struct vn_device *dev, const VkDeviceQueueCreateInfo *queue_info, uint32_t queue_index) { - vn_object_base_init(&queue->base, VK_OBJECT_TYPE_QUEUE, &dev->base); + VkResult result = + vn_queue_base_init(&queue->base, &dev->base, queue_info, queue_index); + if (result != VK_SUCCESS) + return result; VkDeviceQueueTimelineInfoMESA timeline_info; const struct vn_renderer_info *renderer_info = diff --git a/src/virtio/vulkan/vn_queue.h b/src/virtio/vulkan/vn_queue.h index b91ef1bcf67..1810416d59d 100644 --- a/src/virtio/vulkan/vn_queue.h +++ b/src/virtio/vulkan/vn_queue.h @@ -16,7 +16,7 @@ #include "vn_feedback.h" struct vn_queue { - struct vn_object_base base; + struct vn_queue_base base; struct vn_device *device; uint32_t family; @@ -38,7 +38,7 @@ struct vn_queue { VkSemaphore sparse_semaphore; uint64_t sparse_semaphore_counter; }; -VK_DEFINE_HANDLE_CASTS(vn_queue, base.base, VkQueue, VK_OBJECT_TYPE_QUEUE) +VK_DEFINE_HANDLE_CASTS(vn_queue, base.base.base, VkQueue, VK_OBJECT_TYPE_QUEUE) enum vn_sync_type { /* no payload */