From ceb8006c3d8fc0a4e5a0fb27b8e68087eb96a1e5 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Tue, 24 Mar 2026 10:06:57 -0700 Subject: [PATCH] fix: prevent hang on FSR3 upscale context creation failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When ffxCreateContext for the upscaler fails (e.g. on NVIDIA with the AMD FidelityFX runtime), the shutdown() path called dlclose() on the runtime library which could hang — the library's global destructors may block waiting for GPU operations that never completed. Skip dlclose() on context creation failure: just clean up function pointers and mark as failed. The library stays loaded (harmless) and the game continues with FSR2 fallback instead of hanging. --- src/rendering/amd_fsr3_runtime.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/rendering/amd_fsr3_runtime.cpp b/src/rendering/amd_fsr3_runtime.cpp index 26fc5ce1..469056d9 100644 --- a/src/rendering/amd_fsr3_runtime.cpp +++ b/src/rendering/amd_fsr3_runtime.cpp @@ -341,7 +341,13 @@ bool AmdFsr3Runtime::initialize(const AmdFsr3RuntimeInitDesc& desc) { const std::string loadedPath = loadedLibraryPath_; lastError_ = "ffxCreateContext (upscale) failed rc=" + std::to_string(upCreateRc) + " (" + ffxApiReturnCodeName(upCreateRc) + "), runtimeLib=" + loadedPath; - shutdown(); + LOG_ERROR("FSR3 runtime/API: FSR3 Upscale create failed at ffxCreateContext: rc=", upCreateRc); + // Don't call full shutdown() here — dlclose() on the AMD runtime library + // can hang on some drivers (notably NVIDIA) when context creation failed. + // Just clean up local state; library stays loaded (harmless leak). + delete fns_; fns_ = nullptr; + ready_ = false; + apiMode_ = ApiMode::LegacyFsr3; return false; } genericUpscaleContext_ = upscaleCtx;