@@ -111,17 +111,34 @@ VkLayerDeviceCreateInfo* getChainInfo(const VkDeviceCreateInfo* pCreateInfo)
111111}
112112
113113/* See header for documentation. */
114- PFN_vkVoidFunction getInstanceLayerFunction (const char * name)
114+ std::pair< bool , PFN_vkVoidFunction> getInstanceLayerFunction (const char * name)
115115{
116+ const std::array<const char *, 4 > globalFunctions {
117+ " vkCreateInstance" ,
118+ " vkEnumerateInstanceVersion" ,
119+ " vkEnumerateInstanceExtensionProperties" ,
120+ " vkEnumerateInstanceLayerProperties"
121+ };
122+
123+ bool isGlobal { false };
124+ for (const auto * globalName : globalFunctions)
125+ {
126+ if (!strcmp (globalName, name))
127+ {
128+ isGlobal = true ;
129+ break ;
130+ }
131+ }
132+
116133 for (auto & function : instanceIntercepts)
117134 {
118135 if (!strcmp (function.name , name))
119136 {
120- return function.function ;
137+ return {isGlobal, function.function } ;
121138 }
122139 }
123140
124- return nullptr ;
141+ return {isGlobal, nullptr } ;
125142}
126143
127144/* See header for documentation. */
@@ -474,9 +491,18 @@ void enableDeviceVkExtImageCompressionControl(Instance& instance,
474491/* * See Vulkan API for documentation. */
475492PFN_vkVoidFunction layer_vkGetInstanceProcAddr_default (VkInstance instance, const char * pName)
476493{
477- // Only expose functions that the driver exposes to avoid changing
478- // queryable interface behavior seen by the application
479- auto layerFunction = getInstanceLayerFunction (pName);
494+ auto [isGlobal, layerFunction] = getInstanceLayerFunction (pName);
495+
496+ // Global functions must be exposed and do not require the caller to pass
497+ // a valid instance pointer, although it is required to be nullptr in
498+ // Vulkan 1.2.193 or later
499+ if (isGlobal)
500+ {
501+ return layerFunction;
502+ }
503+
504+ // For other functions, only expose functions that the driver exposes to
505+ // avoid changing queryable interface behavior seen by the application
480506 if (instance)
481507 {
482508 std::unique_lock<std::mutex> lock {g_vulkanLock};
0 commit comments