From 215cfd3dafbbd6ffdf3fd771dcac90cc19dffcd8 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 26 Aug 2022 21:59:17 +1000 Subject: [PATCH] NoGui: Fix renderer switching on Win32 --- src/duckstation-nogui/nogui_host.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/duckstation-nogui/nogui_host.cpp b/src/duckstation-nogui/nogui_host.cpp index 23f6a54e1..68ca5b898 100644 --- a/src/duckstation-nogui/nogui_host.cpp +++ b/src/duckstation-nogui/nogui_host.cpp @@ -91,7 +91,7 @@ static bool s_save_state_on_shutdown = false; static bool s_was_paused_by_focus_loss = false; static Threading::Thread s_cpu_thread; -static Threading::KernelSemaphore s_host_display_created; +static Threading::KernelSemaphore s_host_display_created_or_destroyed; static std::atomic_bool s_running{false}; static std::mutex s_cpu_thread_events_mutex; static std::condition_variable s_cpu_thread_event_done; @@ -726,10 +726,10 @@ bool NoGUIHost::AcquireHostDisplay(HostDisplay::RenderAPI api) g_nogui_window->DestroyPlatformWindow(); } - s_host_display_created.Post(); + s_host_display_created_or_destroyed.Post(); }); - s_host_display_created.Wait(); + s_host_display_created_or_destroyed.Wait(); if (!g_host_display) { @@ -781,7 +781,11 @@ void NoGUIHost::ReleaseHostDisplay() ImGuiManager::Shutdown(); g_host_display->DestroyRenderDevice(); g_host_display.reset(); - g_nogui_window->ExecuteInMessageLoop([]() { g_nogui_window->DestroyPlatformWindow(); }); + g_nogui_window->ExecuteInMessageLoop([]() { + g_nogui_window->DestroyPlatformWindow(); + s_host_display_created_or_destroyed.Post(); + }); + s_host_display_created_or_destroyed.Wait(); } void Host::ReleaseHostDisplay()