From 6b0d29a72d09a2379542282d620f598d9f6dbac4 Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Fri, 2 Oct 2015 19:03:22 +0200 Subject: [PATCH] d3d12: Measure flip duration --- rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp | 9 ++++++++- rpcs3/Emu/RSX/D3D12/D3D12GSRender.h | 1 + rpcs3/Emu/RSX/D3D12/D3D12Overlay.cpp | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp index b33b6fda61..3a06418a08 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp @@ -836,6 +836,10 @@ void D3D12GSRender::Flip() if(Ini.GSOverlay.GetValue()) renderOverlay(); + ResetTimer(); + + std::chrono::time_point flipStart = std::chrono::system_clock::now(); + ThrowIfFailed(m_swapChain->Present(Ini.GSVSyncEnable.GetValue() ? 1 : 0, 0)); // Add an event signaling queue completion @@ -874,7 +878,9 @@ void D3D12GSRender::Flip() m_frame->Flip(nullptr); - ResetTimer(); + + std::chrono::time_point flipEnd = std::chrono::system_clock::now(); + m_timers.m_flipDuration += std::chrono::duration_cast(flipEnd - flipStart).count(); } void D3D12GSRender::ResetTimer() @@ -887,6 +893,7 @@ void D3D12GSRender::ResetTimer() m_timers.m_programLoadDuration = 0; m_timers.m_constantsDuration = 0; m_timers.m_textureDuration = 0; + m_timers.m_flipDuration = 0; } D3D12GSRender::ResourceStorage& D3D12GSRender::getCurrentResourceStorage() diff --git a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h index b7c926ab6a..b14b7c3239 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h @@ -244,6 +244,7 @@ private: size_t m_programLoadDuration; size_t m_constantsDuration; size_t m_textureDuration; + size_t m_flipDuration; } m_timers; void ResetTimer(); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Overlay.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Overlay.cpp index d119a4500d..f687f72f9d 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Overlay.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Overlay.cpp @@ -130,6 +130,7 @@ void D3D12GSRender::renderOverlay() std::wstring constantDuration = L"Constants : " + std::to_wstring(m_timers.m_constantsDuration) + L" us (" + std::to_wstring(100.f * constantsPercent) + L" %)"; float rttPercent = (float)m_timers.m_rttDuration / (float)m_timers.m_drawCallDuration; std::wstring rttDuration = L"RTT : " + std::to_wstring(m_timers.m_rttDuration) + L" us (" + std::to_wstring(100.f * rttPercent) + L" %)"; + std::wstring flipDuration = L"Flip : " + std::to_wstring(m_timers.m_flipDuration) + L" us"; std::wstring count = L"Draw count : " + std::to_wstring(m_timers.m_drawCallCount); @@ -196,6 +197,13 @@ void D3D12GSRender::renderOverlay() &D2D1::RectF(0, 98, rtSize.width, rtSize.height), m_textBrush.Get() ); + m_d2dDeviceContext->DrawTextW( + flipDuration.c_str(), + (UINT32)flipDuration.size(), + m_textFormat.Get(), + &D2D1::RectF(0, 112, rtSize.width, rtSize.height), + m_textBrush.Get() + ); m_d2dDeviceContext->EndDraw(); // Release our wrapped render target resource. Releasing