mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-06 20:58:37 +01:00
[dxvk] Improve low-latency frame pacing when gpuStart gets signaled earlier than expected
This commit is contained in:
parent
91c6793b55
commit
988dcdc08c
1 changed files with 6 additions and 26 deletions
|
@ -79,8 +79,10 @@ namespace dxvk {
|
|||
// and calculate backwards when we want to start this frame
|
||||
|
||||
const SyncProps props = getSyncPrediction();
|
||||
int32_t gpuReadyPrediction = duration_cast<microseconds>(
|
||||
m->start + microseconds(m->gpuStart+getGpuStartToFinishPrediction()) - now).count();
|
||||
int32_t lastFrameStart = duration_cast<microseconds>( m->start - now ).count();
|
||||
int32_t gpuReadyPrediction = lastFrameStart
|
||||
+ std::max( props.cpuUntilGpuStart, m->gpuStart )
|
||||
+ props.optimizedGpuTime;
|
||||
|
||||
int32_t targetGpuSync = gpuReadyPrediction + props.gpuSync;
|
||||
int32_t gpuDelay = targetGpuSync - props.cpuUntilGpuSync;
|
||||
|
@ -144,6 +146,7 @@ namespace dxvk {
|
|||
SyncProps& props = m_props[frameId % m_props.size()];
|
||||
props.gpuSync = gpuRun[numLoop-1];
|
||||
props.cpuUntilGpuSync = offset + duration_cast<microseconds>( m->gpuSubmit[numLoop-1] - m->start ).count();
|
||||
props.cpuUntilGpuStart = props.cpuUntilGpuSync - props.gpuSync;
|
||||
props.optimizedGpuTime = optimizedGpuTime;
|
||||
props.csStart = m->csStart;
|
||||
props.csFinished = m->csFinished;
|
||||
|
@ -176,6 +179,7 @@ namespace dxvk {
|
|||
int32_t optimizedGpuTime; // gpu executing packed submits in one go
|
||||
int32_t gpuSync; // us after gpuStart
|
||||
int32_t cpuUntilGpuSync;
|
||||
int32_t cpuUntilGpuStart;
|
||||
int32_t csStart;
|
||||
int32_t csFinished;
|
||||
bool isOutlier;
|
||||
|
@ -203,30 +207,6 @@ namespace dxvk {
|
|||
};
|
||||
|
||||
|
||||
int32_t getGpuStartToFinishPrediction() {
|
||||
uint64_t id = m_propsFinished;
|
||||
if (id < DXGI_MAX_SWAP_CHAIN_BUFFERS+7)
|
||||
return 0;
|
||||
|
||||
for (size_t i=0; i<7; ++i) {
|
||||
const SyncProps& props = m_props[ (id-i) % m_props.size() ];
|
||||
if (!props.isOutlier) {
|
||||
const LatencyMarkers* m = m_latencyMarkersStorage->getConstMarkers(id-i);
|
||||
if (m->gpuReady.empty() || m->gpuSubmit.empty())
|
||||
return m->gpuFinished - m->gpuStart;
|
||||
|
||||
time_point t = std::max( m->gpuReady[0], m->gpuSubmit[0] );
|
||||
return std::chrono::duration_cast<microseconds>( t - m->start ).count()
|
||||
+ props.optimizedGpuTime
|
||||
- m->gpuStart;
|
||||
}
|
||||
}
|
||||
|
||||
const LatencyMarkers* m = m_latencyMarkersStorage->getConstMarkers(id);
|
||||
return m->gpuFinished - m->gpuStart;
|
||||
};
|
||||
|
||||
|
||||
bool isOutlier( uint64_t frameId ) {
|
||||
constexpr size_t numLoop = 7;
|
||||
int32_t totalCpuTime = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue