From 46e331d000e0af8986189fb937f2b68f7dcb9bd1 Mon Sep 17 00:00:00 2001 From: OatmealDome Date: Sun, 25 Jul 2021 16:11:01 -0400 Subject: [PATCH] VideoBackendBase: Prefer Vulkan over OGL on macOS Mojave and newer --- Source/Core/VideoCommon/VideoBackendBase.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Source/Core/VideoCommon/VideoBackendBase.cpp b/Source/Core/VideoCommon/VideoBackendBase.cpp index 1f93517dd1..cadbd08024 100644 --- a/Source/Core/VideoCommon/VideoBackendBase.cpp +++ b/Source/Core/VideoCommon/VideoBackendBase.cpp @@ -214,6 +214,10 @@ const std::vector>& VideoBackendBase::GetAvail std::vector> backends; // OGL > D3D11 > D3D12 > Vulkan > SW > Null + // + // On macOS Mojave and newer, we prefer Vulkan over OGL due to outdated drivers. + // However, on macOS High Sierra and older, we still prefer OGL due to its older Metal version + // missing several features required by the Vulkan backend. #ifdef HAS_OPENGL backends.push_back(std::make_unique()); #endif @@ -222,7 +226,18 @@ const std::vector>& VideoBackendBase::GetAvail backends.push_back(std::make_unique()); #endif #ifdef HAS_VULKAN - backends.push_back(std::make_unique()); +#ifdef __APPLE__ + // If we can run the Vulkan backend, emplace it at the beginning of the vector so + // it takes precedence over OpenGL. + if (__builtin_available(macOS 10.14, *)) + { + backends.emplace(backends.begin(), std::make_unique()); + } + else +#endif + { + backends.push_back(std::make_unique()); + } #endif #ifdef HAS_OPENGL backends.push_back(std::make_unique());