From 4b49ca7751748d2236fa8e0de347dd7f0d9a3b1c Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Mon, 25 Sep 2023 13:37:10 +0200 Subject: [PATCH] backends/drm: fix frame scheduling with pageflip timestamps in the future --- src/backends/drm/drm_commit_thread.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backends/drm/drm_commit_thread.cpp b/src/backends/drm/drm_commit_thread.cpp index dc08c94ddd..30b66de916 100644 --- a/src/backends/drm/drm_commit_thread.cpp +++ b/src/backends/drm/drm_commit_thread.cpp @@ -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); } }