From 2c4879b58c13e8ff27ecaf14a02e16b97803608b Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Fri, 13 Dec 2019 13:01:16 +0100 Subject: [PATCH] [hud] Reduce update frequency of queue submission display Shows the maximum number of submissions encountered per frame in the given time frame. --- src/dxvk/hud/dxvk_hud_item.cpp | 13 +++++++++++-- src/dxvk/hud/dxvk_hud_item.h | 6 +++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/dxvk/hud/dxvk_hud_item.cpp b/src/dxvk/hud/dxvk_hud_item.cpp index f0c1a21dc..46a2319fc 100644 --- a/src/dxvk/hud/dxvk_hud_item.cpp +++ b/src/dxvk/hud/dxvk_hud_item.cpp @@ -290,8 +290,17 @@ namespace dxvk::hud { DxvkStatCounters counters = m_device->getStatCounters(); uint32_t currCounter = counters.getCtr(DxvkStatCounter::QueueSubmitCount); - m_diffCounter = currCounter - m_prevCounter; + m_diffCounter = std::max(m_diffCounter, currCounter - m_prevCounter); m_prevCounter = currCounter; + + auto elapsed = std::chrono::duration_cast(time - m_lastUpdate); + + if (elapsed.count() >= UpdateInterval) { + m_showCounter = m_diffCounter; + m_diffCounter = 0; + + m_lastUpdate = time; + } } @@ -308,7 +317,7 @@ namespace dxvk::hud { renderer.drawText(16.0f, { position.x + 228.0f, position.y }, { 1.0f, 1.0f, 1.0f, 1.0f }, - str::format(m_diffCounter)); + str::format(m_showCounter)); position.y += 8.0f; return position; diff --git a/src/dxvk/hud/dxvk_hud_item.h b/src/dxvk/hud/dxvk_hud_item.h index 2bf071eda..e22761964 100644 --- a/src/dxvk/hud/dxvk_hud_item.h +++ b/src/dxvk/hud/dxvk_hud_item.h @@ -220,7 +220,7 @@ namespace dxvk::hud { * \brief HUD item to display queue submissions */ class HudSubmissionStatsItem : public HudItem { - + constexpr static int64_t UpdateInterval = 500'000; public: HudSubmissionStatsItem(const Rc& device); @@ -239,6 +239,10 @@ namespace dxvk::hud { uint64_t m_prevCounter = 0; uint64_t m_diffCounter = 0; + uint64_t m_showCounter = 0; + + dxvk::high_resolution_clock::time_point m_lastUpdate + = dxvk::high_resolution_clock::now(); };