diff options
Diffstat (limited to 'src/debug/HyprDebugOverlay.cpp')
-rw-r--r-- | src/debug/HyprDebugOverlay.cpp | 63 |
1 files changed, 57 insertions, 6 deletions
diff --git a/src/debug/HyprDebugOverlay.cpp b/src/debug/HyprDebugOverlay.cpp index 6b2ed914..bd10f680 100644 --- a/src/debug/HyprDebugOverlay.cpp +++ b/src/debug/HyprDebugOverlay.cpp @@ -31,6 +31,15 @@ void CHyprMonitorDebugOverlay::frameData(CMonitor* pMonitor) { if (!m_pMonitor) m_pMonitor = pMonitor; + + // anim data too + const auto PMONITORFORTICKS = g_pHyprRenderer->m_pMostHzMonitor ? g_pHyprRenderer->m_pMostHzMonitor : g_pCompositor->m_pLastMonitor; + if (PMONITORFORTICKS) { + if (m_dLastAnimationTicks.size() > (long unsigned int)PMONITORFORTICKS->refreshRate) + m_dLastAnimationTicks.pop_front(); + + m_dLastAnimationTicks.push_back(g_pAnimationManager->m_fLastTickTime); + } } int CHyprMonitorDebugOverlay::draw(int offset) { @@ -45,23 +54,57 @@ int CHyprMonitorDebugOverlay::draw(int offset) { // get avg fps float avgFrametime = 0; + float maxFrametime = 0; + float minFrametime = 9999; for (auto& ft : m_dLastFrametimes) { + if (ft > maxFrametime) + maxFrametime = ft; + if (ft < minFrametime) + minFrametime = ft; avgFrametime += ft; } + float varFrametime = maxFrametime - minFrametime; avgFrametime /= m_dLastFrametimes.size() == 0 ? 1 : m_dLastFrametimes.size(); float avgRenderTime = 0; + float maxRenderTime = 0; + float minRenderTime = 9999; for (auto& rt : m_dLastRenderTimes) { + if (rt > maxRenderTime) + maxRenderTime = rt; + if (rt < minRenderTime) + minRenderTime = rt; avgRenderTime += rt; } + float varRenderTime = maxRenderTime - minRenderTime; avgRenderTime /= m_dLastRenderTimes.size() == 0 ? 1 : m_dLastRenderTimes.size(); float avgRenderTimeNoOverlay = 0; + float maxRenderTimeNoOverlay = 0; + float minRenderTimeNoOverlay = 9999; for (auto& rt : m_dLastRenderTimesNoOverlay) { + if (rt > maxRenderTimeNoOverlay) + maxRenderTimeNoOverlay = rt; + if (rt < minRenderTimeNoOverlay) + minRenderTimeNoOverlay = rt; avgRenderTimeNoOverlay += rt; } + float varRenderTimeNoOverlay = maxRenderTimeNoOverlay - minRenderTimeNoOverlay; avgRenderTimeNoOverlay /= m_dLastRenderTimes.size() == 0 ? 1 : m_dLastRenderTimes.size(); + float avgAnimMgrTick = 0; + float maxAnimMgrTick = 0; + float minAnimMgrTick = 9999; + for (auto& at : m_dLastAnimationTicks) { + if (at > maxAnimMgrTick) + maxAnimMgrTick = at; + if (at < minAnimMgrTick) + minAnimMgrTick = at; + avgAnimMgrTick += at; + } + float varAnimMgrTick = maxAnimMgrTick - minAnimMgrTick; + avgAnimMgrTick /= m_dLastAnimationTicks.size() == 0 ? 1 : m_dLastAnimationTicks.size(); + const float FPS = 1.f / (avgFrametime / 1000.f); // frametimes are in ms const float idealFPS = m_dLastFrametimes.size(); @@ -89,7 +132,7 @@ int CHyprMonitorDebugOverlay::draw(int offset) { yOffset += 17; cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset); - text = std::string(std::to_string((int)FPS) + " FPS"); + text = std::string(getFormat("%i FPS", (int)FPS)); 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) @@ -100,7 +143,15 @@ int CHyprMonitorDebugOverlay::draw(int offset) { yOffset += 11; cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset); - text = std::string("Avg Frametime: " + std::to_string((int)avgFrametime) + "." + std::to_string((int)(avgFrametime * 10.f) % 10) + "ms"); + text = std::string(getFormat("Avg Frametime: %.2fms (var %.2fms)", avgFrametime, varFrametime)); + 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; + cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset); + text = std::string(getFormat("Avg Rendertime: %.2fms (var %.2fms)", avgRenderTime, varRenderTime)); 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) @@ -108,7 +159,7 @@ int CHyprMonitorDebugOverlay::draw(int offset) { yOffset += 11; cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset); - text = std::string("Avg Rendertime: " + std::to_string((int)avgRenderTime) + "." + std::to_string((int)(avgRenderTime * 10.f) % 10) + "ms"); + text = std::string(getFormat("Avg Rendertime (No Overlay): %.2fms (var %.2fms)", avgRenderTimeNoOverlay, varRenderTimeNoOverlay)); 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) @@ -116,7 +167,7 @@ int CHyprMonitorDebugOverlay::draw(int offset) { 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"); + text = std::string(getFormat("Avg Anim Tick: %.2fms (var %.2fms) (%.2f TPS)", avgAnimMgrTick, varAnimMgrTick, 1.0 / (avgAnimMgrTick / 1000.0))); 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) @@ -149,7 +200,7 @@ void CHyprDebugOverlay::draw() { const auto PMONITOR = g_pCompositor->m_vMonitors.front().get(); if (!m_pCairoSurface || !m_pCairo) { - m_pCairoSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, PMONITOR->vecSize.x, PMONITOR->vecSize.y); + m_pCairoSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y); m_pCairo = cairo_create(m_pCairoSurface); } @@ -180,7 +231,7 @@ void CHyprDebugOverlay::draw() { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED); #endif - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, PMONITOR->vecSize.x, PMONITOR->vecSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, DATA); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, DATA); wlr_box pMonBox = {0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y}; g_pHyprOpenGL->renderTexture(m_tTexture, &pMonBox, 1.f); |