vk_platform: Remove workaround to use Vulkan loader on macOS. (#3484)

This commit is contained in:
squidbus
2025-08-29 18:29:34 -07:00
committed by GitHub
parent 32244c097c
commit 673b2afaa8

View File

@@ -226,8 +226,7 @@ vk::UniqueInstance CreateInstance(Frontend::WindowSystemType window_type, bool e
bool enable_crash_diagnostic) { bool enable_crash_diagnostic) {
LOG_INFO(Render_Vulkan, "Creating vulkan instance"); LOG_INFO(Render_Vulkan, "Creating vulkan instance");
#ifdef __APPLE__ #if defined(__APPLE__) && !defined(ENABLE_QT_GUI)
#ifndef ENABLE_QT_GUI
// Initialize the environment with the path to the MoltenVK ICD, so that the loader will // Initialize the environment with the path to the MoltenVK ICD, so that the loader will
// find it. // find it.
static const auto icd_path = [] { static const auto icd_path = [] {
@@ -238,17 +237,8 @@ vk::UniqueInstance CreateInstance(Frontend::WindowSystemType window_type, bool e
}(); }();
setenv("VK_DRIVER_FILES", icd_path.c_str(), true); setenv("VK_DRIVER_FILES", icd_path.c_str(), true);
#endif #endif
// If the Vulkan loader exists in /usr/local/lib, give it priority. The Vulkan SDK
// installs it here by default, but it is not in the default library search path.
// The loader has a clause to check for it, but at a lower priority than the bundled
// libMoltenVK.dylib, so we need to handle it ourselves to give it priority.
static const std::string usr_local_path = "/usr/local/lib/libvulkan.dylib";
static vk::detail::DynamicLoader dl = std::filesystem::exists(usr_local_path)
? vk::detail::DynamicLoader(usr_local_path)
: vk::detail::DynamicLoader();
#else
static vk::detail::DynamicLoader dl; static vk::detail::DynamicLoader dl;
#endif
VULKAN_HPP_DEFAULT_DISPATCHER.init( VULKAN_HPP_DEFAULT_DISPATCHER.init(
dl.getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr")); dl.getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr"));