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

Commit 3db8a3c4 authored by Ady Abraham's avatar Ady Abraham
Browse files

SF: use peak refresh rate for HWC backpressure

The logic we have for selecting which fence to use to detect
backpressure replies on the assumption that continuously presents as
the rate of vsync. This is not true for VRR displays.

Bug: 296635687
Test: adb root && adb shell service call SurfaceFlinger 1045 f 0.9
Change-Id: Iaceb45741fd657b8c551f51b3c76a643df116da8
parent c585dbac
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -62,5 +62,9 @@ cc_test {
        "libgmock",
        "libgtest",
        "libscheduler",
        "libsurfaceflingerflags_test",
    ],
    shared_libs: [
        "server_configurable_flags",
    ],
}
+13 −0
Original line number Diff line number Diff line
@@ -108,6 +108,19 @@ nsecs_t VSyncPredictor::currentPeriod() const {
    return mRateMap.find(idealPeriod())->second.slope;
}

Period VSyncPredictor::minFramePeriod() const {
    if (!FlagManager::getInstance().vrr_config()) {
        return Period::fromNs(currentPeriod());
    }

    std::lock_guard lock(mMutex);
    const auto idealPeakRefreshPeriod = mDisplayModePtr->getPeakFps().getPeriodNsecs();
    const auto numPeriods = static_cast<int>(std::round(static_cast<float>(idealPeakRefreshPeriod) /
                                                        static_cast<float>(idealPeriod())));
    const auto slope = mRateMap.find(idealPeriod())->second.slope;
    return Period::fromNs(slope * numPeriods);
}

bool VSyncPredictor::addVsyncTimestamp(nsecs_t timestamp) {
    std::lock_guard lock(mMutex);

+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ public:
    bool addVsyncTimestamp(nsecs_t timestamp) final EXCLUDES(mMutex);
    nsecs_t nextAnticipatedVSyncTimeFrom(nsecs_t timePoint) const final EXCLUDES(mMutex);
    nsecs_t currentPeriod() const final EXCLUDES(mMutex);
    Period minFramePeriod() const final EXCLUDES(mMutex);
    void resetModel() final EXCLUDES(mMutex);

    /* Query if the model is in need of more samples to make a prediction.
+5 −0
Original line number Diff line number Diff line
@@ -68,6 +68,11 @@ public:
     */
    virtual nsecs_t currentPeriod() const = 0;

    /*
     * The minimal period frames can be displayed.
     */
    virtual Period minFramePeriod() const = 0;

    /* Inform the tracker that the samples it has are not accurate for prediction. */
    virtual void resetModel() = 0;

+7 −0
Original line number Diff line number Diff line
@@ -81,6 +81,13 @@ Period VsyncSchedule::period() const {
    return Period::fromNs(mTracker->currentPeriod());
}

Period VsyncSchedule::minFramePeriod() const {
    if (FlagManager::getInstance().vrr_config()) {
        return mTracker->minFramePeriod();
    }
    return period();
}

TimePoint VsyncSchedule::vsyncDeadlineAfter(TimePoint timePoint) const {
    return TimePoint::fromNs(mTracker->nextAnticipatedVSyncTimeFrom(timePoint.ns()));
}
Loading