From 620075222fc22743dc409af6f018c9b5e442cbbf Mon Sep 17 00:00:00 2001 From: ramindani Date: Fri, 28 Jun 2024 11:17:12 -0700 Subject: SF: Move isWithin into implementation Update the comment for the freeze timeline at the vsync time. BUG: 343603085 Test: atest VSyncPredictorTest Flag: com.android.graphics.surfaceflinger.flags.vrr_bugfix_24q4 Change-Id: I78cbe386983d7f8cefaab1d3b0e94f0a034815af --- services/surfaceflinger/Scheduler/VSyncPredictor.cpp | 19 +++++++++++++++++-- services/surfaceflinger/Scheduler/VSyncPredictor.h | 13 +------------ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/services/surfaceflinger/Scheduler/VSyncPredictor.cpp b/services/surfaceflinger/Scheduler/VSyncPredictor.cpp index 16799bd32d..3fc39017fe 100644 --- a/services/surfaceflinger/Scheduler/VSyncPredictor.cpp +++ b/services/surfaceflinger/Scheduler/VSyncPredictor.cpp @@ -400,8 +400,9 @@ void VSyncPredictor::setRenderRate(Fps renderRate, bool applyImmediately) { } else { if (FlagManager::getInstance().vrr_bugfix_24q4()) { - // We need to freeze the timeline at the committed vsync so that we don't - // overshoot the deadline. + // We need to freeze the timeline at the committed vsync, and + // then use with threshold adjustments when required to avoid + // marginal errors when checking the vsync on the timeline. mTimelines.back().freeze(mLastCommittedVsync); } else { mTimelines.back().freeze( @@ -779,6 +780,20 @@ void VSyncPredictor::VsyncTimeline::shiftVsyncSequence(Duration phase) { } } +VSyncPredictor::VsyncTimeline::VsyncOnTimeline VSyncPredictor::VsyncTimeline::isWithin( + TimePoint vsync) { + const auto threshold = mIdealPeriod.ns() / 2; + if (!mValidUntil || vsync.ns() < mValidUntil->ns() - threshold) { + // if mValidUntil is absent then timeline is not frozen and + // vsync should be unique to that timeline. + return VsyncOnTimeline::Unique; + } + if (vsync.ns() > mValidUntil->ns() + threshold) { + return VsyncOnTimeline::Outside; + } + return VsyncOnTimeline::Shared; +} + } // namespace android::scheduler // TODO(b/129481165): remove the #pragma below and fix conversion issues diff --git a/services/surfaceflinger/Scheduler/VSyncPredictor.h b/services/surfaceflinger/Scheduler/VSyncPredictor.h index 66a7d71435..64e1029a43 100644 --- a/services/surfaceflinger/Scheduler/VSyncPredictor.h +++ b/services/surfaceflinger/Scheduler/VSyncPredictor.h @@ -111,18 +111,7 @@ private: Shared, // Within timeline, shared with next timeline. Outside, // Outside of the timeline. }; - VsyncOnTimeline isWithin(TimePoint vsync) { - const auto threshold = mIdealPeriod.ns() / 2; - if (!mValidUntil || vsync.ns() < mValidUntil->ns() - threshold) { - // if mValidUntil is absent then timeline is not frozen and - // vsync should be unique to that timeline. - return VsyncOnTimeline::Unique; - } - if (vsync.ns() > mValidUntil->ns() + threshold) { - return VsyncOnTimeline::Outside; - } - return VsyncOnTimeline::Shared; - } + VsyncOnTimeline isWithin(TimePoint vsync); private: nsecs_t snapToVsyncAlignedWithRenderRate(Model model, nsecs_t vsync); -- cgit v1.2.3-59-g8ed1b