Skip to content

Commit

Permalink
MoltenVK: Use an external project instead of a pre-compiled dylib
Browse files Browse the repository at this point in the history
Also, update MoltenVK to match Vulkan SDK 1.2.182.
  • Loading branch information
OatmealDome committed Jul 31, 2021
1 parent c86c02e commit 18d71b5
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,10 @@ add_subdirectory(Externals/glslang)

if(ENABLE_VULKAN)
add_definitions(-DHAS_VULKAN)

if(APPLE)
add_subdirectory(Externals/MoltenVK)
endif()
endif()

if(NOT WIN32 OR (NOT (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")))
Expand Down
15 changes: 15 additions & 0 deletions Externals/MoltenVK/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
include(ExternalProject)

ExternalProject_Add(MoltenVK
GIT_REPOSITORY https://github.com/KhronosGroup/MoltenVK.git
GIT_TAG v1.1.4

CONFIGURE_COMMAND cd <SOURCE_DIR> && ./fetchDependencies --macos

BUILD_COMMAND make -C <SOURCE_DIR> macos

INSTALL_COMMAND ""

LOG_CONFIGURE ON
LOG_BUILD ON
)
Binary file removed Externals/MoltenVK/libvulkan.dylib
Binary file not shown.
1 change: 0 additions & 1 deletion Externals/MoltenVK/version.txt

This file was deleted.

8 changes: 6 additions & 2 deletions Source/Core/DolphinQt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,12 @@ if(APPLE)
endforeach()

# Copy MoltenVK into the bundle
target_sources(dolphin-emu PRIVATE "${CMAKE_SOURCE_DIR}/Externals/MoltenVK/libvulkan.dylib")
set_source_files_properties("${CMAKE_SOURCE_DIR}/Externals/MoltenVK/libvulkan.dylib" PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks)
if(ENABLE_VULKAN)
add_dependencies(dolphin-emu MoltenVK)
ExternalProject_Get_Property(MoltenVK SOURCE_DIR)
target_sources(dolphin-emu PRIVATE "${SOURCE_DIR}/Package/Release/MoltenVK/dylib/macOS/libMoltenVK.dylib")
set_source_files_properties("${SOURCE_DIR}/Package/Release/MoltenVK/dylib/macOS/libMoltenVK.dylib" PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks)
endif()

# Update library references to make the bundle portable
include(DolphinPostprocessBundle)
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ static bool OpenVulkanLibrary()
if (libvulkan_env && s_vulkan_module.Open(libvulkan_env))
return true;

// Use the libvulkan.dylib from the application bundle.
std::string filename = File::GetBundleDirectory() + "/Contents/Frameworks/libvulkan.dylib";
// Use the libMoltenVK.dylib from the application bundle.
std::string filename = File::GetBundleDirectory() + "/Contents/Frameworks/libMoltenVK.dylib";
return s_vulkan_module.Open(filename.c_str());
#else
std::string filename = Common::DynamicLibrary::GetVersionedFilename("vulkan", 1);
Expand Down

0 comments on commit 18d71b5

Please sign in to comment.