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

Commit 128de254 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I32346436,Idb65880a into main

* changes:
  SF: add the first vsync timestamp when confirming period
  SF: add flag add_first_vsync_to_tracker
parents c82d9554 cc138dad
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -170,7 +170,7 @@ bool VSyncReactor::periodConfirmed(nsecs_t vsync_timestamp, std::optional<nsecs_
        return true;
    }

    if (!mLastHwVsync && !HwcVsyncPeriod) {
    if (!mLastHwVsync.get() && !HwcVsyncPeriod) {
        return false;
    }

@@ -191,7 +191,7 @@ bool VSyncReactor::periodConfirmed(nsecs_t vsync_timestamp, std::optional<nsecs_
        return std::abs(*HwcVsyncPeriod - period) < allowance;
    }

    auto const distance = vsync_timestamp - *mLastHwVsync;
    auto const distance = vsync_timestamp - *mLastHwVsync.get();
    return std::abs(distance - period) < allowance;
}

@@ -207,8 +207,9 @@ bool VSyncReactor::addHwVsyncTimestamp(nsecs_t timestamp, std::optional<nsecs_t>
            *periodFlushed = true;
        }

        if (mLastHwVsync) {
            mTracker.addVsyncTimestamp(*mLastHwVsync);
        if (mLastHwVsync.get() &&
            (!FlagManager::getInstance().add_first_vsync_to_tracker() || !mLastHwVsync.isFirst())) {
            mTracker.addVsyncTimestamp(*mLastHwVsync.get());
        }
        mTracker.addVsyncTimestamp(timestamp);

@@ -216,7 +217,11 @@ bool VSyncReactor::addHwVsyncTimestamp(nsecs_t timestamp, std::optional<nsecs_t>
        mMoreSamplesNeeded = mTracker.needsMoreSamples();
    } else if (mPeriodConfirmationInProgress) {
        SFTRACE_FORMAT("VSR %" PRIu64 ": still confirming period", mId.value);
        mLastHwVsync = timestamp;
        mLastHwVsync.set(timestamp);
        // Add the first vsync callback to the tracker to be based on a fresh vsync
        if (FlagManager::getInstance().add_first_vsync_to_tracker() && mLastHwVsync.isFirst()) {
            mTracker.addVsyncTimestamp(*mLastHwVsync.get());
        }
        mMoreSamplesNeeded = true;
        *periodFlushed = false;
    } else {
@@ -263,9 +268,9 @@ void VSyncReactor::dump(std::string& result) const {
        StringAppendF(&result, "mModePtrTransitioningTo=nullptr\n");
    }

    if (mLastHwVsync) {
    if (mLastHwVsync.get()) {
        StringAppendF(&result, "Last HW vsync was %.2fms ago\n",
                      (mClock->now() - *mLastHwVsync) / 1e6f);
                      (mClock->now() - *mLastHwVsync.get()) / 1e6f);
    } else {
        StringAppendF(&result, "No Last HW vsync\n");
    }
+22 −1
Original line number Diff line number Diff line
@@ -79,7 +79,28 @@ private:
    bool mMoreSamplesNeeded GUARDED_BY(mMutex) = false;
    bool mPeriodConfirmationInProgress GUARDED_BY(mMutex) = false;
    DisplayModePtr mModePtrTransitioningTo GUARDED_BY(mMutex);
    std::optional<nsecs_t> mLastHwVsync GUARDED_BY(mMutex);

    class LastHwVsync {
    public:
        LastHwVsync() { reset(); }
        void reset() {
            mFirst = true;
            mVsync.reset();
        }
        bool isFirst() const { return mFirst; }
        std::optional<nsecs_t> get() const { return mVsync; }
        void set(nsecs_t vsync) {
            if (mVsync.has_value()) {
                mFirst = false;
            }
            mVsync = vsync;
        }

    private:
        bool mFirst;
        std::optional<nsecs_t> mVsync;
    };
    LastHwVsync mLastHwVsync GUARDED_BY(mMutex);

    hal::PowerMode mDisplayPowerMode GUARDED_BY(mMutex) = hal::PowerMode::ON;

+2 −0
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ void FlagManager::dump(std::string& result) const {
    DUMP_LEGACY_SERVER_FLAG(use_skia_tracing);

    /// Trunk stable server (R/W) flags ///
    DUMP_ACONFIG_FLAG(add_first_vsync_to_tracker);
    DUMP_ACONFIG_FLAG(adpf_cpu_effects_loadup);
    DUMP_ACONFIG_FLAG(adpf_gpu_sf);
    DUMP_ACONFIG_FLAG(adpf_native_session_manager);
@@ -286,6 +287,7 @@ FLAG_MANAGER_ACONFIG_FLAG(window_blur_kawase2, "");
FLAG_MANAGER_ACONFIG_FLAG(synced_resolution_switch, "");

/// Trunk stable server (R/W) flags ///
FLAG_MANAGER_ACONFIG_FLAG(add_first_vsync_to_tracker, "")
FLAG_MANAGER_ACONFIG_FLAG(refresh_rate_overlay_on_external_display, "")
FLAG_MANAGER_ACONFIG_FLAG(adpf_cpu_effects_loadup, "");
FLAG_MANAGER_ACONFIG_FLAG(adpf_gpu_sf, "")
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ public:
    bool use_skia_tracing() const;

    /// Trunk stable server (R/W) flags ///
    bool add_first_vsync_to_tracker() const;
    bool adpf_cpu_effects_loadup() const;
    bool adpf_gpu_sf() const;
    bool adpf_native_session_manager() const;
+10 −0
Original line number Diff line number Diff line
@@ -3,6 +3,16 @@
package: "com.android.graphics.surfaceflinger.flags"
container: "system"

flag {
  name: "add_first_vsync_to_tracker"
  namespace: "core_graphics"
  description: "Add the first vsync timestamp to vsync tracker when priod confirmation is still in progress"
  bug: "422343157"
  metadata {
      purpose: PURPOSE_BUGFIX
    }
} # add_first_vsync_to_tracker

flag {
  name: "adpf_cpu_effects_loadup"
  namespace: "window_surfaces"