mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 22:45:58 +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;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
|
@ -94,6 +110,13 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
|
|||
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("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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue