From: Chad Versace Date: Thu, 9 Jul 2015 22:38:58 +0000 (-0700) Subject: vk/device: Move device enumeration to vkEnumeratePhysicalDevices() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fa915b661d4159014c0ed3c593505ddf57f27ee5;p=mesa.git 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(). --- 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;