From 0841f5faf438ca58528670a5edf87ffd34ec27b8 Mon Sep 17 00:00:00 2001 From: Robin Kertels Date: Thu, 25 Jan 2024 21:59:27 +0100 Subject: [PATCH] [d3d9] Implement config option to disable rejecting reset --- dxvk.conf | 23 +++++++++++++++++++++++ src/d3d9/d3d9_device.cpp | 2 +- src/d3d9/d3d9_options.cpp | 1 + src/d3d9/d3d9_options.h | 3 +++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/dxvk.conf b/dxvk.conf index ec3876cd3..09f5dfbaf 100644 --- a/dxvk.conf +++ b/dxvk.conf @@ -646,3 +646,26 @@ # - True/False # dxvk.hideIntegratedGraphics = False + +# Trigger DEVICELOST when losing focus +# +# D3D9 requires the application to call Device::Reset after +# it loses focus in fullscreen. +# Some games rely on observing a D3DERR_DEVICELOST or D3DERR_NOTRESET. +# Others don't handle it correctly. +# +# Supported values: +# - True/False + +# d3d9.deviceLossOnFocusLoss = False + +# Reject Device::Reset if any losable resource is still alive +# +# D3D9 rejects Device::Reset if there's still any alive resources of specific types. +# (State blocks, additional swapchains, D3DPOOL_DEFAULT resources) +# Some games leak resources leading to a hang. +# +# Supported values: +# - True/False + +# d3d9.countLosableResources = True diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 732f818c2..a0c0a1ecb 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -464,7 +464,7 @@ namespace dxvk { * We have to check after ResetState clears the references held by SetTexture, etc. * This matches what Windows D3D9 does. */ - if (unlikely(m_losableResourceCounter.load() != 0 && !IsExtended())) { + if (unlikely(m_losableResourceCounter.load() != 0 && !IsExtended() && m_d3d9Options.countLosableResources)) { Logger::warn(str::format("Device reset failed because device still has alive losable resources: Device not reset. Remaining resources: ", m_losableResourceCounter.load())); m_deviceLostState = D3D9DeviceLostState::NotReset; return D3DERR_INVALIDCALL; diff --git a/src/d3d9/d3d9_options.cpp b/src/d3d9/d3d9_options.cpp index 190ca29b8..fc3d0b481 100644 --- a/src/d3d9/d3d9_options.cpp +++ b/src/d3d9/d3d9_options.cpp @@ -76,6 +76,7 @@ namespace dxvk { this->deviceLossOnFocusLoss = config.getOption ("d3d9.deviceLossOnFocusLoss", false); this->samplerLodBias = config.getOption ("d3d9.samplerLodBias", 0.0f); this->clampNegativeLodBias = config.getOption ("d3d9.clampNegativeLodBias", false); + this->countLosableResources = config.getOption ("d3d9.countLosableResources", true); // Clamp LOD bias so that people don't abuse this in unintended ways this->samplerLodBias = dxvk::fclamp(this->samplerLodBias, -2.0f, 1.0f); diff --git a/src/d3d9/d3d9_options.h b/src/d3d9/d3d9_options.h index f5b1fce46..034c85d3a 100644 --- a/src/d3d9/d3d9_options.h +++ b/src/d3d9/d3d9_options.h @@ -152,6 +152,9 @@ namespace dxvk { /// Enable emulation of device loss when a fullscreen app loses focus bool deviceLossOnFocusLoss; + + /// Disable counting losable resources and rejecting calls to Reset() if any are still alive + bool countLosableResources; }; }