From fa915b661d4159014c0ed3c593505ddf57f27ee5 Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Thu, 9 Jul 2015 15:38:58 -0700 Subject: [PATCH] vk/device: Move device enumeration to vkEnumeratePhysicalDevices() Don't enumerate devices in vkCreateInstance(). That's where global, device-independent initialization should happen. Move device enumeration to the more logical location, vkEnumeratePhysicalDevices(). --- src/vulkan/device.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/vulkan/device.c b/src/vulkan/device.c index ca8fd843f52..bbe4ff1c87e 100644 --- a/src/vulkan/device.c +++ b/src/vulkan/device.c @@ -121,7 +121,6 @@ VkResult anv_CreateInstance( struct anv_instance *instance; const VkAllocCallbacks *alloc_callbacks = &default_alloc_callbacks; void *user_data = NULL; - VkResult result; assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO); @@ -138,15 +137,8 @@ VkResult anv_CreateInstance( instance->pfnAlloc = alloc_callbacks->pfnAlloc; instance->pfnFree = alloc_callbacks->pfnFree; instance->apiVersion = pCreateInfo->pAppInfo->apiVersion; - instance->physicalDeviceCount = 0; - result = fill_physical_device(&instance->physicalDevice, - instance, "/dev/dri/renderD128"); - if (result != VK_SUCCESS) - return result; - - instance->physicalDeviceCount++; *pInstance = (VkInstance) instance; return VK_SUCCESS; @@ -168,6 +160,16 @@ VkResult anv_EnumeratePhysicalDevices( VkPhysicalDevice* pPhysicalDevices) { struct anv_instance *instance = (struct anv_instance *) _instance; + VkResult result; + + if (instance->physicalDeviceCount == 0) { + result = fill_physical_device(&instance->physicalDevice, + instance, "/dev/dri/renderD128"); + if (result != VK_SUCCESS) + return result; + + instance->physicalDeviceCount++; + } if (*pPhysicalDeviceCount >= 1) pPhysicalDevices[0] = (VkPhysicalDevice) &instance->physicalDevice;