diff --git a/src/virtio/vulkan/vn_instance.c b/src/virtio/vulkan/vn_instance.c index 54efb8e4272..5e1b63a4086 100644 --- a/src/virtio/vulkan/vn_instance.c +++ b/src/virtio/vulkan/vn_instance.c @@ -670,7 +670,7 @@ vn_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, return vn_error(NULL, result); } - mtx_init(&instance->physical_device_mutex, mtx_plain); + mtx_init(&instance->physical_device.mutex, mtx_plain); if (!vn_icd_supports_api_version( instance->base.base.app_info.api_version)) { @@ -759,7 +759,7 @@ fail: vn_renderer_destroy(instance->renderer, alloc); } - mtx_destroy(&instance->physical_device_mutex); + mtx_destroy(&instance->physical_device.mutex); vn_instance_base_fini(&instance->base); vk_free(alloc, instance); @@ -778,12 +778,13 @@ vn_DestroyInstance(VkInstance _instance, if (!instance) return; - if (instance->physical_devices) { - vk_free(alloc, instance->physical_device_groups); - for (uint32_t i = 0; i < instance->physical_device_count; i++) - vn_physical_device_fini(&instance->physical_devices[i]); - vk_free(alloc, instance->physical_devices); + if (instance->physical_device.devices) { + for (uint32_t i = 0; i < instance->physical_device.device_count; i++) + vn_physical_device_fini(&instance->physical_device.devices[i]); + vk_free(alloc, instance->physical_device.devices); + vk_free(alloc, instance->physical_device.groups); } + mtx_destroy(&instance->physical_device.mutex); vn_call_vkDestroyInstance(instance, _instance, NULL); @@ -804,8 +805,6 @@ vn_DestroyInstance(VkInstance _instance, mtx_destroy(&instance->roundtrip_mutex); vn_renderer_destroy(instance->renderer, alloc); - mtx_destroy(&instance->physical_device_mutex); - driDestroyOptionCache(&instance->dri_options); driDestroyOptionInfo(&instance->available_dri_options); diff --git a/src/virtio/vulkan/vn_instance.h b/src/virtio/vulkan/vn_instance.h index 6c49489b961..82a03bf095d 100644 --- a/src/virtio/vulkan/vn_instance.h +++ b/src/virtio/vulkan/vn_instance.h @@ -71,11 +71,14 @@ struct vn_instance { void *ptr; } reply; - mtx_t physical_device_mutex; - struct vn_physical_device *physical_devices; - uint32_t physical_device_count; - VkPhysicalDeviceGroupProperties *physical_device_groups; - uint32_t physical_device_group_count; + struct { + mtx_t mutex; + + struct vn_physical_device *devices; + uint32_t device_count; + VkPhysicalDeviceGroupProperties *groups; + uint32_t group_count; + } physical_device; /* XXX staged features to be merged to core venus protocol */ VkVenusExperimentalFeatures100000MESA experimental; diff --git a/src/virtio/vulkan/vn_physical_device.c b/src/virtio/vulkan/vn_physical_device.c index fb5d4e1b599..198356d3e16 100644 --- a/src/virtio/vulkan/vn_physical_device.c +++ b/src/virtio/vulkan/vn_physical_device.c @@ -1252,8 +1252,8 @@ vn_instance_enumerate_physical_device_groups_locked( vk_free(alloc, temp_objs); - instance->physical_device_groups = groups; - instance->physical_device_group_count = count; + instance->physical_device.groups = groups; + instance->physical_device.group_count = count; return VK_SUCCESS; } @@ -1265,9 +1265,9 @@ vn_instance_enumerate_physical_devices(struct vn_instance *instance) struct vn_physical_device *physical_devs = NULL; VkResult result; - mtx_lock(&instance->physical_device_mutex); + mtx_lock(&instance->physical_device.mutex); - if (instance->physical_devices) { + if (instance->physical_device.devices) { result = VK_SUCCESS; goto out; } @@ -1348,8 +1348,8 @@ vn_instance_enumerate_physical_devices(struct vn_instance *instance) goto out; } - instance->physical_devices = physical_devs; - instance->physical_device_count = count; + instance->physical_device.devices = physical_devs; + instance->physical_device.device_count = count; out: if (result != VK_SUCCESS && physical_devs) { @@ -1358,7 +1358,7 @@ out: vk_free(alloc, physical_devs); } - mtx_unlock(&instance->physical_device_mutex); + mtx_unlock(&instance->physical_device.mutex); return result; } @@ -1376,10 +1376,10 @@ vn_EnumeratePhysicalDevices(VkInstance _instance, return vn_error(instance, result); VK_OUTARRAY_MAKE(out, pPhysicalDevices, pPhysicalDeviceCount); - for (uint32_t i = 0; i < instance->physical_device_count; i++) { + for (uint32_t i = 0; i < instance->physical_device.device_count; i++) { vk_outarray_append(&out, physical_dev) { - *physical_dev = - vn_physical_device_to_handle(&instance->physical_devices[i]); + *physical_dev = vn_physical_device_to_handle( + &instance->physical_device.devices[i]); } } @@ -1400,9 +1400,9 @@ vn_EnumeratePhysicalDeviceGroups( VK_OUTARRAY_MAKE(out, pPhysicalDeviceGroupProperties, pPhysicalDeviceGroupCount); - for (uint32_t i = 0; i < instance->physical_device_group_count; i++) { + for (uint32_t i = 0; i < instance->physical_device.group_count; i++) { vk_outarray_append(&out, props) { - *props = instance->physical_device_groups[i]; + *props = instance->physical_device.groups[i]; } }