mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 19:26:00 +01:00
Update the debug overlay
This commit is contained in:
parent
9e028d56c0
commit
66b8629964
4 changed files with 65 additions and 6 deletions
|
@ -31,6 +31,15 @@ void CHyprMonitorDebugOverlay::frameData(CMonitor* pMonitor) {
|
||||||
|
|
||||||
if (!m_pMonitor)
|
if (!m_pMonitor)
|
||||||
m_pMonitor = 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) {
|
int CHyprMonitorDebugOverlay::draw(int offset) {
|
||||||
|
@ -45,23 +54,57 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
|
||||||
|
|
||||||
// get avg fps
|
// get avg fps
|
||||||
float avgFrametime = 0;
|
float avgFrametime = 0;
|
||||||
|
float maxFrametime = 0;
|
||||||
|
float minFrametime = 9999;
|
||||||
for (auto& ft : m_dLastFrametimes) {
|
for (auto& ft : m_dLastFrametimes) {
|
||||||
|
if (ft > maxFrametime)
|
||||||
|
maxFrametime = ft;
|
||||||
|
if (ft < minFrametime)
|
||||||
|
minFrametime = ft;
|
||||||
avgFrametime += ft;
|
avgFrametime += ft;
|
||||||
}
|
}
|
||||||
|
float varFrametime = maxFrametime - minFrametime;
|
||||||
avgFrametime /= m_dLastFrametimes.size() == 0 ? 1 : m_dLastFrametimes.size();
|
avgFrametime /= m_dLastFrametimes.size() == 0 ? 1 : m_dLastFrametimes.size();
|
||||||
|
|
||||||
float avgRenderTime = 0;
|
float avgRenderTime = 0;
|
||||||
|
float maxRenderTime = 0;
|
||||||
|
float minRenderTime = 9999;
|
||||||
for (auto& rt : m_dLastRenderTimes) {
|
for (auto& rt : m_dLastRenderTimes) {
|
||||||
|
if (rt > maxRenderTime)
|
||||||
|
maxRenderTime = rt;
|
||||||
|
if (rt < minRenderTime)
|
||||||
|
minRenderTime = rt;
|
||||||
avgRenderTime += rt;
|
avgRenderTime += rt;
|
||||||
}
|
}
|
||||||
|
float varRenderTime = maxRenderTime - minRenderTime;
|
||||||
avgRenderTime /= m_dLastRenderTimes.size() == 0 ? 1 : m_dLastRenderTimes.size();
|
avgRenderTime /= m_dLastRenderTimes.size() == 0 ? 1 : m_dLastRenderTimes.size();
|
||||||
|
|
||||||
float avgRenderTimeNoOverlay = 0;
|
float avgRenderTimeNoOverlay = 0;
|
||||||
|
float maxRenderTimeNoOverlay = 0;
|
||||||
|
float minRenderTimeNoOverlay = 9999;
|
||||||
for (auto& rt : m_dLastRenderTimesNoOverlay) {
|
for (auto& rt : m_dLastRenderTimesNoOverlay) {
|
||||||
|
if (rt > maxRenderTimeNoOverlay)
|
||||||
|
maxRenderTimeNoOverlay = rt;
|
||||||
|
if (rt < minRenderTimeNoOverlay)
|
||||||
|
minRenderTimeNoOverlay = rt;
|
||||||
avgRenderTimeNoOverlay += rt;
|
avgRenderTimeNoOverlay += rt;
|
||||||
}
|
}
|
||||||
|
float varRenderTimeNoOverlay = maxRenderTimeNoOverlay - minRenderTimeNoOverlay;
|
||||||
avgRenderTimeNoOverlay /= m_dLastRenderTimes.size() == 0 ? 1 : m_dLastRenderTimes.size();
|
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 FPS = 1.f / (avgFrametime / 1000.f); // frametimes are in ms
|
||||||
const float idealFPS = m_dLastFrametimes.size();
|
const float idealFPS = m_dLastFrametimes.size();
|
||||||
|
|
||||||
|
@ -89,7 +132,7 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
|
||||||
|
|
||||||
yOffset += 17;
|
yOffset += 17;
|
||||||
cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset);
|
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_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
||||||
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
|
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
|
||||||
if (cairoExtents.width > maxX)
|
if (cairoExtents.width > maxX)
|
||||||
|
@ -100,7 +143,7 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
|
||||||
|
|
||||||
yOffset += 11;
|
yOffset += 11;
|
||||||
cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset);
|
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_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
||||||
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
|
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
|
||||||
if (cairoExtents.width > maxX)
|
if (cairoExtents.width > maxX)
|
||||||
|
@ -108,7 +151,7 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
|
||||||
|
|
||||||
yOffset += 11;
|
yOffset += 11;
|
||||||
cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset);
|
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: %.2fms (var %.2fms)", avgRenderTime, varRenderTime));
|
||||||
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
||||||
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
|
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
|
||||||
if (cairoExtents.width > maxX)
|
if (cairoExtents.width > maxX)
|
||||||
|
@ -116,7 +159,15 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
|
||||||
|
|
||||||
yOffset += 11;
|
yOffset += 11;
|
||||||
cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset);
|
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 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)
|
||||||
|
maxX = cairoExtents.width;
|
||||||
|
|
||||||
|
yOffset += 11;
|
||||||
|
cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset);
|
||||||
|
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_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
||||||
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
|
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
|
||||||
if (cairoExtents.width > maxX)
|
if (cairoExtents.width > maxX)
|
||||||
|
@ -149,7 +200,7 @@ void CHyprDebugOverlay::draw() {
|
||||||
const auto PMONITOR = g_pCompositor->m_vMonitors.front().get();
|
const auto PMONITOR = g_pCompositor->m_vMonitors.front().get();
|
||||||
|
|
||||||
if (!m_pCairoSurface || !m_pCairo) {
|
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);
|
m_pCairo = cairo_create(m_pCairoSurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +231,7 @@ void CHyprDebugOverlay::draw() {
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
|
||||||
#endif
|
#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};
|
wlr_box pMonBox = {0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y};
|
||||||
g_pHyprOpenGL->renderTexture(m_tTexture, &pMonBox, 1.f);
|
g_pHyprOpenGL->renderTexture(m_tTexture, &pMonBox, 1.f);
|
||||||
|
|
|
@ -19,6 +19,7 @@ class CHyprMonitorDebugOverlay {
|
||||||
std::deque<float> m_dLastFrametimes;
|
std::deque<float> m_dLastFrametimes;
|
||||||
std::deque<float> m_dLastRenderTimes;
|
std::deque<float> m_dLastRenderTimes;
|
||||||
std::deque<float> m_dLastRenderTimesNoOverlay;
|
std::deque<float> m_dLastRenderTimesNoOverlay;
|
||||||
|
std::deque<float> m_dLastAnimationTicks;
|
||||||
std::chrono::high_resolution_clock::time_point m_tpLastFrame;
|
std::chrono::high_resolution_clock::time_point m_tpLastFrame;
|
||||||
CMonitor* m_pMonitor = nullptr;
|
CMonitor* m_pMonitor = nullptr;
|
||||||
wlr_box m_wbLastDrawnBox;
|
wlr_box m_wbLastDrawnBox;
|
||||||
|
|
|
@ -35,6 +35,10 @@ void CAnimationManager::addBezierWithName(std::string name, const Vector2D& p1,
|
||||||
|
|
||||||
void CAnimationManager::tick() {
|
void CAnimationManager::tick() {
|
||||||
|
|
||||||
|
static std::chrono::time_point lastTick = std::chrono::high_resolution_clock::now();
|
||||||
|
m_fLastTickTime = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - lastTick).count() / 1000.0;
|
||||||
|
lastTick = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
bool animGlobalDisabled = false;
|
bool animGlobalDisabled = false;
|
||||||
|
|
||||||
static auto* const PANIMENABLED = &g_pConfigManager->getConfigValuePtr("animations:enabled")->intValue;
|
static auto* const PANIMENABLED = &g_pConfigManager->getConfigValuePtr("animations:enabled")->intValue;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "../helpers/AnimatedVariable.hpp"
|
#include "../helpers/AnimatedVariable.hpp"
|
||||||
#include "../helpers/BezierCurve.hpp"
|
#include "../helpers/BezierCurve.hpp"
|
||||||
#include "../Window.hpp"
|
#include "../Window.hpp"
|
||||||
|
#include "../helpers/Timer.hpp"
|
||||||
|
|
||||||
class CAnimationManager {
|
class CAnimationManager {
|
||||||
public:
|
public:
|
||||||
|
@ -28,6 +29,8 @@ class CAnimationManager {
|
||||||
|
|
||||||
wl_event_source* m_pAnimationTick;
|
wl_event_source* m_pAnimationTick;
|
||||||
|
|
||||||
|
float m_fLastTickTime; // in ms
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool deltaSmallToFlip(const Vector2D& a, const Vector2D& b);
|
bool deltaSmallToFlip(const Vector2D& a, const Vector2D& b);
|
||||||
bool deltaSmallToFlip(const CColor& a, const CColor& b);
|
bool deltaSmallToFlip(const CColor& a, const CColor& b);
|
||||||
|
|
Loading…
Reference in a new issue