From 32686d203aaf7110673d16a6d3df45e85efbb068 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 26 Feb 2023 14:17:38 +0000 Subject: properly schedule frames during rendering --- src/Compositor.cpp | 3 +++ src/debug/HyprNotificationOverlay.cpp | 2 ++ src/events/Monitors.cpp | 10 +++++++++- src/helpers/Monitor.hpp | 3 +++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index ff64dbf6..a7d48a15 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -2024,6 +2024,9 @@ void CCompositor::scheduleFrameForMonitor(CMonitor* pMonitor) { if (!pMonitor->m_bEnabled) return; + if (pMonitor->renderingActive) + pMonitor->pendingFrame = true; + wlr_output_schedule_frame(pMonitor->output); } diff --git a/src/debug/HyprNotificationOverlay.cpp b/src/debug/HyprNotificationOverlay.cpp index a45ba2b2..94cb6a6c 100644 --- a/src/debug/HyprNotificationOverlay.cpp +++ b/src/debug/HyprNotificationOverlay.cpp @@ -132,6 +132,8 @@ void CHyprNotificationOverlay::draw(CMonitor* pMonitor) { g_pHyprRenderer->damageBox(&damage); g_pHyprRenderer->damageBox(&m_bLastDamage); + g_pCompositor->scheduleFrameForMonitor(pMonitor); + m_bLastDamage = damage; // copy the data to an OpenGL texture we have diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index 840d9cae..271b7d81 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -197,6 +197,8 @@ void Events::listener_monitorFrame(void* owner, void* data) { return; } + PMONITOR->renderingActive = true; + // we need to cleanup fading out when rendering the appropriate context g_pCompositor->cleanupFadingOut(PMONITOR->ID); @@ -207,6 +209,8 @@ void Events::listener_monitorFrame(void* owner, void* data) { if (*PDAMAGEBLINK || *PVFR == 0) g_pCompositor->scheduleFrameForMonitor(PMONITOR); + PMONITOR->renderingActive = false; + return; } @@ -309,12 +313,16 @@ void Events::listener_monitorFrame(void* owner, void* data) { pixman_region32_fini(&frameDamage); pixman_region32_fini(&damage); + PMONITOR->renderingActive = false; + if (!wlr_output_commit(PMONITOR->output)) return; - if (*PDAMAGEBLINK || *PVFR == 0) + if (*PDAMAGEBLINK || *PVFR == 0 || PMONITOR->pendingFrame) g_pCompositor->scheduleFrameForMonitor(PMONITOR); + PMONITOR->pendingFrame = false; + if (*PDEBUGOVERLAY == 1) { const float µs = std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - startRender).count() / 1000.f; g_pDebugOverlay->renderData(PMONITOR, µs); diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index 6582cbfc..9ad6d917 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -42,6 +42,9 @@ class CMonitor { bool enabled10bit = false; // as above, this can be TRUE even if 10 bit failed. bool createdByUser = false; + bool pendingFrame = false; // if we schedule a frame during rendering, reschedule it after + bool renderingActive = false; + // mirroring CMonitor* pMirrorOf = nullptr; std::vector mirrors; -- cgit v1.2.3