[d3d11] Flush more aggressively when CPU bound

Submitting GPU work early is especially important if there is
a CPU<>GPU synchronization point somewhere.
This commit is contained in:
Philip Rebohle 2019-05-09 16:56:35 +02:00
parent 45be1dfb53
commit a54548dae9
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
1 changed files with 10 additions and 4 deletions

View File

@ -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();
}
}