From ff061d177e86435a0d9f5605153a4567e2fcd88b Mon Sep 17 00:00:00 2001 From: UjinT34 <41110182+UjinT34@users.noreply.github.com> Date: Tue, 10 Feb 2026 17:55:21 +0300 Subject: protocols: commit and presentation timing fixes (#13174) * move commit timing fields to surface state * fix toTimespec init * update sendQueued api * update onPresented api * set zero copy flag * send clock id * move presented calcs inside condition * use only CLOCK_MONOTONIC for commit/presentation timings * fix setSetTimestamp * do not wait for commit timing while tearing * proto config * fix config defaults --- src/helpers/Monitor.cpp | 10 ++++++---- src/helpers/time/Time.cpp | 9 ++++++++- src/helpers/time/Time.hpp | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src/helpers') diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index f0077c63..be0b78fd 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -114,10 +114,12 @@ void CMonitor::onConnect(bool noRule) { ts = nullptr; } - if (!ts) - PROTO::presentation->onPresented(m_self.lock(), Time::steadyNow(), event.refresh, event.seq, event.flags); - else - PROTO::presentation->onPresented(m_self.lock(), Time::fromTimespec(event.when), event.refresh, event.seq, event.flags); + if (!ts) { + timespec mono{}; + clock_gettime(CLOCK_MONOTONIC, &mono); + PROTO::presentation->onPresented(m_self.lock(), mono, event.refresh, event.seq, event.flags & ~Aquamarine::IOutput::AQ_OUTPUT_PRESENT_HW_CLOCK); + } else + PROTO::presentation->onPresented(m_self.lock(), *ts, event.refresh, event.seq, event.flags); if (m_zoomAnimFrameCounter < 5) { m_zoomAnimFrameCounter++; diff --git a/src/helpers/time/Time.cpp b/src/helpers/time/Time.cpp index 7ef24e22..f454b784 100644 --- a/src/helpers/time/Time.cpp +++ b/src/helpers/time/Time.cpp @@ -103,7 +103,7 @@ Time::steady_tp Time::fromTimespec(const timespec* ts) { } struct timespec Time::toTimespec(const steady_tp& tp) { - struct timespec mono, real; + timespec mono{}, real{}; clock_gettime(CLOCK_MONOTONIC, &mono); clock_gettime(CLOCK_REALTIME, &real); Time::steady_tp now = Time::steadyNow(); @@ -136,3 +136,10 @@ struct timespec Time::toTimespec(const steady_tp& tp) { auto sum = timeadd(tpTime, diffFinal); return timespec{.tv_sec = sum.first, .tv_nsec = sum.second}; } + +Time::steady_dur Time::till(const timespec& ts) { + timespec mono{}; + clock_gettime(CLOCK_MONOTONIC, &mono); + const auto delay = (ts.tv_sec - mono.tv_sec) * 1000000000 + (ts.tv_nsec - mono.tv_nsec); + return std::chrono::nanoseconds(delay); +} diff --git a/src/helpers/time/Time.hpp b/src/helpers/time/Time.hpp index eb3b5771..ce99982b 100644 --- a/src/helpers/time/Time.hpp +++ b/src/helpers/time/Time.hpp @@ -17,6 +17,7 @@ namespace Time { steady_tp fromTimespec(const timespec*); struct timespec toTimespec(const steady_tp& tp); + steady_dur till(const timespec& ts); uint64_t millis(const steady_tp& tp); uint64_t millis(const system_tp& tp); -- cgit v1.2.3