mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 09:05:59 +01:00
Added rendertime no overlay
This commit is contained in:
parent
8c10857f14
commit
7d442d4851
3 changed files with 46 additions and 3 deletions
|
@ -11,6 +11,16 @@ void CHyprMonitorDebugOverlay::renderData(SMonitor* pMonitor, float µs) {
|
||||||
m_pMonitor = pMonitor;
|
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) {
|
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);
|
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();
|
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 FPS = 1.f / (avgFrametime / 1000.f); // frametimes are in ms
|
||||||
const float idealFPS = m_dLastFrametimes.size();
|
const float idealFPS = m_dLastFrametimes.size();
|
||||||
|
|
||||||
|
@ -94,6 +110,13 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
|
||||||
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) maxX = cairoExtents.width;
|
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;
|
yOffset += 11;
|
||||||
|
|
||||||
g_pHyprRenderer->damageBox(&m_wbLastDrawnBox);
|
g_pHyprRenderer->damageBox(&m_wbLastDrawnBox);
|
||||||
|
@ -107,6 +130,10 @@ void CHyprDebugOverlay::renderData(SMonitor* pMonitor, float µs) {
|
||||||
m_mMonitorOverlays[pMonitor].renderData(pMonitor, µ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) {
|
void CHyprDebugOverlay::frameData(SMonitor* pMonitor) {
|
||||||
m_mMonitorOverlays[pMonitor].frameData(pMonitor);
|
m_mMonitorOverlays[pMonitor].frameData(pMonitor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,13 @@ public:
|
||||||
int draw(int offset);
|
int draw(int offset);
|
||||||
|
|
||||||
void renderData(SMonitor* pMonitor, float µs);
|
void renderData(SMonitor* pMonitor, float µs);
|
||||||
|
void renderDataNoOverlay(SMonitor* pMonitor, float µs);
|
||||||
void frameData(SMonitor* pMonitor);
|
void frameData(SMonitor* pMonitor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
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::chrono::high_resolution_clock::time_point m_tpLastFrame;
|
std::chrono::high_resolution_clock::time_point m_tpLastFrame;
|
||||||
SMonitor* m_pMonitor = nullptr;
|
SMonitor* m_pMonitor = nullptr;
|
||||||
wlr_box m_wbLastDrawnBox;
|
wlr_box m_wbLastDrawnBox;
|
||||||
|
@ -27,6 +29,7 @@ public:
|
||||||
|
|
||||||
void draw();
|
void draw();
|
||||||
void renderData(SMonitor*, float µs);
|
void renderData(SMonitor*, float µs);
|
||||||
|
void renderDataNoOverlay(SMonitor*, float µs);
|
||||||
void frameData(SMonitor*);
|
void frameData(SMonitor*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -132,6 +132,8 @@ void Events::listener_monitorFrame(void* owner, void* data) {
|
||||||
SMonitor* const PMONITOR = (SMonitor*)owner;
|
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 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) {
|
if (g_pConfigManager->getInt("debug:overlay") == 1) {
|
||||||
startRender = std::chrono::high_resolution_clock::now();
|
startRender = std::chrono::high_resolution_clock::now();
|
||||||
|
@ -225,8 +227,11 @@ void Events::listener_monitorFrame(void* owner, void* data) {
|
||||||
g_pHyprError->draw();
|
g_pHyprError->draw();
|
||||||
|
|
||||||
// for drawing the debug overlay
|
// 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();
|
g_pDebugOverlay->draw();
|
||||||
|
endRenderOverlay = std::chrono::high_resolution_clock::now();
|
||||||
|
}
|
||||||
|
|
||||||
wlr_renderer_begin(g_pCompositor->m_sWLRRenderer, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y);
|
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);
|
wlr_output_schedule_frame(PMONITOR->output);
|
||||||
|
|
||||||
if (g_pConfigManager->getInt("debug:overlay") == 1)
|
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);
|
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) {
|
void Events::listener_monitorDestroy(void* owner, void* data) {
|
||||||
|
|
Loading…
Reference in a new issue