Skip to content

Commit

Permalink
D3D11Device: Always query timestamp before present start
Browse files Browse the repository at this point in the history
Fixes high GPU usage reporting in D3D11 with AMD GPUs + Optimal Frame
Pacing.
  • Loading branch information
stenzek committed Feb 7, 2025
1 parent 5ae6d90 commit 063bb96
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/util/d3d11_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,11 +685,11 @@ GPUDevice::PresentResult D3D11Device::BeginPresent(GPUSwapChain* swap_chain, u32
return PresentResult::ExclusiveFullscreenLost;
}

// When using vsync, the time here seems to include the time for the buffer to become available.
// The time here seems to include the time for the buffer to become available.
// This blows our our GPU usage number considerably, so read the timestamp before the final blit
// in this configuration. It does reduce accuracy a little, but better than seeing 100% all of
// the time, when it's more like a couple of percent.
if (SC == m_main_swap_chain.get() && SC->GetVSyncMode() == GPUVSyncMode::FIFO && m_gpu_timing_enabled)
if (SC == m_main_swap_chain.get() && m_gpu_timing_enabled)
{
PopTimestampQuery();
EndTimestampQuery();
Expand All @@ -711,12 +711,6 @@ void D3D11Device::EndPresent(GPUSwapChain* swap_chain, bool explicit_present, u6
DebugAssert(!explicit_present && present_time == 0);
DebugAssert(m_num_current_render_targets == 0 && !m_current_depth_target);

if (SC == m_main_swap_chain.get() && SC->GetVSyncMode() != GPUVSyncMode::FIFO && m_gpu_timing_enabled)
{
PopTimestampQuery();
EndTimestampQuery();
}

const UINT sync_interval = static_cast<UINT>(SC->GetVSyncMode() == GPUVSyncMode::FIFO);
const UINT flags =
(SC->GetVSyncMode() == GPUVSyncMode::Disabled && SC->IsUsingAllowTearing()) ? DXGI_PRESENT_ALLOW_TEARING : 0;
Expand Down

0 comments on commit 063bb96

Please sign in to comment.