diff --git a/generator/generate_vulkan_common.py b/generator/generate_vulkan_common.py index ce273bb..2c4fcd4 100755 --- a/generator/generate_vulkan_common.py +++ b/generator/generate_vulkan_common.py @@ -39,28 +39,14 @@ 'vkEnumerateInstanceVersion', } -# These functions are excluded from generated intercept and dispatch tables -NO_INTERCEPT_OR_DISPATCH_FUNCTIONS = { - # Functions resolved by the loaded not the implementation - 'vkGetDeviceProcAddr', - 'vkGetInstanceProcAddr', -} - -# These functions are excluded from generated intercept tables -NO_INTERCEPT_FUNCTIONS = { - # Functions exported as shared object symbols and resolved by loader - 'vkEnumerateDeviceExtensionProperties', - 'vkEnumerateDeviceLayerProperties', - 'vkEnumerateInstanceExtensionProperties', - 'vkEnumerateInstanceLayerProperties', -} - # These functions are excluded from generated dispatch tables NO_DISPATCH_FUNCTIONS = { # Functions resolved by the loader not the implementation 'vkCreateDevice', 'vkCreateInstance', 'vkEnumerateInstanceExtensionProperties', + 'vkGetDeviceProcAddr', + 'vkGetInstanceProcAddr', } # These functions are excluded from generated declarations @@ -69,13 +55,13 @@ 'vkCreateInstance', 'vkDestroyDevice', 'vkDestroyInstance', - 'vkGetDeviceProcAddr', - 'vkGetInstanceProcAddr', 'vkEnumerateDeviceExtensionProperties', 'vkEnumerateDeviceLayerProperties', 'vkEnumerateInstanceExtensionProperties', 'vkEnumerateInstanceLayerProperties', 'vkGetDeviceImageMemoryRequirementsKHR', + 'vkGetDeviceProcAddr', + 'vkGetInstanceProcAddr', } # Filter out extensions from these vendors by default @@ -434,21 +420,16 @@ def generate_instance_dispatch_table( continue assert command.name - - if command.name in NO_INTERCEPT_OR_DISPATCH_FUNCTIONS: - continue - plat_define = mapping.get_platform_define(command.name) - ttype = f'PFN_{command.name}' - if command.name not in NO_INTERCEPT_FUNCTIONS: - if plat_define: - itable_members.append(f'#if defined({plat_define})') + if plat_define: + itable_members.append(f'#if defined({plat_define})') - itable_members.append(f' ENTRY({command.name}),') - if plat_define: - itable_members.append('#endif') + itable_members.append(f' ENTRY({command.name}),') + + if plat_define: + itable_members.append('#endif') if command.name not in NO_DISPATCH_FUNCTIONS: if plat_define: @@ -586,9 +567,6 @@ def generate_instance_defs( continue assert command.name - if command.name in NO_INTERCEPT_FUNCTIONS: - continue - if command.name in CUSTOM_FUNCTIONS: continue @@ -657,25 +635,28 @@ def generate_device_dispatch_table( continue assert command.name - if command.name in NO_INTERCEPT_OR_DISPATCH_FUNCTIONS: - continue - plat_define = mapping.get_platform_define(command.name) ttype = f'PFN_{command.name}' if plat_define: itable_members.append(f'#if defined({plat_define})') - dispatch_table_members.append(f'#if defined({plat_define})') - dispatch_table_inits.append(f'#if defined({plat_define})') itable_members.append(f' ENTRY({command.name}),') - dispatch_table_members.append(f' {ttype} {command.name};') - dispatch_table_inits.append(f' ENTRY({command.name});') if plat_define: itable_members.append('#endif') - dispatch_table_members.append('#endif') - dispatch_table_inits.append('#endif') + + if command.name not in NO_DISPATCH_FUNCTIONS: + if plat_define: + dispatch_table_members.append(f'#if defined({plat_define})') + dispatch_table_inits.append(f'#if defined({plat_define})') + + dispatch_table_members.append(f' {ttype} {command.name};') + dispatch_table_inits.append(f' ENTRY({command.name});') + + if plat_define: + dispatch_table_members.append('#endif') + dispatch_table_inits.append('#endif') data = data.replace('{ITABLE_MEMBERS}', '\n'.join(itable_members)) data = data.replace('{DTABLE_MEMBERS}', '\n'.join(dispatch_table_members)) diff --git a/source_common/framework/device_dispatch_table.hpp b/source_common/framework/device_dispatch_table.hpp index d5ea701..a19c09d 100644 --- a/source_common/framework/device_dispatch_table.hpp +++ b/source_common/framework/device_dispatch_table.hpp @@ -407,6 +407,7 @@ static const struct DeviceInterceptTableEntry deviceIntercepts[] = { ENTRY(vkGetDeviceMemoryOpaqueCaptureAddress), ENTRY(vkGetDeviceMemoryOpaqueCaptureAddressKHR), ENTRY(vkGetDeviceMicromapCompatibilityEXT), + ENTRY(vkGetDeviceProcAddr), ENTRY(vkGetDeviceQueue), ENTRY(vkGetDeviceQueue2), ENTRY(vkGetEventStatus), diff --git a/source_common/framework/instance_dispatch_table.hpp b/source_common/framework/instance_dispatch_table.hpp index 8114645..cd35e46 100644 --- a/source_common/framework/instance_dispatch_table.hpp +++ b/source_common/framework/instance_dispatch_table.hpp @@ -75,6 +75,10 @@ static const struct InstanceInterceptTableEntry instanceIntercepts[] = { ENTRY(vkDestroyDebugUtilsMessengerEXT), ENTRY(vkDestroyInstance), ENTRY(vkDestroySurfaceKHR), + ENTRY(vkEnumerateDeviceExtensionProperties), + ENTRY(vkEnumerateDeviceLayerProperties), + ENTRY(vkEnumerateInstanceExtensionProperties), + ENTRY(vkEnumerateInstanceLayerProperties), ENTRY(vkEnumeratePhysicalDeviceGroups), ENTRY(vkEnumeratePhysicalDeviceGroupsKHR), ENTRY(vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR), @@ -84,6 +88,7 @@ static const struct InstanceInterceptTableEntry instanceIntercepts[] = { ENTRY(vkGetDisplayPlaneCapabilities2KHR), ENTRY(vkGetDisplayPlaneCapabilitiesKHR), ENTRY(vkGetDisplayPlaneSupportedDisplaysKHR), + ENTRY(vkGetInstanceProcAddr), ENTRY(vkGetPhysicalDeviceCalibrateableTimeDomainsEXT), ENTRY(vkGetPhysicalDeviceCalibrateableTimeDomainsKHR), ENTRY(vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR), diff --git a/source_common/framework/manual_functions.cpp b/source_common/framework/manual_functions.cpp index b9b3389..5a35e19 100644 --- a/source_common/framework/manual_functions.cpp +++ b/source_common/framework/manual_functions.cpp @@ -67,17 +67,9 @@ struct DispatchTableEntry /** * @brief Utility macro to define a lookup for a core function. */ -#define VK_TABLE_ENTRY(func) \ - { \ - STR(func), reinterpret_cast(func) \ - } - -/** - * @brief Utility macro to define a lookup for a layer-dispatch-only function. - */ -#define VK_TABLE_ENTRYL(func) \ - { \ - STR(func), reinterpret_cast(layer_##func) \ +#define VK_TABLE_ENTRY(func) \ + { \ + STR(func), reinterpret_cast(layer_##func) \ } /* See header for documentation. */ @@ -118,28 +110,6 @@ VkLayerDeviceCreateInfo* getChainInfo(const VkDeviceCreateInfo* pCreateInfo) return const_cast(info); } -/* See header for documentation. */ -PFN_vkVoidFunction getFixedInstanceLayerFunction(const char* name) -{ - static const DispatchTableEntry layerFunctions[] = { - VK_TABLE_ENTRY(vkGetInstanceProcAddr), - VK_TABLE_ENTRY(vkEnumerateDeviceLayerProperties), - VK_TABLE_ENTRY(vkEnumerateDeviceExtensionProperties), - VK_TABLE_ENTRY(vkEnumerateInstanceLayerProperties), - VK_TABLE_ENTRY(vkEnumerateInstanceExtensionProperties), - }; - - for (auto& function : layerFunctions) - { - if (!strcmp(function.name, name)) - { - return function.function; - } - } - - return nullptr; -} - /* See header for documentation. */ PFN_vkVoidFunction getInstanceLayerFunction(const char* name) { @@ -157,20 +127,6 @@ PFN_vkVoidFunction getInstanceLayerFunction(const char* name) /* See header for documentation. */ PFN_vkVoidFunction getDeviceLayerFunction(const char* name) { - static const DispatchTableEntry layerFunctions[] = { - VK_TABLE_ENTRY(vkGetDeviceProcAddr), - VK_TABLE_ENTRY(vkEnumerateDeviceExtensionProperties), - VK_TABLE_ENTRY(vkEnumerateDeviceLayerProperties), - }; - - for (auto& function : layerFunctions) - { - if (!strcmp(function.name, name)) - { - return function.function; - } - } - for (auto& function : deviceIntercepts) { if (!strcmp(function.name, name)) @@ -570,16 +526,9 @@ static void enableDeviceVkExtImageCompressionControl(VkDeviceCreateInfo& createI /** See Vulkan API for documentation. */ PFN_vkVoidFunction layer_vkGetInstanceProcAddr_default(VkInstance instance, const char* pName) { - // Always expose these functions ... - PFN_vkVoidFunction layerFunction = getFixedInstanceLayerFunction(pName); - if (layerFunction) - { - return layerFunction; - } - - // Otherwise, only expose functions that the driver exposes to avoid - // changing queryable interface behavior seen by the application - layerFunction = getInstanceLayerFunction(pName); + // Only expose functions that the driver exposes to avoid changing + // queryable interface behavior seen by the application + auto layerFunction = getInstanceLayerFunction(pName); if (instance) { std::unique_lock lock {g_vulkanLock}; @@ -667,6 +616,7 @@ VkResult layer_vkEnumerateDeviceExtensionProperties_default(VkPhysicalDevice gpu // For other cases forward to the driver to handle it assert(!pLayerName); + assert(gpu); // Hold the lock to access layer-wide global store std::unique_lock lock {g_vulkanLock};