| 1333 | } |
| 1334 | |
| 1335 | VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo, |
| 1336 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) { |
| 1337 | VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
| 1338 | |
| 1339 | assert(chain_info->u.pLayerInfo); |
| 1340 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 1341 | PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr; |
| 1342 | VkInstance instance = physDeviceMap[gpu].instance; |
| 1343 | PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice)fpGetInstanceProcAddr(instance, "vkCreateDevice"); |
| 1344 | if (fpCreateDevice == NULL) { |
| 1345 | return VK_ERROR_INITIALIZATION_FAILED; |
| 1346 | } |
| 1347 | |
| 1348 | // Advance the link info for the next element on the chain |
| 1349 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 1350 | |
| 1351 | VkResult result = fpCreateDevice(gpu, pCreateInfo, pAllocator, pDevice); |
| 1352 | if (result != VK_SUCCESS) { |
| 1353 | return result; |
| 1354 | } |
| 1355 | |
| 1356 | assert(deviceMap.find(*pDevice) == deviceMap.end()); |
| 1357 | DeviceMapStruct *deviceMapElem = new DeviceMapStruct; |
| 1358 | deviceMap[*pDevice] = deviceMapElem; |
| 1359 | assert(dispatchMap.find(*pDevice) == dispatchMap.end()); |
| 1360 | DispatchMapStruct *dispatchMapElem = new DispatchMapStruct; |
| 1361 | dispatchMap[*pDevice] = dispatchMapElem; |
| 1362 | |
| 1363 | // Setup device dispatch table |
| 1364 | dispatchMapElem->device_dispatch_table = new VkuDeviceDispatchTable; |
| 1365 | vkuInitDeviceDispatchTable(*pDevice, dispatchMapElem->device_dispatch_table, fpGetDeviceProcAddr); |
| 1366 | |
| 1367 | createDeviceRegisterExtensions(pCreateInfo, *pDevice); |
| 1368 | // Create a mapping from a device to a physicalDevice |
| 1369 | deviceMapElem->physicalDevice = gpu; |
| 1370 | |
| 1371 | // store the loader callback for initializing created dispatchable objects |
| 1372 | chain_info = get_chain_info(pCreateInfo, VK_LOADER_DATA_CALLBACK); |
| 1373 | if (chain_info) { |
| 1374 | dispatchMapElem->pfn_dev_init = chain_info->u.pfnSetDeviceLoaderData; |
| 1375 | } else { |
| 1376 | dispatchMapElem->pfn_dev_init = NULL; |
| 1377 | } |
| 1378 | return result; |
| 1379 | } |
| 1380 | |
| 1381 | VKAPI_ATTR VkResult VKAPI_CALL EnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, |
| 1382 | VkPhysicalDevice *pPhysicalDevices) { |
nothing calls this directly
no test coverage detected