From 0d478497f8c1024b19cf27d7c783f53e42bd5cf3 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Mon, 18 Mar 2024 21:46:25 +0000 Subject: [PATCH] work --- src/managers/FrameSchedulingManager.cpp | 14 ++++++++++---- src/managers/FrameSchedulingManager.hpp | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/managers/FrameSchedulingManager.cpp b/src/managers/FrameSchedulingManager.cpp index 3e46436f..9cc98163 100644 --- a/src/managers/FrameSchedulingManager.cpp +++ b/src/managers/FrameSchedulingManager.cpp @@ -25,11 +25,17 @@ void CFrameSchedulingManager::onFrameNeeded(CMonitor* pMonitor) { RASSERT(DATA, "No data in gpuDone"); - if (pMonitor->output->frame_pending || pMonitor->tearingState.activelyTearing) + if (pMonitor->tearingState.activelyTearing) return; + if (DATA->activelyPushing) { + DATA->forceFrames++; + return; + } + Debug::log(LOG, "onFrameNeeded"); + DATA->noVblankTimer = true; onPresent(pMonitor); } @@ -43,7 +49,7 @@ void CFrameSchedulingManager::gpuDone(wlr_buffer* pBuffer) { // delayed frame, let's render immediately, our shit will be presented soon // if we finish rendering before the next vblank somehow, kernel will be mad, but oh well - DATA->gpuDoneCall = true; + DATA->noVblankTimer = true; g_pHyprRenderer->renderMonitor(DATA->pMonitor); DATA->delayedFrameSubmitted = true; } @@ -111,7 +117,7 @@ void CFrameSchedulingManager::onPresent(CMonitor* pMonitor) { Debug::log(LOG, "remder!"); // we can't do this on wayland - if (!wlr_backend_is_wl(pMonitor->output->backend) && !DATA->gpuDoneCall) { + if (!wlr_backend_is_wl(pMonitor->output->backend) && !DATA->noVblankTimer) { const float TIMEUNTILVBLANK = 1000.0 / pMonitor->refreshRate; wl_event_source_timer_update(DATA->event, 0); wl_event_source_timer_update(DATA->event, std::floor(TIMEUNTILVBLANK)); @@ -119,7 +125,7 @@ void CFrameSchedulingManager::onPresent(CMonitor* pMonitor) { renderMonitor(DATA); - DATA->gpuDoneCall = false; + DATA->noVblankTimer = false; } CFrameSchedulingManager::SSchedulingData* CFrameSchedulingManager::dataFor(CMonitor* pMonitor) { diff --git a/src/managers/FrameSchedulingManager.hpp b/src/managers/FrameSchedulingManager.hpp index 6b2e8c35..c30843ff 100644 --- a/src/managers/FrameSchedulingManager.hpp +++ b/src/managers/FrameSchedulingManager.hpp @@ -39,8 +39,8 @@ class CFrameSchedulingManager { // whether the frame was submitted from gpuDone bool delayedFrameSubmitted = false; - // whether this call comes from gpuDone - bool gpuDoneCall = false; + // don't plant a vblank timer + bool noVblankTimer = false; // we need to render a few full frames at the beginning to catch all buffers int forceFrames = 5;