From bd28750890104505c8875c28c61bdde66085516a Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Thu, 29 Jul 2021 16:43:30 +0000 Subject: [PATCH] vkr: vkr_physical_device to track vkr_device with vkr_object::track_head Signed-off-by: Yiwei Zhang Reviewed-by: Chia-I Wu Reviewed-by: Ryan Neph --- src/vkr_object.h | 3 +++ src/vkr_renderer.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/vkr_object.h b/src/vkr_object.h index dbab7a9..38fc3bd 100644 --- a/src/vkr_object.h +++ b/src/vkr_object.h @@ -9,6 +9,7 @@ #include #include +#include "util/u_double_list.h" #include "venus-protocol/vulkan.h" typedef uint64_t vkr_object_id; @@ -50,6 +51,8 @@ struct vkr_object { VkSamplerYcbcrConversion sampler_ycbcr_conversion; VkDescriptorUpdateTemplate descriptor_update_template; } handle; + + struct list_head track_head; }; #endif /* VKR_OBJECT_H */ diff --git a/src/vkr_renderer.c b/src/vkr_renderer.c index f76b386..8ca10e3 100644 --- a/src/vkr_renderer.c +++ b/src/vkr_renderer.c @@ -207,12 +207,14 @@ struct vkr_physical_device { VkExtensionProperties *extensions; uint32_t extension_count; - VkPhysicalDeviceMemoryProperties memory_properties; - bool KHR_external_memory_fd; bool EXT_external_memory_dma_buf; bool KHR_external_fence_fd; + + VkPhysicalDeviceMemoryProperties memory_properties; + + struct list_head devices; }; struct vkr_queue_sync { @@ -1284,6 +1286,8 @@ vkr_dispatch_vkEnumeratePhysicalDevices(struct vn_dispatch_context *dispatch, vkr_physical_device_init_extensions(physical_dev, instance); vkr_physical_device_init_memory_properties(physical_dev); + list_inithead(&physical_dev->devices); + instance->physical_devices[i] = physical_dev; util_hash_table_set_u64(ctx->object_table, physical_dev->base.id, physical_dev); @@ -2032,6 +2036,8 @@ vkr_dispatch_vkCreateDevice(struct vn_dispatch_context *dispatch, mtx_init(&dev->free_sync_mutex, mtx_plain); list_inithead(&dev->free_syncs); + list_add(&dev->base.track_head, &physical_dev->devices); + util_hash_table_set_u64(ctx->object_table, dev->base.id, dev); } @@ -2068,6 +2074,8 @@ vkr_dispatch_vkDestroyDevice(struct vn_dispatch_context *dispatch, vkDestroyDevice(device, NULL); + list_del(&dev->base.track_head); + util_hash_table_remove_u64(ctx->object_table, dev->base.id); }