From 0433485e8881e4e60db23a79347ee3a737dd6632 Mon Sep 17 00:00:00 2001 From: UjinT34 Date: Fri, 30 Jan 2026 15:31:43 +0300 Subject: [PATCH] fix tearing --- src/protocols/Fifo.cpp | 23 +++++++++++++---------- src/protocols/Fifo.hpp | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/protocols/Fifo.cpp b/src/protocols/Fifo.cpp index e491a9ee9..8f8425931 100644 --- a/src/protocols/Fifo.cpp +++ b/src/protocols/Fifo.cpp @@ -31,8 +31,8 @@ CFifoResource::CFifoResource(UP&& resource_, SP s if (!m_surface->m_current.barrierSet) { // that might mean an empty commit with a barrier_set alone static const auto PPEND = CConfigValue("debug:fifo_pending_workaround"); - if (*PPEND && !m_surface->m_pending.fifoScheduled) - m_surface->m_pending.fifoScheduled = scheduleFrame(); + if (!m_surface->m_pending.fifoScheduled) + m_surface->m_pending.fifoScheduled = checkMonitors(*PPEND); return; } @@ -50,8 +50,11 @@ CFifoResource::CFifoResource(UP&& resource_, SP s // this feels wrong, but if we have no pending frames, presented might never come because // we are waiting on the barrier to unlock and no damage is around. // unlock on timeout instead? - if (*PPEND && !state->fifoScheduled) - state->fifoScheduled = scheduleFrame(); + if (!state->fifoScheduled) + state->fifoScheduled = checkMonitors(*PPEND); + + if (!state->fifoScheduled) + return; // only lock once its mapped. if (m_surface->m_mapped) @@ -72,7 +75,7 @@ void CFifoResource::presented() { m_surface->m_stateQueue.unlockFirst(LOCK_REASON_FIFO); } -bool CFifoResource::scheduleFrame() { +bool CFifoResource::checkMonitors(bool needsSchedule) { if (m_surface->m_enteredOutputs.empty() && m_surface->m_hlSurface) { for (auto& m : g_pCompositor->m_monitors) { if (!m || !m->m_enabled) @@ -83,8 +86,8 @@ bool CFifoResource::scheduleFrame() { if (m->m_tearingState.activelyTearing) return false; // dont fifo lock on tearing. - g_pCompositor->scheduleFrameForMonitor(m, Aquamarine::IOutput::AQ_SCHEDULE_NEEDS_FRAME); - return true; + if (needsSchedule) + g_pCompositor->scheduleFrameForMonitor(m, Aquamarine::IOutput::AQ_SCHEDULE_NEEDS_FRAME); } } } else { @@ -95,12 +98,12 @@ bool CFifoResource::scheduleFrame() { if (m->m_tearingState.activelyTearing) return false; // dont fifo lock on tearing. - g_pCompositor->scheduleFrameForMonitor(m.lock(), Aquamarine::IOutput::AQ_SCHEDULE_NEEDS_FRAME); - return true; + if (needsSchedule) + g_pCompositor->scheduleFrameForMonitor(m.lock(), Aquamarine::IOutput::AQ_SCHEDULE_NEEDS_FRAME); } } - return false; + return true; } CFifoManagerResource::CFifoManagerResource(UP&& resource_) : m_resource(std::move(resource_)) { diff --git a/src/protocols/Fifo.hpp b/src/protocols/Fifo.hpp index e67276a06..5b143f792 100644 --- a/src/protocols/Fifo.hpp +++ b/src/protocols/Fifo.hpp @@ -26,7 +26,7 @@ class CFifoResource { } m_listeners; void presented(); - bool scheduleFrame(); + bool checkMonitors(bool needsSchedule = false); friend class CFifoProtocol; friend class CFifoManagerResource;