summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/surfaceflinger/Scheduler/RefreshRateSelector.cpp3
-rw-r--r--services/surfaceflinger/Scheduler/VSyncPredictor.cpp50
-rw-r--r--services/surfaceflinger/Scheduler/include/scheduler/FrameRateMode.h7
3 files changed, 34 insertions, 26 deletions
diff --git a/services/surfaceflinger/Scheduler/RefreshRateSelector.cpp b/services/surfaceflinger/Scheduler/RefreshRateSelector.cpp
index a37fb96b5b..2c664928ee 100644
--- a/services/surfaceflinger/Scheduler/RefreshRateSelector.cpp
+++ b/services/surfaceflinger/Scheduler/RefreshRateSelector.cpp
@@ -1590,7 +1590,8 @@ void RefreshRateSelector::dump(utils::Dumper& dumper) const {
std::lock_guard lock(mLock);
const auto activeMode = getActiveModeLocked();
- dumper.dump("activeMode"sv, to_string(activeMode));
+ dumper.dump("renderRate"sv, to_string(activeMode.fps));
+ dumper.dump("activeMode"sv, to_string(*activeMode.modePtr));
dumper.dump("displayModes"sv);
{
diff --git a/services/surfaceflinger/Scheduler/VSyncPredictor.cpp b/services/surfaceflinger/Scheduler/VSyncPredictor.cpp
index 0b47924e36..85ce713703 100644
--- a/services/surfaceflinger/Scheduler/VSyncPredictor.cpp
+++ b/services/surfaceflinger/Scheduler/VSyncPredictor.cpp
@@ -650,29 +650,33 @@ std::optional<TimePoint> VSyncPredictor::VsyncTimeline::nextAnticipatedVSyncTime
const auto threshold = model.slope / 2;
const auto lastFrameMissed =
lastVsyncOpt && std::abs(*lastVsyncOpt - missedVsync.vsync.ns()) < threshold;
- if (FlagManager::getInstance().vrr_config() && lastFrameMissed) {
- // If the last frame missed is the last vsync, we already shifted the timeline. Depends on
- // whether we skipped the frame (onFrameMissed) or not (onFrameBegin) we apply a different
- // fixup. There is no need to to shift the vsync timeline again.
- vsyncTime += missedVsync.fixup.ns();
- ATRACE_FORMAT_INSTANT("lastFrameMissed");
- } else if (FlagManager::getInstance().vrr_config() && minFramePeriodOpt && mRenderRateOpt &&
- lastVsyncOpt) {
- // lastVsyncOpt is based on the old timeline before we shifted it. we should correct it
- // first before trying to use it.
- lastVsyncOpt = snapToVsyncAlignedWithRenderRate(model, *lastVsyncOpt);
- const auto vsyncDiff = vsyncTime - *lastVsyncOpt;
- if (vsyncDiff <= minFramePeriodOpt->ns() - threshold) {
- // avoid a duplicate vsync
- ATRACE_FORMAT_INSTANT("skipping a vsync to avoid duplicate frame. next in %.2f which "
- "is %.2f "
- "from "
- "prev. "
- "adjust by %.2f",
- static_cast<float>(vsyncTime - TimePoint::now().ns()) / 1e6f,
- static_cast<float>(vsyncDiff) / 1e6f,
- static_cast<float>(mRenderRateOpt->getPeriodNsecs()) / 1e6f);
- vsyncTime += mRenderRateOpt->getPeriodNsecs();
+ const auto mightBackpressure = minFramePeriodOpt && mRenderRateOpt &&
+ mRenderRateOpt->getPeriod() < 2 * (*minFramePeriodOpt);
+ if (FlagManager::getInstance().vrr_config()) {
+ if (lastFrameMissed) {
+ // If the last frame missed is the last vsync, we already shifted the timeline. Depends
+ // on whether we skipped the frame (onFrameMissed) or not (onFrameBegin) we apply a
+ // different fixup. There is no need to to shift the vsync timeline again.
+ vsyncTime += missedVsync.fixup.ns();
+ ATRACE_FORMAT_INSTANT("lastFrameMissed");
+ } else if (mightBackpressure && lastVsyncOpt) {
+ // lastVsyncOpt is based on the old timeline before we shifted it. we should correct it
+ // first before trying to use it.
+ lastVsyncOpt = snapToVsyncAlignedWithRenderRate(model, *lastVsyncOpt);
+ const auto vsyncDiff = vsyncTime - *lastVsyncOpt;
+ if (vsyncDiff <= minFramePeriodOpt->ns() - threshold) {
+ // avoid a duplicate vsync
+ ATRACE_FORMAT_INSTANT("skipping a vsync to avoid duplicate frame. next in %.2f "
+ "which "
+ "is %.2f "
+ "from "
+ "prev. "
+ "adjust by %.2f",
+ static_cast<float>(vsyncTime - TimePoint::now().ns()) / 1e6f,
+ static_cast<float>(vsyncDiff) / 1e6f,
+ static_cast<float>(mRenderRateOpt->getPeriodNsecs()) / 1e6f);
+ vsyncTime += mRenderRateOpt->getPeriodNsecs();
+ }
}
}
diff --git a/services/surfaceflinger/Scheduler/include/scheduler/FrameRateMode.h b/services/surfaceflinger/Scheduler/include/scheduler/FrameRateMode.h
index 59a6df23fd..f2be316452 100644
--- a/services/surfaceflinger/Scheduler/include/scheduler/FrameRateMode.h
+++ b/services/surfaceflinger/Scheduler/include/scheduler/FrameRateMode.h
@@ -36,8 +36,11 @@ struct FrameRateMode {
};
inline std::string to_string(const FrameRateMode& mode) {
- return to_string(mode.fps) + " (" + to_string(mode.modePtr->getPeakFps()) + "(" +
- to_string(mode.modePtr->getVsyncRate()) + "))";
+ return base::StringPrintf("{fps=%s, modePtr={id=%d, vsyncRate=%s, peakRefreshRate=%s}}",
+ to_string(mode.fps).c_str(),
+ ftl::to_underlying(mode.modePtr->getId()),
+ to_string(mode.modePtr->getVsyncRate()).c_str(),
+ to_string(mode.modePtr->getPeakFps()).c_str());
}
} // namespace android::scheduler