Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[d3d9] Implement config option to disable rejecting reset
Browse files Browse the repository at this point in the history
K0bin committed Jan 25, 2024

Verified

This commit was signed with the committer’s verified signature.
timryanb Tim Brooks
1 parent d4c5fc7 commit ba72583
Showing 4 changed files with 28 additions and 1 deletion.
23 changes: 23 additions & 0 deletions dxvk.conf
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/d3d9/d3d9_device.cpp
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions src/d3d9/d3d9_options.cpp
Original file line number Diff line number Diff line change
@@ -76,6 +76,7 @@ namespace dxvk {
this->deviceLossOnFocusLoss = config.getOption<bool> ("d3d9.deviceLossOnFocusLoss", false);
this->samplerLodBias = config.getOption<float> ("d3d9.samplerLodBias", 0.0f);
this->clampNegativeLodBias = config.getOption<bool> ("d3d9.clampNegativeLodBias", false);
this->countLosableResources = config.getOption<bool> ("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);
3 changes: 3 additions & 0 deletions src/d3d9/d3d9_options.h
Original file line number Diff line number Diff line change
@@ -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;
};

}

0 comments on commit ba72583

Please sign in to comment.