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

Commit 1d1b6a4b authored by Matt Buckley's avatar Matt Buckley Committed by Automerger Merge Worker
Browse files

Merge "Fix SF hint sessions for virtual multi-display case" into tm-qpr-dev am: a69f18cf

parents 0de065d0 a69f18cf
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -55,7 +55,8 @@ public:
    MOCK_METHOD(void, setRequiresClientComposition,
                (DisplayId displayId, bool requiresClientComposition), (override));
    MOCK_METHOD(void, setExpectedPresentTime, (nsecs_t expectedPresentTime), (override));
    MOCK_METHOD(void, setPresentFenceTime, (nsecs_t presentFenceTime), (override));
    MOCK_METHOD(void, setSfPresentTiming, (nsecs_t presentFenceTime, nsecs_t presentEndTime),
                (override));
    MOCK_METHOD(void, setHwcPresentDelayedTime,
                (DisplayId displayId,
                 std::chrono::steady_clock::time_point earliestFrameStartTime));
+11 −10
Original line number Diff line number Diff line
@@ -315,7 +315,8 @@ void PowerAdvisor::setExpectedPresentTime(nsecs_t expectedPresentTime) {
    mExpectedPresentTimes.append(expectedPresentTime);
}

void PowerAdvisor::setPresentFenceTime(nsecs_t presentFenceTime) {
void PowerAdvisor::setSfPresentTiming(nsecs_t presentFenceTime, nsecs_t presentEndTime) {
    mLastSfPresentEndTime = presentEndTime;
    mLastPresentFenceTime = presentFenceTime;
}

@@ -334,13 +335,7 @@ void PowerAdvisor::setCommitStart(nsecs_t commitStartTime) {
}

void PowerAdvisor::setCompositeEnd(nsecs_t compositeEnd) {
    mLastCompositeEndTime = compositeEnd;
    // calculate the postcomp time here as well
    std::vector<DisplayId>&& displays = getOrderedDisplayIds(&DisplayTimingData::hwcPresentEndTime);
    DisplayTimingData& timingData = mDisplayTimingData[displays.back()];
    mLastPostcompDuration = compositeEnd -
            (timingData.skippedValidate ? *timingData.hwcValidateEndTime
                                        : *timingData.hwcPresentEndTime);
    mLastPostcompDuration = compositeEnd - mLastSfPresentEndTime;
}

void PowerAdvisor::setDisplays(std::vector<DisplayId>& displayIds) {
@@ -399,7 +394,7 @@ std::optional<nsecs_t> PowerAdvisor::estimateWorkDuration(bool earlyHint) {
            getOrderedDisplayIds(&DisplayTimingData::hwcPresentStartTime);
    DisplayTimeline referenceTiming, estimatedTiming;

    // Iterate over the displays in the same order they are presented
    // Iterate over the displays that use hwc in the same order they are presented
    for (DisplayId displayId : displayIds) {
        if (mDisplayTimingData.count(displayId) == 0) {
            continue;
@@ -451,8 +446,11 @@ std::optional<nsecs_t> PowerAdvisor::estimateWorkDuration(bool earlyHint) {
    }
    ATRACE_INT64("Idle duration", idleDuration);

    nsecs_t estimatedFlingerEndTime = earlyHint ? estimatedEndTime : mLastSfPresentEndTime;

    // Don't count time spent idly waiting in the estimate as we could do more work in that time
    estimatedEndTime -= idleDuration;
    estimatedFlingerEndTime -= idleDuration;

    // We finish the frame when both present and the gpu are done, so wait for the later of the two
    // Also add the frame delay duration since the target did not move while we were delayed
@@ -460,7 +458,10 @@ std::optional<nsecs_t> PowerAdvisor::estimateWorkDuration(bool earlyHint) {
            std::max(estimatedEndTime, estimatedGpuEndTime.value_or(0)) - mCommitStartTimes[0];

    // We finish SurfaceFlinger when post-composition finishes, so add that in here
    nsecs_t flingerDuration = estimatedEndTime + mLastPostcompDuration - mCommitStartTimes[0];
    nsecs_t flingerDuration =
            estimatedFlingerEndTime + mLastPostcompDuration - mCommitStartTimes[0];

    // Combine the two timings into a single normalized one
    nsecs_t combinedDuration = combineTimingEstimates(totalDuration, flingerDuration);

    return std::make_optional(combinedDuration);
+5 −5
Original line number Diff line number Diff line
@@ -72,8 +72,8 @@ public:
                                     nsecs_t presentEndTime) = 0;
    // Reports the expected time that the current frame will present to the display
    virtual void setExpectedPresentTime(nsecs_t expectedPresentTime) = 0;
    // Reports the most recent present fence time once it's known at the end of the frame
    virtual void setPresentFenceTime(nsecs_t presentFenceTime) = 0;
    // Reports the most recent present fence time and end time once known
    virtual void setSfPresentTiming(nsecs_t presentFenceTime, nsecs_t presentEndTime) = 0;
    // Reports whether a display used client composition this frame
    virtual void setRequiresClientComposition(DisplayId displayId,
                                              bool requiresClientComposition) = 0;
@@ -142,7 +142,7 @@ public:
    void setSkippedValidate(DisplayId displayId, bool skipped) override;
    void setRequiresClientComposition(DisplayId displayId, bool requiresClientComposition) override;
    void setExpectedPresentTime(nsecs_t expectedPresentTime) override;
    void setPresentFenceTime(nsecs_t presentFenceTime) override;
    void setSfPresentTiming(nsecs_t presentFenceTime, nsecs_t presentEndTime) override;
    void setHwcPresentDelayedTime(
            DisplayId displayId,
            std::chrono::steady_clock::time_point earliestFrameStartTime) override;
@@ -245,8 +245,6 @@ private:

    // Current frame's delay
    nsecs_t mFrameDelayDuration = 0;
    // Last frame's composite end time
    nsecs_t mLastCompositeEndTime = -1;
    // Last frame's post-composition duration
    nsecs_t mLastPostcompDuration = 0;
    // Buffer of recent commit start times
@@ -255,6 +253,8 @@ private:
    RingBuffer<nsecs_t, 2> mExpectedPresentTimes;
    // Most recent present fence time, set at the end of the frame once known
    nsecs_t mLastPresentFenceTime = -1;
    // Most recent present fence time, set at the end of the frame once known
    nsecs_t mLastSfPresentEndTime = -1;
    // Target for the entire pipeline including gpu
    std::optional<nsecs_t> mTotalFrameTargetDuration;
    // Updated list of display IDs
+2 −1
Original line number Diff line number Diff line
@@ -2254,7 +2254,8 @@ void SurfaceFlinger::composite(nsecs_t frameTime, int64_t vsyncId)

    // Send a power hint hint after presentation is finished
    if (mPowerHintSessionEnabled) {
        mPowerAdvisor->setPresentFenceTime(mPreviousPresentFences[0].fenceTime->getSignalTime());
        mPowerAdvisor->setSfPresentTiming(mPreviousPresentFences[0].fenceTime->getSignalTime(),
                                          systemTime());
        if (mPowerHintSessionMode.late) {
            mPowerAdvisor->sendActualWorkDuration();
        }
+2 −1
Original line number Diff line number Diff line
@@ -53,7 +53,8 @@ public:
    MOCK_METHOD(void, setRequiresClientComposition,
                (DisplayId displayId, bool requiresClientComposition), (override));
    MOCK_METHOD(void, setExpectedPresentTime, (nsecs_t expectedPresentTime), (override));
    MOCK_METHOD(void, setPresentFenceTime, (nsecs_t presentFenceTime), (override));
    MOCK_METHOD(void, setSfPresentTiming, (nsecs_t presentFenceTime, nsecs_t presentEndTime),
                (override));
    MOCK_METHOD(void, setHwcPresentDelayedTime,
                (DisplayId displayId,
                 std::chrono::steady_clock::time_point earliestFrameStartTime));