From a106d96ab6be75d6e556a0a62ef22c8e16ed1f38 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Mon, 8 Apr 2024 16:18:54 +0100 Subject: [PATCH] stuf --- src/managers/FrameSchedulingManager.cpp | 20 +++++++++----------- src/managers/FrameSchedulingManager.hpp | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/managers/FrameSchedulingManager.cpp b/src/managers/FrameSchedulingManager.cpp index f2ba1018..f6f5edbb 100644 --- a/src/managers/FrameSchedulingManager.cpp +++ b/src/managers/FrameSchedulingManager.cpp @@ -63,8 +63,7 @@ void CFrameSchedulingManager::onFrameNeeded(CMonitor* pMonitor) { return; if (DATA->activelyPushing && DATA->lastPresent.getMillis() < 100) { - if (DATA->forceFrames < 1) - DATA->forceFrames++; + DATA->forceFrames = 1; return; } @@ -167,27 +166,26 @@ void CFrameSchedulingManager::onPresent(CMonitor* pMonitor, wlr_output_event_pre Debug::log(LOG, "render"); // we can't do this on wayland - float µsUntilVblank = 0; + uint64_t µsUntilVblank = 0; if (presentationData) { timespec now; clock_gettime(CLOCK_MONOTONIC, &now); - const std::chrono::system_clock::duration LASTVBLANK{ + const std::chrono::system_clock::duration SINCELASTVBLANK{ std::chrono::duration_cast(std::chrono::seconds{now.tv_sec} + std::chrono::nanoseconds{now.tv_nsec}) - std::chrono::duration_cast(std::chrono::seconds{presentationData->when->tv_sec} + std::chrono::nanoseconds{presentationData->when->tv_nsec})}; - µsUntilVblank = (presentationData->refresh ? presentationData->refresh / 1000000.0 : pMonitor->refreshRate / 1000.0) - - std::chrono::duration_cast(LASTVBLANK).count(); + µsUntilVblank = (presentationData->refresh ? presentationData->refresh / 1000.0 : pMonitor->refreshRate / 1000000.0) - + std::chrono::duration_cast(SINCELASTVBLANK).count(); - DATA->nextVblank = std::chrono::system_clock::now() + LASTVBLANK + - std::chrono::nanoseconds{int{presentationData->refresh ? presentationData->refresh : 1000000000 / pMonitor->refreshRate}}; + DATA->nextVblank = std::chrono::system_clock::now() + std::chrono::microseconds{µsUntilVblank}; } else µsUntilVblank = std::chrono::duration_cast(DATA->nextVblank - std::chrono::system_clock::now()).count(); - if (µsUntilVblank > 10) - DATA->vblankTimer->updateTimeout(std::chrono::microseconds((long)(µsUntilVblank - 100))); + if (µsUntilVblank > 100) + DATA->vblankTimer->updateTimeout(std::chrono::microseconds(µsUntilVblank - 100)); - Debug::log(LOG, "until vblank {:.2f}µs", µsUntilVblank); + Debug::log(LOG, "until vblank {}µs", µsUntilVblank); renderMonitor(DATA); diff --git a/src/managers/FrameSchedulingManager.hpp b/src/managers/FrameSchedulingManager.hpp index 60b277b7..dab00d77 100644 --- a/src/managers/FrameSchedulingManager.hpp +++ b/src/managers/FrameSchedulingManager.hpp @@ -48,7 +48,7 @@ class CFrameSchedulingManager { bool delayedFrameSubmitted = false; // we need to render a few full frames at the beginning to catch all buffers - int forceFrames = 5; + int forceFrames = 10; // last present timer CTimer lastPresent;