This commit is contained in:
Vaxry 2024-03-18 21:46:25 +00:00
parent e5f379cd40
commit 0d478497f8
2 changed files with 12 additions and 6 deletions

View file

@ -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) {

View file

@ -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;