diff --git a/CMakeLists.txt b/CMakeLists.txt index 38e7a4e274559837068fc999059969fdbe95e92f..6436cccf973da5351150f5e1999d4869f822518e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -343,6 +343,8 @@ if(Vulkan_FOUND) add_definitions(-DHAS_VULKAN) include_directories(${Vulkan_INCLUDE_DIR}) endif() +# Define PREFER_VULKAN to prefer Vulkan over the default API +# on GNU/Linux and Windows. Metal is always preferred on macOS. if(MSVC) set(WINDOWS_SYS_LIBS diff --git a/src/app/main.cpp b/src/app/main.cpp index df808d0306c5841510a7061cb06ea1877c3291ac..2d0cdd0f94337955523888d30162c8f44b841920 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -93,7 +93,7 @@ main(int argc, char* argv[]) } #else if (std::invoke([] { -#if defined(HAS_VULKAN) && !defined(Q_OS_LINUX) +#if defined(HAS_VULKAN) && defined(PREFER_VULKAN) // Somehow, several bug reports show that, on Windows, QVulkanInstance // verification passes, but goes on to fail when creating the QQuickWindow // with "Failed to initialize graphics backend for Vulkan". @@ -119,8 +119,6 @@ main(int argc, char* argv[]) // removed. So we need to re-implement this (custom controls) // or wait for a future version QQuickWindow::setGraphicsApi(QSGRendererInterface::VulkanRhi); - } else { - QQuickWindow::setGraphicsApi(QSGRendererInterface::Unknown); } #endif