diff options
| -rw-r--r-- | services/surfaceflinger/Scheduler/VSyncPredictor.cpp | 19 | ||||
| -rw-r--r-- | 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); |