Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9593b23 authored by Ady Abraham's avatar Ady Abraham Committed by Android (Google) Code Review
Browse files

Merge changes If230ef0a,I06a03d3c into main

* changes:
  SF: do not skip a frame if it will not cause backpressure on dvrr
  SF: improve activeMode log in dumpsys
parents 9679086f e9dcf79f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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);
    {
+27 −23
Original line number Diff line number Diff line
@@ -650,21 +650,24 @@ 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.
    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 (FlagManager::getInstance().vrr_config() && minFramePeriodOpt && mRenderRateOpt &&
               lastVsyncOpt) {
        } 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 "
                ATRACE_FORMAT_INSTANT("skipping a vsync to avoid duplicate frame. next in %.2f "
                                      "which "
                                      "is %.2f "
                                      "from "
                                      "prev. "
@@ -675,6 +678,7 @@ std::optional<TimePoint> VSyncPredictor::VsyncTimeline::nextAnticipatedVSyncTime
                vsyncTime += mRenderRateOpt->getPeriodNsecs();
            }
        }
    }

    ATRACE_FORMAT_INSTANT("vsync in %.2fms", float(vsyncTime - TimePoint::now().ns()) / 1e6f);
    if (mValidUntil && vsyncTime > mValidUntil->ns()) {
+5 −2
Original line number Diff line number Diff line
@@ -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