diff options
author | Philip Rebohle <philip.rebohle@tu-dortmund.de> | 2023-07-31 22:47:44 +0300 |
---|---|---|
committer | Philip Rebohle <philip.rebohle@tu-dortmund.de> | 2023-07-31 22:47:44 +0300 |
commit | 9b019d26accf9053240d1e88691f0c3275bcee49 (patch) | |
tree | 2723f8fd585c54c9dec5a40e443a2cb2dd415816 | |
parent | 228615b639679267389e23765c5e6de012931031 (diff) |
[dxgi] Forward IDXGIOutput::GetFrameStatistics to full-screen swap chain
Testing on Windows reveals that this function does not work with windowed
mode swap chains even in flip model.
-rw-r--r-- | src/dxgi/dxgi_output.cpp | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/src/dxgi/dxgi_output.cpp b/src/dxgi/dxgi_output.cpp index f948c7a8..0be8ee3f 100644 --- a/src/dxgi/dxgi_output.cpp +++ b/src/dxgi/dxgi_output.cpp @@ -362,31 +362,18 @@ namespace dxvk { if (FAILED(hr)) return hr; - static bool s_errorShown = false; - - if (!std::exchange(s_errorShown, true)) - Logger::warn("DxgiOutput::GetFrameStatistics: Frame statistics may be inaccurate"); - - // Estimate vblank count based on last known display mode. Querying - // the display mode on every call would be prohibitively expensive. - auto refreshPeriod = computeRefreshPeriod( - monitorInfo->LastMode.RefreshRate.Numerator, - monitorInfo->LastMode.RefreshRate.Denominator); - - // We don't really have a way to query time since boot - auto t1Counter = dxvk::high_resolution_clock::get_counter(); - - auto t0 = dxvk::high_resolution_clock::get_time_from_counter(monitorInfo->FrameStats.SyncQPCTime.QuadPart); - auto t1 = dxvk::high_resolution_clock::get_time_from_counter(t1Counter); + // Need to acquire swap chain and unlock monitor data, since querying + // frame statistics from the swap chain will also access monitor data. + Com<IDXGISwapChain> swapChain = monitorInfo->pSwapChain; + m_monitorInfo->ReleaseMonitorData(); - pStats->PresentCount = monitorInfo->FrameStats.PresentCount; - pStats->PresentRefreshCount = monitorInfo->FrameStats.PresentRefreshCount; - pStats->SyncRefreshCount = monitorInfo->FrameStats.SyncRefreshCount + computeRefreshCount(t0, t1, refreshPeriod); - pStats->SyncQPCTime.QuadPart = t1Counter; - pStats->SyncGPUTime.QuadPart = 0; + // This API only works if there is a full-screen swap chain active. + if (swapChain == nullptr) { + *pStats = DXGI_FRAME_STATISTICS(); + return S_OK; + } - m_monitorInfo->ReleaseMonitorData(); - return S_OK; + return swapChain->GetFrameStatistics(pStats); } |