|
1 | | - auto* chainInfo = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
| 1 | + auto* chainInfo = getChainInfo(pCreateInfo); |
| 2 | + auto supportedExtensions = getInstanceExtensionList(pCreateInfo); |
2 | 3 |
|
3 | 4 | auto fpGetInstanceProcAddr = chainInfo->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
4 | 5 | auto fpCreateInstance = reinterpret_cast<PFN_vkCreateInstance>(fpGetInstanceProcAddr(nullptr, "vkCreateInstance")); |
|
7 | 8 | return VK_ERROR_INITIALIZATION_FAILED; |
8 | 9 | } |
9 | 10 |
|
| 11 | + // Create a copy we can write |
| 12 | + VkInstanceCreateInfo newCreateInfo = *pCreateInfo; |
| 13 | + |
| 14 | + // Query extension state |
| 15 | + std::string targetExt("VK_EXT_debug_utils"); |
| 16 | + bool targetSupported = isIn(targetExt, supportedExtensions); |
| 17 | + bool targetEnabled = isInExtensionList( |
| 18 | + targetExt, |
| 19 | + pCreateInfo->enabledExtensionCount, |
| 20 | + pCreateInfo->ppEnabledExtensionNames); |
| 21 | + |
| 22 | + if (!targetSupported) |
| 23 | + { |
| 24 | + LAYER_LOG("WARNING: Cannot enable additional extension: %s", targetExt.c_str()); |
| 25 | + } |
| 26 | + |
| 27 | + // Enable the extension if we need to |
| 28 | + std::vector<const char*> newExtList; |
| 29 | + if (targetSupported && !targetEnabled) |
| 30 | + { |
| 31 | + LAYER_LOG("Enabling additional extension: %s", targetExt.c_str()); |
| 32 | + newExtList = cloneExtensionList( |
| 33 | + pCreateInfo->enabledExtensionCount, |
| 34 | + pCreateInfo->ppEnabledExtensionNames); |
| 35 | + |
| 36 | + newExtList.push_back(targetExt.c_str()); |
| 37 | + |
| 38 | + newCreateInfo.enabledExtensionCount = newExtList.size(); |
| 39 | + newCreateInfo.ppEnabledExtensionNames = newExtList.data(); |
| 40 | + } |
| 41 | + |
10 | 42 | chainInfo->u.pLayerInfo = chainInfo->u.pLayerInfo->pNext; |
11 | | - auto res = fpCreateInstance(pCreateInfo, pAllocator, pInstance); |
| 43 | + auto res = fpCreateInstance(&newCreateInfo, pAllocator, pInstance); |
12 | 44 | if (res != VK_SUCCESS) |
13 | 45 | { |
14 | 46 | return res; |
15 | 47 | } |
16 | 48 |
|
17 | | - // Hold the lock to access layer-wide global store |
| 49 | + // Retake the lock to access layer-wide global store |
18 | 50 | auto instance = std::make_unique<Instance>(*pInstance, fpGetInstanceProcAddr); |
19 | 51 | { |
20 | 52 | std::lock_guard<std::mutex> lock { g_vulkanLock }; |
|
0 commit comments