Index: libraries/osx/build-osx-libs.sh =================================================================== --- libraries/osx/build-osx-libs.sh +++ libraries/osx/build-osx-libs.sh @@ -48,6 +48,7 @@ MINIUPNPC_VERSION="miniupnpc-2.2.2" SODIUM_VERSION="libsodium-1.0.18" FMT_VERSION="7.1.3" +MOLTENVK_VERSION="1.2.1" # -------------------------------------------------------------- # Bundled with the game: # * SpiderMonkey @@ -1039,6 +1040,33 @@ fi popd > /dev/null +# -------------------------------------------------------------- +echo -e "Building Molten VK..." +LIB_DIRECTORY="MoltenVK-$MOLTENVK_VERSION" +LIB_ARCHIVE="MoltenVK-$MOLTENVK_VERSION.tar.gz" +LIB_URL="https://releases.wildfiregames.com/libs/" + +mkdir -p "molten-vk" +pushd "molten-vk" > /dev/null +if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$MOLTENVK_VERSION" ]] +then + INSTALL_DIR="../../../../binaries/system/" + rm -f .already-built + download_lib $LIB_URL $LIB_ARCHIVE + rm -rf "$LIB_DIRECTORY" + tar -xf $LIB_ARCHIVE + pushd $LIB_DIRECTORY + # The CI cannot build MoltenVK so we provide prebuild binaries instead. + # Use mv instead of copy to preserve binary integrity. See + # https://developer.apple.com/forums/thread/130313?answerId=410541022#410541022 + mv dylib/libMoltenVK.dylib $INSTALL_DIR + popd > /dev/null + echo "$MOLTENVK_VERSION" > .already-built +else + already_built +fi +popd > /dev/null + # -------------------------------------------------------------------- # The following libraries are shared on different OSes and may # be customized, so we build and install them from bundled sources Index: source/ps/VideoMode.h =================================================================== --- source/ps/VideoMode.h +++ source/ps/VideoMode.h @@ -19,6 +19,10 @@ #define INCLUDED_VIDEOMODE #include "ps/CStrForward.h" +#include "lib/sysdep/os.h" +#if OS_MACOSX +#include "ps/DllLoader.h" +#endif #include "renderer/backend/Backend.h" #include @@ -178,6 +182,10 @@ Renderer::Backend::Backend m_Backend = Renderer::Backend::Backend::GL; std::unique_ptr m_BackendDevice; + +#if OS_MACOSX + std::unique_ptr m_DllLoader; +#endif }; extern CVideoMode g_VideoMode; Index: source/ps/VideoMode.cpp =================================================================== --- source/ps/VideoMode.cpp +++ source/ps/VideoMode.cpp @@ -23,7 +23,6 @@ #include "gui/GUIManager.h" #include "lib/config2.h" #include "lib/external_libraries/libsdl.h" -#include "lib/sysdep/os.h" #include "lib/tex/tex.h" #include "ps/CConsole.h" #include "ps/CLogger.h" @@ -391,6 +390,24 @@ flags |= SDL_WINDOW_VULKAN; m_WindowedX = m_WindowedY = SDL_WINDOWPOS_CENTERED_DISPLAY(m_ConfigDisplay); +#if OS_MACOSX + if (m_Backend == Renderer::Backend::Backend::VULKAN) + { + if (!m_DllLoader) + m_DllLoader = std::make_unique("MoltenVK", CLogger::Normal); + + if (!m_DllLoader->IsLoaded()) + m_DllLoader->LoadDLL(); + + if (!m_DllLoader->IsLoaded()) + { + LOGWARNING("Failed to load libMoltenVK.dylib."); + DowngradeBackendSettingAfterCreationFailure(); + return SetVideoMode(w, h, bpp, fullscreen); + } + } +#endif + m_Window = SDL_CreateWindow(main_window_name, m_WindowedX, m_WindowedY, w, h, flags); if (!m_Window) { Index: source/tools/dist/build-osx-bundle.py =================================================================== --- source/tools/dist/build-osx-bundle.py +++ source/tools/dist/build-osx-bundle.py @@ -60,6 +60,7 @@ print("Copying libs") shutil.copy("binaries/system/libAtlasUI.dylib", BUNDLE_FRAMEWORKS) shutil.copy("binaries/system/libCollada.dylib", BUNDLE_FRAMEWORKS) +shutil.copy("binaries/system/libMoltenVK.dylib", BUNDLE_FRAMEWORKS) if not args.dev: print("Copying archived game data from archives/")