Add placeholder dummy function pointers in DispatchLoaderDynamic for not defined platforms.

- Prevents function offset differences in case of (erroneous) different definitions of platform in different translation units.

Resolves #887
This commit is contained in:
asuessenbach 2021-03-01 12:30:23 +01:00
parent e7bec052db
commit c376dff68c
2 changed files with 84 additions and 7 deletions

View File

@ -2058,6 +2058,8 @@ void VulkanHppGenerator::appendDispatchLoaderDynamic( std::string & str )
class DispatchLoaderDynamic
{
public:
using PFN_dummy = void ( * )();
)";
std::string emptyFunctions;
@ -2300,7 +2302,12 @@ void VulkanHppGenerator::appendDispatchLoaderDynamicCommand( std::string &
std::string enter, leave;
std::tie( enter, leave ) = generateProtection( commandData.feature, commandData.extensions );
str += enter + " PFN_" + commandName + " " + commandName + " = 0;\n" + leave;
std::string command = " PFN_" + commandName + " " + commandName + " = 0;\n";
if ( !enter.empty() )
{
command = enter + command + "#else\n PFN_dummy placeholder_dont_call_" + commandName + " = 0;\n" + leave;
}
str += command;
bool isDeviceFunction = !commandData.handle.empty() && !commandData.params.empty() &&
( m_handles.find( commandData.params[0].type.type ) != m_handles.end() ) &&

View File

@ -67,7 +67,7 @@
#endif
#if VULKAN_HPP_ENABLE_DYNAMIC_LOADER_TOOL == 1
# if defined( __linux__ ) || defined( __APPLE__ )
# if defined( __linux__ ) || defined( __APPLE__ ) || defined( __QNXNTO__ )
# include <dlfcn.h>
# elif defined( _WIN32 )
typedef struct HINSTANCE__ * HINSTANCE;
@ -111286,7 +111286,7 @@ namespace VULKAN_HPP_NAMESPACE
{
if ( !vulkanLibraryName.empty() )
{
# if defined( __linux__ ) || defined( __APPLE__ )
# if defined( __linux__ ) || defined( __APPLE__ ) || defined( __QNXNTO__ )
m_library = dlopen( vulkanLibraryName.c_str(), RTLD_NOW | RTLD_LOCAL );
# elif defined( _WIN32 )
m_library = ::LoadLibraryA( vulkanLibraryName.c_str() );
@ -111296,7 +111296,7 @@ namespace VULKAN_HPP_NAMESPACE
}
else
{
# if defined( __linux__ )
# if defined( __linux__ ) || defined( __QNXNTO__ )
m_library = dlopen( "libvulkan.so", RTLD_NOW | RTLD_LOCAL );
if ( m_library == nullptr )
{
@ -111340,7 +111340,7 @@ namespace VULKAN_HPP_NAMESPACE
{
if ( m_library )
{
# if defined( __linux__ ) || defined( __APPLE__ )
# if defined( __linux__ ) || defined( __APPLE__ ) || defined( __QNXNTO__ )
dlclose( m_library );
# elif defined( _WIN32 )
::FreeLibrary( m_library );
@ -111353,7 +111353,7 @@ namespace VULKAN_HPP_NAMESPACE
template <typename T>
T getProcAddress( const char * function ) const VULKAN_HPP_NOEXCEPT
{
# if defined( __linux__ ) || defined( __APPLE__ )
# if defined( __linux__ ) || defined( __APPLE__ ) || defined( __QNXNTO__ )
return (T)dlsym( m_library, function );
# elif defined( _WIN32 )
return ( T )::GetProcAddress( m_library, function );
@ -111368,7 +111368,7 @@ namespace VULKAN_HPP_NAMESPACE
}
private:
# if defined( __linux__ ) || defined( __APPLE__ )
# if defined( __linux__ ) || defined( __APPLE__ ) || defined( __QNXNTO__ )
void * m_library;
# elif defined( _WIN32 )
::HINSTANCE m_library;
@ -111381,8 +111381,12 @@ namespace VULKAN_HPP_NAMESPACE
class DispatchLoaderDynamic
{
public:
using PFN_dummy = void ( * )();
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkAcquireFullScreenExclusiveModeEXT vkAcquireFullScreenExclusiveModeEXT = 0;
#else
PFN_dummy placeholder_dont_call_vkAcquireFullScreenExclusiveModeEXT = 0;
#endif /*VK_USE_PLATFORM_WIN32_KHR*/
PFN_vkAcquireNextImage2KHR vkAcquireNextImage2KHR = 0;
PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR = 0;
@ -111390,9 +111394,13 @@ namespace VULKAN_HPP_NAMESPACE
PFN_vkAcquireProfilingLockKHR vkAcquireProfilingLockKHR = 0;
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkAcquireWinrtDisplayNV vkAcquireWinrtDisplayNV = 0;
#else
PFN_dummy placeholder_dont_call_vkAcquireWinrtDisplayNV = 0;
#endif /*VK_USE_PLATFORM_WIN32_KHR*/
#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
PFN_vkAcquireXlibDisplayEXT vkAcquireXlibDisplayEXT = 0;
#else
PFN_dummy placeholder_dont_call_vkAcquireXlibDisplayEXT = 0;
#endif /*VK_USE_PLATFORM_XLIB_XRANDR_EXT*/
PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers = 0;
PFN_vkAllocateDescriptorSets vkAllocateDescriptorSets = 0;
@ -111548,6 +111556,8 @@ namespace VULKAN_HPP_NAMESPACE
PFN_vkCreateAccelerationStructureNV vkCreateAccelerationStructureNV = 0;
#ifdef VK_USE_PLATFORM_ANDROID_KHR
PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR = 0;
#else
PFN_dummy placeholder_dont_call_vkCreateAndroidSurfaceKHR = 0;
#endif /*VK_USE_PLATFORM_ANDROID_KHR*/
PFN_vkCreateBuffer vkCreateBuffer = 0;
PFN_vkCreateBufferView vkCreateBufferView = 0;
@ -111563,6 +111573,8 @@ namespace VULKAN_HPP_NAMESPACE
PFN_vkCreateDevice vkCreateDevice = 0;
#ifdef VK_USE_PLATFORM_DIRECTFB_EXT
PFN_vkCreateDirectFBSurfaceEXT vkCreateDirectFBSurfaceEXT = 0;
#else
PFN_dummy placeholder_dont_call_vkCreateDirectFBSurfaceEXT = 0;
#endif /*VK_USE_PLATFORM_DIRECTFB_EXT*/
PFN_vkCreateDisplayModeKHR vkCreateDisplayModeKHR = 0;
PFN_vkCreateDisplayPlaneSurfaceKHR vkCreateDisplayPlaneSurfaceKHR = 0;
@ -111573,19 +111585,27 @@ namespace VULKAN_HPP_NAMESPACE
PFN_vkCreateHeadlessSurfaceEXT vkCreateHeadlessSurfaceEXT = 0;
#ifdef VK_USE_PLATFORM_IOS_MVK
PFN_vkCreateIOSSurfaceMVK vkCreateIOSSurfaceMVK = 0;
#else
PFN_dummy placeholder_dont_call_vkCreateIOSSurfaceMVK = 0;
#endif /*VK_USE_PLATFORM_IOS_MVK*/
PFN_vkCreateImage vkCreateImage = 0;
#ifdef VK_USE_PLATFORM_FUCHSIA
PFN_vkCreateImagePipeSurfaceFUCHSIA vkCreateImagePipeSurfaceFUCHSIA = 0;
#else
PFN_dummy placeholder_dont_call_vkCreateImagePipeSurfaceFUCHSIA = 0;
#endif /*VK_USE_PLATFORM_FUCHSIA*/
PFN_vkCreateImageView vkCreateImageView = 0;
PFN_vkCreateIndirectCommandsLayoutNV vkCreateIndirectCommandsLayoutNV = 0;
PFN_vkCreateInstance vkCreateInstance = 0;
#ifdef VK_USE_PLATFORM_MACOS_MVK
PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK = 0;
#else
PFN_dummy placeholder_dont_call_vkCreateMacOSSurfaceMVK = 0;
#endif /*VK_USE_PLATFORM_MACOS_MVK*/
#ifdef VK_USE_PLATFORM_METAL_EXT
PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT = 0;
#else
PFN_dummy placeholder_dont_call_vkCreateMetalSurfaceEXT = 0;
#endif /*VK_USE_PLATFORM_METAL_EXT*/
PFN_vkCreatePipelineCache vkCreatePipelineCache = 0;
PFN_vkCreatePipelineLayout vkCreatePipelineLayout = 0;
@ -111604,23 +111624,35 @@ namespace VULKAN_HPP_NAMESPACE
PFN_vkCreateSharedSwapchainsKHR vkCreateSharedSwapchainsKHR = 0;
#ifdef VK_USE_PLATFORM_GGP
PFN_vkCreateStreamDescriptorSurfaceGGP vkCreateStreamDescriptorSurfaceGGP = 0;
#else
PFN_dummy placeholder_dont_call_vkCreateStreamDescriptorSurfaceGGP = 0;
#endif /*VK_USE_PLATFORM_GGP*/
PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR = 0;
PFN_vkCreateValidationCacheEXT vkCreateValidationCacheEXT = 0;
#ifdef VK_USE_PLATFORM_VI_NN
PFN_vkCreateViSurfaceNN vkCreateViSurfaceNN = 0;
#else
PFN_dummy placeholder_dont_call_vkCreateViSurfaceNN = 0;
#endif /*VK_USE_PLATFORM_VI_NN*/
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR = 0;
#else
PFN_dummy placeholder_dont_call_vkCreateWaylandSurfaceKHR = 0;
#endif /*VK_USE_PLATFORM_WAYLAND_KHR*/
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR = 0;
#else
PFN_dummy placeholder_dont_call_vkCreateWin32SurfaceKHR = 0;
#endif /*VK_USE_PLATFORM_WIN32_KHR*/
#ifdef VK_USE_PLATFORM_XCB_KHR
PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR = 0;
#else
PFN_dummy placeholder_dont_call_vkCreateXcbSurfaceKHR = 0;
#endif /*VK_USE_PLATFORM_XCB_KHR*/
#ifdef VK_USE_PLATFORM_XLIB_KHR
PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR = 0;
#else
PFN_dummy placeholder_dont_call_vkCreateXlibSurfaceKHR = 0;
#endif /*VK_USE_PLATFORM_XLIB_KHR*/
PFN_vkDebugMarkerSetObjectNameEXT vkDebugMarkerSetObjectNameEXT = 0;
PFN_vkDebugMarkerSetObjectTagEXT vkDebugMarkerSetObjectTagEXT = 0;
@ -111683,6 +111715,8 @@ namespace VULKAN_HPP_NAMESPACE
PFN_vkGetAccelerationStructureMemoryRequirementsNV vkGetAccelerationStructureMemoryRequirementsNV = 0;
#ifdef VK_USE_PLATFORM_ANDROID_KHR
PFN_vkGetAndroidHardwareBufferPropertiesANDROID vkGetAndroidHardwareBufferPropertiesANDROID = 0;
#else
PFN_dummy placeholder_dont_call_vkGetAndroidHardwareBufferPropertiesANDROID = 0;
#endif /*VK_USE_PLATFORM_ANDROID_KHR*/
PFN_vkGetBufferDeviceAddressEXT vkGetBufferDeviceAddressEXT = 0;
PFN_vkGetBufferDeviceAddressKHR vkGetBufferDeviceAddressKHR = 0;
@ -111703,6 +111737,8 @@ namespace VULKAN_HPP_NAMESPACE
PFN_vkGetDeviceGroupPresentCapabilitiesKHR vkGetDeviceGroupPresentCapabilitiesKHR = 0;
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkGetDeviceGroupSurfacePresentModes2EXT vkGetDeviceGroupSurfacePresentModes2EXT = 0;
#else
PFN_dummy placeholder_dont_call_vkGetDeviceGroupSurfacePresentModes2EXT = 0;
#endif /*VK_USE_PLATFORM_WIN32_KHR*/
PFN_vkGetDeviceGroupSurfacePresentModesKHR vkGetDeviceGroupSurfacePresentModesKHR = 0;
PFN_vkGetDeviceMemoryCommitment vkGetDeviceMemoryCommitment = 0;
@ -111721,6 +111757,8 @@ namespace VULKAN_HPP_NAMESPACE
PFN_vkGetFenceStatus vkGetFenceStatus = 0;
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkGetFenceWin32HandleKHR vkGetFenceWin32HandleKHR = 0;
#else
PFN_dummy placeholder_dont_call_vkGetFenceWin32HandleKHR = 0;
#endif /*VK_USE_PLATFORM_WIN32_KHR*/
PFN_vkGetGeneratedCommandsMemoryRequirementsNV vkGetGeneratedCommandsMemoryRequirementsNV = 0;
PFN_vkGetImageDrmFormatModifierPropertiesEXT vkGetImageDrmFormatModifierPropertiesEXT = 0;
@ -111736,18 +111774,26 @@ namespace VULKAN_HPP_NAMESPACE
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = 0;
#ifdef VK_USE_PLATFORM_ANDROID_KHR
PFN_vkGetMemoryAndroidHardwareBufferANDROID vkGetMemoryAndroidHardwareBufferANDROID = 0;
#else
PFN_dummy placeholder_dont_call_vkGetMemoryAndroidHardwareBufferANDROID = 0;
#endif /*VK_USE_PLATFORM_ANDROID_KHR*/
PFN_vkGetMemoryFdKHR vkGetMemoryFdKHR = 0;
PFN_vkGetMemoryFdPropertiesKHR vkGetMemoryFdPropertiesKHR = 0;
PFN_vkGetMemoryHostPointerPropertiesEXT vkGetMemoryHostPointerPropertiesEXT = 0;
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkGetMemoryWin32HandleKHR vkGetMemoryWin32HandleKHR = 0;
#else
PFN_dummy placeholder_dont_call_vkGetMemoryWin32HandleKHR = 0;
#endif /*VK_USE_PLATFORM_WIN32_KHR*/
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkGetMemoryWin32HandleNV vkGetMemoryWin32HandleNV = 0;
#else
PFN_dummy placeholder_dont_call_vkGetMemoryWin32HandleNV = 0;
#endif /*VK_USE_PLATFORM_WIN32_KHR*/
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkGetMemoryWin32HandlePropertiesKHR vkGetMemoryWin32HandlePropertiesKHR = 0;
#else
PFN_dummy placeholder_dont_call_vkGetMemoryWin32HandlePropertiesKHR = 0;
#endif /*VK_USE_PLATFORM_WIN32_KHR*/
PFN_vkGetPastPresentationTimingGOOGLE vkGetPastPresentationTimingGOOGLE = 0;
PFN_vkGetPerformanceParameterINTEL vkGetPerformanceParameterINTEL = 0;
@ -111755,6 +111801,8 @@ namespace VULKAN_HPP_NAMESPACE
PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV vkGetPhysicalDeviceCooperativeMatrixPropertiesNV = 0;
#ifdef VK_USE_PLATFORM_DIRECTFB_EXT
PFN_vkGetPhysicalDeviceDirectFBPresentationSupportEXT vkGetPhysicalDeviceDirectFBPresentationSupportEXT = 0;
#else
PFN_dummy placeholder_dont_call_vkGetPhysicalDeviceDirectFBPresentationSupportEXT = 0;
#endif /*VK_USE_PLATFORM_DIRECTFB_EXT*/
PFN_vkGetPhysicalDeviceDisplayPlaneProperties2KHR vkGetPhysicalDeviceDisplayPlaneProperties2KHR = 0;
PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR vkGetPhysicalDeviceDisplayPlanePropertiesKHR = 0;
@ -111802,21 +111850,31 @@ namespace VULKAN_HPP_NAMESPACE
PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR = 0;
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkGetPhysicalDeviceSurfacePresentModes2EXT vkGetPhysicalDeviceSurfacePresentModes2EXT = 0;
#else
PFN_dummy placeholder_dont_call_vkGetPhysicalDeviceSurfacePresentModes2EXT = 0;
#endif /*VK_USE_PLATFORM_WIN32_KHR*/
PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR = 0;
PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupportKHR = 0;
PFN_vkGetPhysicalDeviceToolPropertiesEXT vkGetPhysicalDeviceToolPropertiesEXT = 0;
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR vkGetPhysicalDeviceWaylandPresentationSupportKHR = 0;
#else
PFN_dummy placeholder_dont_call_vkGetPhysicalDeviceWaylandPresentationSupportKHR = 0;
#endif /*VK_USE_PLATFORM_WAYLAND_KHR*/
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR vkGetPhysicalDeviceWin32PresentationSupportKHR = 0;
#else
PFN_dummy placeholder_dont_call_vkGetPhysicalDeviceWin32PresentationSupportKHR = 0;
#endif /*VK_USE_PLATFORM_WIN32_KHR*/
#ifdef VK_USE_PLATFORM_XCB_KHR
PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR vkGetPhysicalDeviceXcbPresentationSupportKHR = 0;
#else
PFN_dummy placeholder_dont_call_vkGetPhysicalDeviceXcbPresentationSupportKHR = 0;
#endif /*VK_USE_PLATFORM_XCB_KHR*/
#ifdef VK_USE_PLATFORM_XLIB_KHR
PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR vkGetPhysicalDeviceXlibPresentationSupportKHR = 0;
#else
PFN_dummy placeholder_dont_call_vkGetPhysicalDeviceXlibPresentationSupportKHR = 0;
#endif /*VK_USE_PLATFORM_XLIB_KHR*/
PFN_vkGetPipelineCacheData vkGetPipelineCacheData = 0;
PFN_vkGetPipelineExecutableInternalRepresentationsKHR vkGetPipelineExecutableInternalRepresentationsKHR = 0;
@ -111828,6 +111886,8 @@ namespace VULKAN_HPP_NAMESPACE
PFN_vkGetQueueCheckpointDataNV vkGetQueueCheckpointDataNV = 0;
#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
PFN_vkGetRandROutputDisplayEXT vkGetRandROutputDisplayEXT = 0;
#else
PFN_dummy placeholder_dont_call_vkGetRandROutputDisplayEXT = 0;
#endif /*VK_USE_PLATFORM_XLIB_XRANDR_EXT*/
PFN_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR vkGetRayTracingCaptureReplayShaderGroupHandlesKHR = 0;
PFN_vkGetRayTracingShaderGroupHandlesNV vkGetRayTracingShaderGroupHandlesNV = 0;
@ -111840,6 +111900,8 @@ namespace VULKAN_HPP_NAMESPACE
PFN_vkGetSemaphoreFdKHR vkGetSemaphoreFdKHR = 0;
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkGetSemaphoreWin32HandleKHR vkGetSemaphoreWin32HandleKHR = 0;
#else
PFN_dummy placeholder_dont_call_vkGetSemaphoreWin32HandleKHR = 0;
#endif /*VK_USE_PLATFORM_WIN32_KHR*/
PFN_vkGetShaderInfoAMD vkGetShaderInfoAMD = 0;
PFN_vkGetSwapchainCounterEXT vkGetSwapchainCounterEXT = 0;
@ -111848,14 +111910,20 @@ namespace VULKAN_HPP_NAMESPACE
PFN_vkGetValidationCacheDataEXT vkGetValidationCacheDataEXT = 0;
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkGetWinrtDisplayNV vkGetWinrtDisplayNV = 0;
#else
PFN_dummy placeholder_dont_call_vkGetWinrtDisplayNV = 0;
#endif /*VK_USE_PLATFORM_WIN32_KHR*/
PFN_vkImportFenceFdKHR vkImportFenceFdKHR = 0;
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkImportFenceWin32HandleKHR vkImportFenceWin32HandleKHR = 0;
#else
PFN_dummy placeholder_dont_call_vkImportFenceWin32HandleKHR = 0;
#endif /*VK_USE_PLATFORM_WIN32_KHR*/
PFN_vkImportSemaphoreFdKHR vkImportSemaphoreFdKHR = 0;
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkImportSemaphoreWin32HandleKHR vkImportSemaphoreWin32HandleKHR = 0;
#else
PFN_dummy placeholder_dont_call_vkImportSemaphoreWin32HandleKHR = 0;
#endif /*VK_USE_PLATFORM_WIN32_KHR*/
PFN_vkInitializePerformanceApiINTEL vkInitializePerformanceApiINTEL = 0;
PFN_vkInvalidateMappedMemoryRanges vkInvalidateMappedMemoryRanges = 0;
@ -111876,6 +111944,8 @@ namespace VULKAN_HPP_NAMESPACE
PFN_vkReleaseDisplayEXT vkReleaseDisplayEXT = 0;
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkReleaseFullScreenExclusiveModeEXT vkReleaseFullScreenExclusiveModeEXT = 0;
#else
PFN_dummy placeholder_dont_call_vkReleaseFullScreenExclusiveModeEXT = 0;
#endif /*VK_USE_PLATFORM_WIN32_KHR*/
PFN_vkReleasePerformanceConfigurationINTEL vkReleasePerformanceConfigurationINTEL = 0;
PFN_vkReleaseProfilingLockKHR vkReleaseProfilingLockKHR = 0;