From 31a9345189ea041da798cf99b18c4e53571f53f1 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 16 Feb 2023 19:39:27 +0100 Subject: [PATCH 1/2] Disable AMD switchable graphics on Windows with Vulkan to fix driver issue This is a required workaround on setups with AMD integrated graphics + NVIDIA dedicated GPU to be able to start the engine with the Forward+ or Forward Mobile rendering methods. While a AMD driver update can resolve this issue, it still gets reported regularly and is likely to become a source of support headache for people distributing projects made with Godot (as this also affects exported projects). --- platform/windows/os_windows.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index d384049fb5d8..84f64f9fe18a 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -151,6 +151,11 @@ static void _error_handler(void *p_self, const char *p_func, const char *p_file, void OS_Windows::initialize() { crash_handler.initialize(); + // Workaround for Vulkan not working on setups with AMD integrated graphics + NVIDIA dedicated GPU (GH-57708). + // This prevents using AMD integrated graphics with Vulkan entirely, but it allows the engine to start + // even on outdated/broken driver setups. + OS::get_singleton()->set_environment("DISABLE_LAYER_AMD_SWITCHABLE_GRAPHICS_1", "1"); + #ifdef WINDOWS_DEBUG_OUTPUT_ENABLED error_handlers.errfunc = _error_handler; error_handlers.userdata = this; From 950c5b57e498c81309f27d2e6114d2653a9b6bdd Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Fri, 17 Feb 2023 17:47:55 +0100 Subject: [PATCH 2/2] Move code to Windows Vulkan context initialization context This workaround is not needed for rendering drivers other than Vulkan. --- platform/windows/os_windows.cpp | 5 ----- platform/windows/vulkan_context_win.cpp | 4 ++++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 84f64f9fe18a..d384049fb5d8 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -151,11 +151,6 @@ static void _error_handler(void *p_self, const char *p_func, const char *p_file, void OS_Windows::initialize() { crash_handler.initialize(); - // Workaround for Vulkan not working on setups with AMD integrated graphics + NVIDIA dedicated GPU (GH-57708). - // This prevents using AMD integrated graphics with Vulkan entirely, but it allows the engine to start - // even on outdated/broken driver setups. - OS::get_singleton()->set_environment("DISABLE_LAYER_AMD_SWITCHABLE_GRAPHICS_1", "1"); - #ifdef WINDOWS_DEBUG_OUTPUT_ENABLED error_handlers.errfunc = _error_handler; error_handlers.userdata = this; diff --git a/platform/windows/vulkan_context_win.cpp b/platform/windows/vulkan_context_win.cpp index cf4383fc331e..4c1e6eebe4f2 100644 --- a/platform/windows/vulkan_context_win.cpp +++ b/platform/windows/vulkan_context_win.cpp @@ -55,6 +55,10 @@ Error VulkanContextWindows::window_create(DisplayServer::WindowID p_window_id, D } VulkanContextWindows::VulkanContextWindows() { + // Workaround for Vulkan not working on setups with AMD integrated graphics + NVIDIA dedicated GPU (GH-57708). + // This prevents using AMD integrated graphics with Vulkan entirely, but it allows the engine to start + // even on outdated/broken driver setups. + OS::get_singleton()->set_environment("DISABLE_LAYER_AMD_SWITCHABLE_GRAPHICS_1", "1"); } VulkanContextWindows::~VulkanContextWindows() {