backends/drm: fix frame scheduling with pageflip timestamps in the future

This commit is contained in:
Xaver Hugl 2023-09-25 13:37:10 +02:00
parent 028dd552cf
commit 4b49ca7751

View file

@ -226,7 +226,8 @@ bool DrmCommitThread::pageflipsPending()
TimePoint DrmCommitThread::estimateNextVblank(TimePoint now) const
{
const uint64_t pageflipsSince = (now - m_lastPageflip) / m_minVblankInterval;
// the pageflip timestamp may be in the future
const uint64_t pageflipsSince = now >= m_lastPageflip ? (now - m_lastPageflip) / m_minVblankInterval : 0;
return m_lastPageflip + m_minVblankInterval * (pageflipsSince + 1);
}
}