Skip to content

Commit 0e85325

Browse files
authored
Use safe-struct chain info copy (#158)
This fixes use of multiple layers, which were failing to create an instance if more than one layer was in use. When we refactored the code to use safe-struct to avoid const-casting in layer code we patched the incorrect chain info, modifying the original user chain info rather than modifying the the safe-struct clone. This happens to work for a single layer because the driver doesn't use the chain, but it fails as soon as you have multiple layers because the chain is never advanced and getProcAddr points at the wrong layer.
1 parent 3b9fff0 commit 0e85325

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

source_common/framework/manual_functions.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,10 @@ VKAPI_ATTR VkResult VKAPI_CALL layer_vkCreateInstance<default_tag>(const VkInsta
784784
LAYER_LOG("Requested instance extension list: [%u] = %s", i, newCreateInfo->ppEnabledExtensionNames[i]);
785785
}
786786

787+
// Get the new chain info so we modify our safe copy, not the original
788+
chainInfo = getChainInfo(newCreateInfo);
789+
790+
// Advance the link info for the next element on the chain
787791
chainInfo->u.pLayerInfo = chainInfo->u.pLayerInfo->pNext;
788792
auto result = fpCreateInstance(newCreateInfo, pAllocator, pInstance);
789793
if (result != VK_SUCCESS)
@@ -874,6 +878,9 @@ VKAPI_ATTR VkResult VKAPI_CALL layer_vkCreateDevice<default_tag>(VkPhysicalDevic
874878
return VK_ERROR_INITIALIZATION_FAILED;
875879
}
876880

881+
// Get the new chain info so we modify our safe copy, not the original
882+
chainInfo = getChainInfo(newCreateInfo);
883+
877884
// Advance the link info for the next element on the chain
878885
chainInfo->u.pLayerInfo = chainInfo->u.pLayerInfo->pNext;
879886
auto res = fpCreateDevice(physicalDevice, newCreateInfo, pAllocator, pDevice);

0 commit comments

Comments
 (0)