From 428c3e3426bb57212e716c8640a29b8259663015 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 20 Oct 2024 22:02:16 +1000 Subject: [PATCH] Host: Fix error when switching to surfaceless --- src/core/host.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/core/host.cpp b/src/core/host.cpp index b63071057..1d05b0a81 100644 --- a/src/core/host.cpp +++ b/src/core/host.cpp @@ -378,10 +378,19 @@ void Host::UpdateDisplayWindow(bool fullscreen) g_gpu_device->DestroyMainSwapChain(); Error error; - std::optional wi; - if (!(wi = Host::AcquireRenderWindow(g_gpu_device->GetRenderAPI(), fullscreen, fullscreen_mode.has_value(), &error)) - .has_value() || - !g_gpu_device->RecreateMainSwapChain(wi.value(), vsync_mode, allow_present_throttle, + std::optional wi = + Host::AcquireRenderWindow(g_gpu_device->GetRenderAPI(), fullscreen, fullscreen_mode.has_value(), &error); + if (!wi.has_value()) + { + Host::ReportFatalError("Failed to get render window after update", error.GetDescription()); + return; + } + + // if surfaceless, just leave it + if (wi->IsSurfaceless()) + return; + + if (!g_gpu_device->RecreateMainSwapChain(wi.value(), vsync_mode, allow_present_throttle, fullscreen_mode.has_value() ? &fullscreen_mode.value() : nullptr, exclusive_fullscreen_control, &error)) {