venus: initialize physical devices once
Avoid re-enumeration when there is no device or no supported device. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Ryan Neph <ryanneph@google.com> Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12653>
This commit is contained in:
@@ -778,7 +778,7 @@ vn_DestroyInstance(VkInstance _instance,
|
||||
if (!instance)
|
||||
return;
|
||||
|
||||
if (instance->physical_device.devices) {
|
||||
if (instance->physical_device.initialized) {
|
||||
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);
|
||||
|
||||
@@ -73,6 +73,7 @@ struct vn_instance {
|
||||
|
||||
struct {
|
||||
mtx_t mutex;
|
||||
bool initialized;
|
||||
|
||||
struct vn_physical_device *devices;
|
||||
uint32_t device_count;
|
||||
|
||||
@@ -1267,10 +1267,11 @@ vn_instance_enumerate_physical_devices(struct vn_instance *instance)
|
||||
|
||||
mtx_lock(&instance->physical_device.mutex);
|
||||
|
||||
if (instance->physical_device.devices) {
|
||||
if (instance->physical_device.initialized) {
|
||||
result = VK_SUCCESS;
|
||||
goto out;
|
||||
}
|
||||
instance->physical_device.initialized = true;
|
||||
|
||||
uint32_t count;
|
||||
result = vn_call_vkEnumeratePhysicalDevices(
|
||||
|
||||
Reference in New Issue
Block a user