diff options
author | vaxerski <[email protected]> | 2022-05-28 17:40:57 +0200 |
---|---|---|
committer | vaxerski <[email protected]> | 2022-05-28 17:40:57 +0200 |
commit | 7d442d48514e62a41e5bad0176adb8428dd112b3 (patch) | |
tree | 6e327af07b01a1e089e5d495bb697d4c4578a1da | |
parent | 8c10857f14e6c91f3b3099b9508e1f4d68c2d276 (diff) | |
download | Hyprland-7d442d48514e62a41e5bad0176adb8428dd112b3.tar.gz Hyprland-7d442d48514e62a41e5bad0176adb8428dd112b3.zip |
Added rendertime no overlay
-rw-r--r-- | src/debug/HyprDebugOverlay.cpp | 27 | ||||
-rw-r--r-- | src/debug/HyprDebugOverlay.hpp | 3 | ||||
-rw-r--r-- | src/events/Monitors.cpp | 19 |
3 files changed, 46 insertions, 3 deletions
diff --git a/src/debug/HyprDebugOverlay.cpp b/src/debug/HyprDebugOverlay.cpp index 214965a8..0eb3ba17 100644 --- a/src/debug/HyprDebugOverlay.cpp +++ b/src/debug/HyprDebugOverlay.cpp @@ -11,6 +11,16 @@ void CHyprMonitorDebugOverlay::renderData(SMonitor* pMonitor, float µs) { m_pMonitor = pMonitor; } +void CHyprMonitorDebugOverlay::renderDataNoOverlay(SMonitor* pMonitor, float µs) { + m_dLastRenderTimesNoOverlay.push_back(µs / 1000.f); + + if (m_dLastRenderTimesNoOverlay.size() > (long unsigned int)pMonitor->refreshRate) + m_dLastRenderTimesNoOverlay.pop_front(); + + if (!m_pMonitor) + m_pMonitor = pMonitor; +} + void CHyprMonitorDebugOverlay::frameData(SMonitor* pMonitor) { m_dLastFrametimes.push_back(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - m_tpLastFrame).count() / 1000.f); @@ -46,6 +56,12 @@ int CHyprMonitorDebugOverlay::draw(int offset) { } avgRenderTime /= m_dLastRenderTimes.size() == 0 ? 1 : m_dLastRenderTimes.size(); + float avgRenderTimeNoOverlay = 0; + for (auto& rt : m_dLastRenderTimesNoOverlay) { + avgRenderTimeNoOverlay += rt; + } + avgRenderTimeNoOverlay /= m_dLastRenderTimes.size() == 0 ? 1 : m_dLastRenderTimes.size(); + const float FPS = 1.f / (avgFrametime / 1000.f); // frametimes are in ms const float idealFPS = m_dLastFrametimes.size(); @@ -95,6 +111,13 @@ int CHyprMonitorDebugOverlay::draw(int offset) { if (cairoExtents.width > maxX) maxX = cairoExtents.width; yOffset += 11; + cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset); + text = std::string("Avg Rendertime (no overlay): " + std::to_string((int)avgRenderTimeNoOverlay) + "." + std::to_string((int)(avgRenderTimeNoOverlay * 10.f) % 10) + "ms"); + cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str()); + cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents); + if (cairoExtents.width > maxX) maxX = cairoExtents.width; + + yOffset += 11; g_pHyprRenderer->damageBox(&m_wbLastDrawnBox); m_wbLastDrawnBox = {(int)g_pCompositor->m_lMonitors.front().vecPosition.x, (int)g_pCompositor->m_lMonitors.front().vecPosition.y + offset - 1, (int)maxX + 2, yOffset - offset + 2}; @@ -107,6 +130,10 @@ void CHyprDebugOverlay::renderData(SMonitor* pMonitor, float µs) { m_mMonitorOverlays[pMonitor].renderData(pMonitor, µs); } +void CHyprDebugOverlay::renderDataNoOverlay(SMonitor* pMonitor, float µs) { + m_mMonitorOverlays[pMonitor].renderDataNoOverlay(pMonitor, µs); +} + void CHyprDebugOverlay::frameData(SMonitor* pMonitor) { m_mMonitorOverlays[pMonitor].frameData(pMonitor); } diff --git a/src/debug/HyprDebugOverlay.hpp b/src/debug/HyprDebugOverlay.hpp index aa476bf7..8899ab15 100644 --- a/src/debug/HyprDebugOverlay.hpp +++ b/src/debug/HyprDebugOverlay.hpp @@ -12,11 +12,13 @@ public: int draw(int offset); void renderData(SMonitor* pMonitor, float µs); + void renderDataNoOverlay(SMonitor* pMonitor, float µs); void frameData(SMonitor* pMonitor); private: std::deque<float> m_dLastFrametimes; std::deque<float> m_dLastRenderTimes; + std::deque<float> m_dLastRenderTimesNoOverlay; std::chrono::high_resolution_clock::time_point m_tpLastFrame; SMonitor* m_pMonitor = nullptr; wlr_box m_wbLastDrawnBox; @@ -27,6 +29,7 @@ public: void draw(); void renderData(SMonitor*, float µs); + void renderDataNoOverlay(SMonitor*, float µs); void frameData(SMonitor*); private: diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index c8f330d7..0ef780d9 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -132,6 +132,8 @@ void Events::listener_monitorFrame(void* owner, void* data) { SMonitor* const PMONITOR = (SMonitor*)owner; static std::chrono::high_resolution_clock::time_point startRender = std::chrono::high_resolution_clock::now(); + static std::chrono::high_resolution_clock::time_point startRenderOverlay = std::chrono::high_resolution_clock::now(); + static std::chrono::high_resolution_clock::time_point endRenderOverlay = std::chrono::high_resolution_clock::now(); if (g_pConfigManager->getInt("debug:overlay") == 1) { startRender = std::chrono::high_resolution_clock::now(); @@ -225,8 +227,11 @@ void Events::listener_monitorFrame(void* owner, void* data) { g_pHyprError->draw(); // for drawing the debug overlay - if (PMONITOR->ID == 0 && g_pConfigManager->getInt("debug:overlay") == 1) + if (PMONITOR->ID == 0 && g_pConfigManager->getInt("debug:overlay") == 1) { + startRenderOverlay = std::chrono::high_resolution_clock::now(); g_pDebugOverlay->draw(); + endRenderOverlay = std::chrono::high_resolution_clock::now(); + } wlr_renderer_begin(g_pCompositor->m_sWLRRenderer, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y); @@ -254,8 +259,16 @@ void Events::listener_monitorFrame(void* owner, void* data) { wlr_output_schedule_frame(PMONITOR->output); - if (g_pConfigManager->getInt("debug:overlay") == 1) - g_pDebugOverlay->renderData(PMONITOR, std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now() - startRender).count() / 1000.f); + if (g_pConfigManager->getInt("debug:overlay") == 1) { + const float µs = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now() - startRender).count() / 1000.f; + g_pDebugOverlay->renderData(PMONITOR, µs); + if (PMONITOR->ID == 0) { + const float µsNoOverlay = µs - std::chrono::duration_cast<std::chrono::nanoseconds>(endRenderOverlay - startRenderOverlay).count() / 1000.f; + g_pDebugOverlay->renderDataNoOverlay(PMONITOR, µsNoOverlay); + } else { + g_pDebugOverlay->renderDataNoOverlay(PMONITOR, µs); + } + } } void Events::listener_monitorDestroy(void* owner, void* data) { |