diff --git a/snippets/DynamicLoader.hpp b/snippets/DynamicLoader.hpp index 3607b92..36e3511 100644 --- a/snippets/DynamicLoader.hpp +++ b/snippets/DynamicLoader.hpp @@ -10,37 +10,57 @@ { if ( !vulkanLibraryName.empty() ) { -# if defined( __unix__ ) || defined( __APPLE__ ) || defined( __QNX__ ) || defined(__Fuchsia__) - m_library = dlopen( vulkanLibraryName.c_str(), RTLD_NOW | RTLD_LOCAL ); -# elif defined( _WIN32 ) +# if defined( _WIN32 ) m_library = ::LoadLibraryA( vulkanLibraryName.c_str() ); +# elif defined( __unix__ ) || defined( __APPLE__ ) || defined( __QNX__ ) || defined(__Fuchsia__) + m_library = dlopen( vulkanLibraryName.c_str(), RTLD_NOW | RTLD_LOCAL ); # else # error unsupported platform # endif } else { -# if defined( __unix__ ) || defined( __QNX__ ) || defined(__Fuchsia__) +# if defined( _WIN32 ) + m_library = ::LoadLibraryA( "vulkan-1.dll" ); +# elif defined( __APPLE__ ) + m_library = dlopen( "libvulkan.dylib", RTLD_NOW | RTLD_LOCAL ); + if ( !m_library ) + { + m_library = dlopen( "libvulkan.1.dylib", RTLD_NOW | RTLD_LOCAL ); + } + if ( !m_library ) + { + m_library = dlopen( "libMoltenVK.dylib", RTLD_NOW | RTLD_LOCAL ); + } + // Add support for using Vulkan and MoltenVK in a Framework. App store rules for iOS + // strictly enforce no .dylib's. If they aren't found it just falls through + if ( !m_library ) + { + m_library = dlopen( "vulkan.framework/vulkan", RTLD_NOW | RTLD_LOCAL ); + } + if ( !m_library ) + { + m_library = dlopen( "MoltenVK.framework/MoltenVK", RTLD_NOW | RTLD_LOCAL ); + } + // modern versions of macOS don't search /usr/local/lib automatically contrary to what man dlopen says + // Vulkan SDK uses this as the system-wide installation location, so we're going to fallback to this if all else fails + if ( !m_library && ( getenv("DYLD_FALLBACK_LIBRARY_PATH") == NULL ) ) + { + m_library = dlopen( "/usr/local/lib/libvulkan.dylib", RTLD_NOW | RTLD_LOCAL ); + } +# elif defined( __unix__ ) || defined( __QNX__ ) || defined(__Fuchsia__) m_library = dlopen( "libvulkan.so", RTLD_NOW | RTLD_LOCAL ); - if ( m_library == nullptr ) + if ( !m_library ) { m_library = dlopen( "libvulkan.so.1", RTLD_NOW | RTLD_LOCAL ); } -# elif defined( __APPLE__ ) - m_library = dlopen( "libvulkan.dylib", RTLD_NOW | RTLD_LOCAL ); - if (m_library == nullptr) - { - m_library = dlopen("libvulkan.1.dylib", RTLD_NOW | RTLD_LOCAL); - } -# elif defined( _WIN32 ) - m_library = ::LoadLibraryA( "vulkan-1.dll" ); # else # error unsupported platform # endif } #ifndef VULKAN_HPP_NO_EXCEPTIONS - if ( m_library == nullptr ) + if ( !m_library ) { // NOTE there should be an InitializationFailedError, but msvc insists on the symbol does not exist within the scope of this function. throw std::runtime_error( "Failed to load vulkan library!" ); diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index 6ee70ed..91d031b 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -17175,37 +17175,57 @@ namespace VULKAN_HPP_NAMESPACE { if ( !vulkanLibraryName.empty() ) { -# if defined( __unix__ ) || defined( __APPLE__ ) || defined( __QNX__ ) || defined( __Fuchsia__ ) - m_library = dlopen( vulkanLibraryName.c_str(), RTLD_NOW | RTLD_LOCAL ); -# elif defined( _WIN32 ) +# if defined( _WIN32 ) m_library = ::LoadLibraryA( vulkanLibraryName.c_str() ); +# elif defined( __unix__ ) || defined( __APPLE__ ) || defined( __QNX__ ) || defined( __Fuchsia__ ) + m_library = dlopen( vulkanLibraryName.c_str(), RTLD_NOW | RTLD_LOCAL ); # else # error unsupported platform # endif } else { -# if defined( __unix__ ) || defined( __QNX__ ) || defined( __Fuchsia__ ) - m_library = dlopen( "libvulkan.so", RTLD_NOW | RTLD_LOCAL ); - if ( m_library == nullptr ) - { - m_library = dlopen( "libvulkan.so.1", RTLD_NOW | RTLD_LOCAL ); - } +# if defined( _WIN32 ) + m_library = ::LoadLibraryA( "vulkan-1.dll" ); # elif defined( __APPLE__ ) m_library = dlopen( "libvulkan.dylib", RTLD_NOW | RTLD_LOCAL ); - if ( m_library == nullptr ) + if ( !m_library ) { m_library = dlopen( "libvulkan.1.dylib", RTLD_NOW | RTLD_LOCAL ); } -# elif defined( _WIN32 ) - m_library = ::LoadLibraryA( "vulkan-1.dll" ); + if ( !m_library ) + { + m_library = dlopen( "libMoltenVK.dylib", RTLD_NOW | RTLD_LOCAL ); + } + // Add support for using Vulkan and MoltenVK in a Framework. App store rules for iOS + // strictly enforce no .dylib's. If they aren't found it just falls through + if ( !m_library ) + { + m_library = dlopen( "vulkan.framework/vulkan", RTLD_NOW | RTLD_LOCAL ); + } + if ( !m_library ) + { + m_library = dlopen( "MoltenVK.framework/MoltenVK", RTLD_NOW | RTLD_LOCAL ); + } + // modern versions of macOS don't search /usr/local/lib automatically contrary to what man dlopen says + // Vulkan SDK uses this as the system-wide installation location, so we're going to fallback to this if all else fails + if ( !m_library && ( getenv( "DYLD_FALLBACK_LIBRARY_PATH" ) == NULL ) ) + { + m_library = dlopen( "/usr/local/lib/libvulkan.dylib", RTLD_NOW | RTLD_LOCAL ); + } +# elif defined( __unix__ ) || defined( __QNX__ ) || defined( __Fuchsia__ ) + m_library = dlopen( "libvulkan.so", RTLD_NOW | RTLD_LOCAL ); + if ( !m_library ) + { + m_library = dlopen( "libvulkan.so.1", RTLD_NOW | RTLD_LOCAL ); + } # else # error unsupported platform # endif } # ifndef VULKAN_HPP_NO_EXCEPTIONS - if ( m_library == nullptr ) + if ( !m_library ) { // NOTE there should be an InitializationFailedError, but msvc insists on the symbol does not exist within the scope of this function. throw std::runtime_error( "Failed to load vulkan library!" ); diff --git a/vulkan/vulkansc.hpp b/vulkan/vulkansc.hpp index 6083e5c..775c586 100644 --- a/vulkan/vulkansc.hpp +++ b/vulkan/vulkansc.hpp @@ -7081,37 +7081,57 @@ namespace VULKAN_HPP_NAMESPACE { if ( !vulkanLibraryName.empty() ) { -# if defined( __unix__ ) || defined( __APPLE__ ) || defined( __QNX__ ) || defined( __Fuchsia__ ) - m_library = dlopen( vulkanLibraryName.c_str(), RTLD_NOW | RTLD_LOCAL ); -# elif defined( _WIN32 ) +# if defined( _WIN32 ) m_library = ::LoadLibraryA( vulkanLibraryName.c_str() ); +# elif defined( __unix__ ) || defined( __APPLE__ ) || defined( __QNX__ ) || defined( __Fuchsia__ ) + m_library = dlopen( vulkanLibraryName.c_str(), RTLD_NOW | RTLD_LOCAL ); # else # error unsupported platform # endif } else { -# if defined( __unix__ ) || defined( __QNX__ ) || defined( __Fuchsia__ ) - m_library = dlopen( "libvulkan.so", RTLD_NOW | RTLD_LOCAL ); - if ( m_library == nullptr ) - { - m_library = dlopen( "libvulkan.so.1", RTLD_NOW | RTLD_LOCAL ); - } +# if defined( _WIN32 ) + m_library = ::LoadLibraryA( "vulkan-1.dll" ); # elif defined( __APPLE__ ) m_library = dlopen( "libvulkan.dylib", RTLD_NOW | RTLD_LOCAL ); - if ( m_library == nullptr ) + if ( !m_library ) { m_library = dlopen( "libvulkan.1.dylib", RTLD_NOW | RTLD_LOCAL ); } -# elif defined( _WIN32 ) - m_library = ::LoadLibraryA( "vulkan-1.dll" ); + if ( !m_library ) + { + m_library = dlopen( "libMoltenVK.dylib", RTLD_NOW | RTLD_LOCAL ); + } + // Add support for using Vulkan and MoltenVK in a Framework. App store rules for iOS + // strictly enforce no .dylib's. If they aren't found it just falls through + if ( !m_library ) + { + m_library = dlopen( "vulkan.framework/vulkan", RTLD_NOW | RTLD_LOCAL ); + } + if ( !m_library ) + { + m_library = dlopen( "MoltenVK.framework/MoltenVK", RTLD_NOW | RTLD_LOCAL ); + } + // modern versions of macOS don't search /usr/local/lib automatically contrary to what man dlopen says + // Vulkan SDK uses this as the system-wide installation location, so we're going to fallback to this if all else fails + if ( !m_library && ( getenv( "DYLD_FALLBACK_LIBRARY_PATH" ) == NULL ) ) + { + m_library = dlopen( "/usr/local/lib/libvulkan.dylib", RTLD_NOW | RTLD_LOCAL ); + } +# elif defined( __unix__ ) || defined( __QNX__ ) || defined( __Fuchsia__ ) + m_library = dlopen( "libvulkan.so", RTLD_NOW | RTLD_LOCAL ); + if ( !m_library ) + { + m_library = dlopen( "libvulkan.so.1", RTLD_NOW | RTLD_LOCAL ); + } # else # error unsupported platform # endif } # ifndef VULKAN_HPP_NO_EXCEPTIONS - if ( m_library == nullptr ) + if ( !m_library ) { // NOTE there should be an InitializationFailedError, but msvc insists on the symbol does not exist within the scope of this function. throw std::runtime_error( "Failed to load vulkan library!" );