fix: prevent hang on FSR3 upscale context creation failure

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.
This commit is contained in:
Kelsi 2026-03-24 10:06:57 -07:00
parent d2a396df11
commit ceb8006c3d

View file

@ -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;