diff options
author | Ryan Neph <ryanneph@google.com> | 2023-09-15 17:06:35 -0700 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2023-09-18 23:09:58 +0000 |
commit | baa5528131c3c110d241bd4b5c25160fab19952a (patch) | |
tree | 4effb86c4d6464e024855607b35241c9c2a80d28 | |
parent | 9c9d55ecbe502e0d71ee99529709efcca69aac42 (diff) |
vkr: track VkQueueFamilyProperties to validate device creation
Signed-off-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1239>
-rw-r--r-- | src/venus/vkr_physical_device.c | 22 | ||||
-rw-r--r-- | src/venus/vkr_physical_device.h | 3 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/venus/vkr_physical_device.c b/src/venus/vkr_physical_device.c index 5792337..1ab8dbd 100644 --- a/src/venus/vkr_physical_device.c +++ b/src/venus/vkr_physical_device.c @@ -62,6 +62,7 @@ vkr_physical_device_destroy(struct vkr_context *ctx, vkr_device_destroy(ctx, dev); free(physical_dev->extensions); + free(physical_dev->queue_family_properties); vkr_context_remove_object(ctx, &physical_dev->base); } @@ -276,6 +277,25 @@ vkr_physical_device_init_proc_table(struct vkr_physical_device *physical_dev, } static void +vkr_physical_device_init_queue_family_properties(struct vkr_physical_device *physical_dev) +{ + VkPhysicalDevice handle = physical_dev->base.handle.physical_device; + + VkQueueFamilyProperties *props; + uint32_t count; + vkGetPhysicalDeviceQueueFamilyProperties(handle, &count, NULL); + + props = malloc(sizeof(*props) * count); + if (!props) + return; + + vkGetPhysicalDeviceQueueFamilyProperties(handle, &count, props); + + physical_dev->queue_family_property_count = count; + physical_dev->queue_family_properties = props; +} + +static void vkr_dispatch_vkEnumeratePhysicalDevices(struct vn_dispatch_context *dispatch, struct vn_command_vkEnumeratePhysicalDevices *args) { @@ -339,6 +359,7 @@ vkr_dispatch_vkEnumeratePhysicalDevices(struct vn_dispatch_context *dispatch, vkr_physical_device_init_extensions(physical_dev, instance); vkr_physical_device_init_memory_properties(physical_dev); vkr_physical_device_init_id_properties(physical_dev); + vkr_physical_device_init_queue_family_properties(physical_dev); list_inithead(&physical_dev->devices); @@ -353,6 +374,7 @@ vkr_dispatch_vkEnumeratePhysicalDevices(struct vn_dispatch_context *dispatch, if (!physical_dev) break; free(physical_dev->extensions); + free(physical_dev->queue_family_properties); vkr_context_remove_object(ctx, &physical_dev->base); instance->physical_devices[i] = NULL; } diff --git a/src/venus/vkr_physical_device.h b/src/venus/vkr_physical_device.h index 142662b..8bdf736 100644 --- a/src/venus/vkr_physical_device.h +++ b/src/venus/vkr_physical_device.h @@ -33,6 +33,9 @@ struct vkr_physical_device { bool is_opaque_fd_export_supported; void *gbm_device; + VkQueueFamilyProperties *queue_family_properties; + uint32_t queue_family_property_count; + struct list_head devices; }; VKR_DEFINE_OBJECT_CAST(physical_device, VK_OBJECT_TYPE_PHYSICAL_DEVICE, VkPhysicalDevice) |