diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index b342fd70..a93414df 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -36,12 +36,18 @@ namespace dxvk { ULONG STDMETHODCALLTYPE D3D11ImmediateContext::AddRef() { - return m_parent->AddRef(); + ULONG refCount = m_refCount++; + if (!refCount) + m_parent->AddRef(); + return refCount; } ULONG STDMETHODCALLTYPE D3D11ImmediateContext::Release() { - return m_parent->Release(); + ULONG refCount = --m_refCount; + if (!refCount) + m_parent->Release(); + return refCount; } diff --git a/src/d3d11/d3d11_context_imm.h b/src/d3d11/d3d11_context_imm.h index 235daec4..8c98d79b 100644 --- a/src/d3d11/d3d11_context_imm.h +++ b/src/d3d11/d3d11_context_imm.h @@ -109,6 +109,8 @@ namespace dxvk { DxvkCsThread m_csThread; bool m_csIsBusy = false; + std::atomic m_refCount = { 0 }; + std::chrono::high_resolution_clock::time_point m_lastFlush = std::chrono::high_resolution_clock::now();