From a54548dae9719da427592226a0eb43bdf7926a1a Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 9 May 2019 16:56:35 +0200 Subject: [PATCH] [d3d11] Flush more aggressively when CPU bound Submitting GPU work early is especially important if there is a CPU<>GPU synchronization point somewhere. --- src/d3d11/d3d11_context_imm.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index 61e05274..8db91b16 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -3,8 +3,9 @@ #include "d3d11_device.h" #include "d3d11_texture.h" -constexpr static uint32_t MinFlushIntervalUs = 1250; -constexpr static uint32_t MaxPendingSubmits = 3; +constexpr static uint32_t MinFlushIntervalUs = 750; +constexpr static uint32_t IncFlushIntervalUs = 250; +constexpr static uint32_t MaxPendingSubmits = 6; namespace dxvk { @@ -553,11 +554,16 @@ namespace dxvk { void D3D11ImmediateContext::FlushImplicit(BOOL StrongHint) { // Flush only if the GPU is about to go idle, in // order to keep the number of submissions low. - if (StrongHint || m_device->pendingSubmissions() <= MaxPendingSubmits) { + uint32_t pending = m_device->pendingSubmissions(); + + if (StrongHint || pending <= MaxPendingSubmits) { auto now = std::chrono::high_resolution_clock::now(); + uint32_t delay = MinFlushIntervalUs + + IncFlushIntervalUs * pending; + // Prevent flushing too often in short intervals. - if (now - m_lastFlush >= std::chrono::microseconds(MinFlushIntervalUs)) + if (now - m_lastFlush >= std::chrono::microseconds(delay)) Flush(); } }