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

Commit aa7ebd6a authored by Ady Abraham's avatar Ady Abraham
Browse files

SF: call onFrameBegin before scheduling the next frame

Bug: 329036771
Test: presubmit

Change-Id: Ie8643df787aa1080c59f280b005b40841715970b
parent 030337de
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -250,18 +250,6 @@ void Scheduler::onFrameSignal(ICompositor& compositor, VsyncId vsyncId,
        mPacesetterFrameDurationFractionToSkip = 0.f;
    }

    if (FlagManager::getInstance().vrr_config()) {
        const auto minFramePeriod = pacesetterPtr->schedulePtr->minFramePeriod();
        const auto presentFenceForPastVsync =
                pacesetterPtr->targeterPtr->target().presentFenceForPastVsync(minFramePeriod);
        const auto lastConfirmedPresentTime = presentFenceForPastVsync->getSignalTime();
        if (lastConfirmedPresentTime != Fence::SIGNAL_TIME_PENDING &&
            lastConfirmedPresentTime != Fence::SIGNAL_TIME_INVALID) {
            pacesetterPtr->schedulePtr->getTracker()
                    .onFrameBegin(expectedVsyncTime, TimePoint::fromNs(lastConfirmedPresentTime));
        }
    }

    const auto resultsPerDisplay = compositor.composite(pacesetterPtr->displayId, targeters);
    if (FlagManager::getInstance().vrr_config()) {
        compositor.sendNotifyExpectedPresentHint(pacesetterPtr->displayId);
+2 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ public:
    bool isFramePending() const { return mFramePending; }
    bool didMissFrame() const { return mFrameMissed; }
    bool didMissHwcFrame() const { return mHwcFrameMissed && !mGpuFrameMissed; }
    TimePoint lastSignaledFrameTime() const { return mLastSignaledFrameTime; };

protected:
    explicit FrameTarget(const std::string& displayLabel);
@@ -98,6 +99,7 @@ protected:
        FenceTimePtr fenceTime = FenceTime::NO_FENCE;
    };
    std::array<FenceWithFenceTime, 2> mPresentFences;
    TimePoint mLastSignaledFrameTime;

private:
    friend class FrameTargeterTestBase;
+1 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ void FrameTargeter::beginFrame(const BeginFrameArgs& args, const IVsyncSource& v
    mFrameMissed = mFramePending || [&] {
        const nsecs_t pastPresentTime = pastPresentFence->getSignalTime();
        if (pastPresentTime < 0) return false;
        mLastSignaledFrameTime = TimePoint::fromNs(pastPresentTime);
        const nsecs_t frameMissedSlop = vsyncPeriod.ns() / 2;
        return lastScheduledPresentTime.ns() < pastPresentTime - frameMissedSlop;
    }();
+8 −0
Original line number Diff line number Diff line
@@ -2606,6 +2606,14 @@ bool SurfaceFlinger::commit(PhysicalDisplayId pacesetterId,
                                         flushTransactions, transactionsAreEmpty);
        }

        // Tell VsyncTracker that we are going to present this frame before scheduling
        // setTransactionFlags which will schedule another SF frame. This was if the tracker
        // needs to adjust the vsync timeline, it will be done before the next frame.
        if (FlagManager::getInstance().vrr_config() && mustComposite) {
            mScheduler->getVsyncSchedule()->getTracker().onFrameBegin(
                pacesetterFrameTarget.expectedPresentTime(),
                pacesetterFrameTarget.lastSignaledFrameTime());
        }
        if (transactionFlushNeeded()) {
            setTransactionFlags(eTransactionFlushNeeded);
        }