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:
Chia-I Wu
2021-08-31 12:28:20 -07:00
committed by Marge Bot
parent 7dfac808b0
commit bd04ff972e
3 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -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);
+1
View File
@@ -73,6 +73,7 @@ struct vn_instance {
struct {
mtx_t mutex;
bool initialized;
struct vn_physical_device *devices;
uint32_t device_count;
+2 -1
View File
@@ -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(