diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index 1558ce6f..b58f93e7 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -170,7 +170,7 @@ namespace dxvk { D3D10DeviceLock lock = LockContext(); - if (m_csIsBusy || !m_csChunk->empty()) { + if (GetPendingCsChunks()) { // Add commands to flush the threaded // context, then flush the command list EmitCs([] (DxvkContext* ctx) { @@ -181,7 +181,7 @@ namespace dxvk { // Reset flush timer used for implicit flushes m_lastFlush = dxvk::high_resolution_clock::now(); - m_csIsBusy = false; + m_flushSeqNum = m_csSeqNum; } } @@ -257,10 +257,6 @@ namespace dxvk { RestoreCommandListState(); else ResetContextState(); - - // Mark CS thread as busy so that subsequent - // flush operations get executed correctly. - m_csIsBusy = true; } @@ -833,7 +829,6 @@ namespace dxvk { void D3D11ImmediateContext::EmitCsChunk(DxvkCsChunkRef&& chunk) { m_csSeqNum = m_csThread.dispatchChunk(std::move(chunk)); - m_csIsBusy = true; } @@ -864,6 +859,11 @@ namespace dxvk { } + uint64_t D3D11ImmediateContext::GetPendingCsChunks() { + return GetCurrentSequenceNumber() - m_flushSeqNum; + } + + void D3D11ImmediateContext::FlushImplicit(BOOL StrongHint) { // Flush only if the GPU is about to go idle, in // order to keep the number of submissions low. diff --git a/src/d3d11/d3d11_context_imm.h b/src/d3d11/d3d11_context_imm.h index 49872be2..6958e517 100644 --- a/src/d3d11/d3d11_context_imm.h +++ b/src/d3d11/d3d11_context_imm.h @@ -88,7 +88,6 @@ namespace dxvk { DxvkCsThread m_csThread; uint64_t m_csSeqNum = 0ull; - bool m_csIsBusy = false; Rc m_eventSignal; uint64_t m_eventCount = 0ull; @@ -96,6 +95,9 @@ namespace dxvk { VkDeviceSize m_maxImplicitDiscardSize = 0ull; + uint64_t m_flushSeqNum = 0ull; + + dxvk::high_resolution_clock::time_point m_lastFlush = dxvk::high_resolution_clock::now(); @@ -158,6 +160,8 @@ namespace dxvk { uint64_t GetCurrentSequenceNumber(); + uint64_t GetPendingCsChunks(); + void FlushImplicit(BOOL StrongHint); void SignalEvent(HANDLE hEvent);