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().
This commit is contained in:
Chad Versace 2015-07-09 15:38:58 -07:00
parent c34d314db3
commit fa915b661d
1 changed files with 10 additions and 8 deletions

View File

@ -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;