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

Commit c7c3ed1b authored by Ram Indani's avatar Ram Indani Committed by Android (Google) Code Review
Browse files

Merge changes I5b0dd111,I40135534,Ief7fff69 into main

* changes:
  [SF] Change VSyncDispatchTimerQueue::Schedule to return ScheduleResult
  [SF] Enable vrr_timeout_hint_enabled
  [SF] Send NotifyExpectedPresentHint at the transaction time
parents 674215c1 558f4a96
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ HWComposer::HWComposer(std::unique_ptr<Hwc2::Composer> composer)
        mMaxVirtualDisplayDimension(static_cast<size_t>(sysprop::max_virtual_display_dimension(0))),
        mUpdateDeviceProductInfoOnHotplugReconnect(
                sysprop::update_device_product_info_on_hotplug_reconnect(false)),
        mEnableVrrTimeout(base::GetBoolProperty("debug.sf.vrr_timeout_hint_enabled"s, false)) {}
        mEnableVrrTimeout(base::GetBoolProperty("debug.sf.vrr_timeout_hint_enabled"s, true)) {}

HWComposer::HWComposer(const std::string& composerServiceName)
      : HWComposer(Hwc2::Composer::create(composerServiceName)) {}
+8 −11
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
#define ATRACE_TAG ATRACE_TAG_GRAPHICS

#include <binder/IPCThreadState.h>
#include <gui/DisplayEventReceiver.h>
#include <utils/Log.h>
#include <utils/Timers.h>
#include <utils/threads.h>
@@ -66,7 +65,7 @@ void MessageQueue::vsyncCallback(nsecs_t vsyncTime, nsecs_t targetWakeupTime, ns
    {
        std::lock_guard lock(mVsync.mutex);
        mVsync.lastCallbackTime = expectedVsyncTime;
        mVsync.scheduledFrameTime.reset();
        mVsync.scheduledFrameTimeOpt.reset();
    }

    const auto vsyncId = VsyncId{mVsync.tokenManager->generateTokenForPredictions(
@@ -122,7 +121,7 @@ std::unique_ptr<scheduler::VSyncCallbackRegistration> MessageQueue::onNewVsyncSc
                                                            std::placeholders::_3),
                                                  "sf");
    if (reschedule) {
        mVsync.scheduledFrameTime =
        mVsync.scheduledFrameTimeOpt =
                mVsync.registration->schedule({.workDuration = mVsync.workDuration.get().count(),
                                               .readyDuration = 0,
                                               .lastVsync = mVsync.lastCallbackTime.ns()});
@@ -140,7 +139,7 @@ void MessageQueue::setDuration(std::chrono::nanoseconds workDuration) {
    ATRACE_CALL();
    std::lock_guard lock(mVsync.mutex);
    mVsync.workDuration = workDuration;
    mVsync.scheduledFrameTime =
    mVsync.scheduledFrameTimeOpt =
            mVsync.registration->update({.workDuration = mVsync.workDuration.get().count(),
                                         .readyDuration = 0,
                                         .lastVsync = mVsync.lastCallbackTime.ns()});
@@ -193,22 +192,20 @@ void MessageQueue::scheduleFrame() {
    ATRACE_CALL();

    std::lock_guard lock(mVsync.mutex);
    mVsync.scheduledFrameTime =
    mVsync.scheduledFrameTimeOpt =
            mVsync.registration->schedule({.workDuration = mVsync.workDuration.get().count(),
                                           .readyDuration = 0,
                                           .lastVsync = mVsync.lastCallbackTime.ns()});
}

auto MessageQueue::getScheduledFrameTime() const -> std::optional<Clock::time_point> {
std::optional<scheduler::ScheduleResult> MessageQueue::getScheduledFrameResult() const {
    if (mHandler->isFramePending()) {
        return Clock::now();
        return scheduler::ScheduleResult{TimePoint::now(), mHandler->getExpectedVsyncTime()};
    }

    std::lock_guard lock(mVsync.mutex);
    if (const auto time = mVsync.scheduledFrameTime) {
        return Clock::time_point(std::chrono::nanoseconds(*time));
    if (const auto scheduledFrameTimeline = mVsync.scheduledFrameTimeOpt) {
        return scheduledFrameTimeline;
    }

    return std::nullopt;
}

+6 −5
Original line number Diff line number Diff line
@@ -76,8 +76,7 @@ public:
    virtual void scheduleConfigure() = 0;
    virtual void scheduleFrame() = 0;

    using Clock = std::chrono::steady_clock;
    virtual std::optional<Clock::time_point> getScheduledFrameTime() const = 0;
    virtual std::optional<scheduler::ScheduleResult> getScheduledFrameResult() const = 0;
};

namespace impl {
@@ -95,7 +94,9 @@ protected:
        explicit Handler(MessageQueue& queue) : mQueue(queue) {}
        void handleMessage(const Message& message) override;

        bool isFramePending() const;
        virtual TimePoint getExpectedVsyncTime() const { return mExpectedVsyncTime.load(); }

        virtual bool isFramePending() const;

        virtual void dispatchFrame(VsyncId, TimePoint expectedVsyncTime);
    };
@@ -124,7 +125,7 @@ private:
        TracedOrdinal<std::chrono::nanoseconds> workDuration
                GUARDED_BY(mutex) = {"VsyncWorkDuration-sf", std::chrono::nanoseconds(0)};
        TimePoint lastCallbackTime GUARDED_BY(mutex);
        std::optional<nsecs_t> scheduledFrameTime GUARDED_BY(mutex);
        std::optional<scheduler::ScheduleResult> scheduledFrameTimeOpt GUARDED_BY(mutex);
        TracedOrdinal<int> value = {"VSYNC-sf", 0};
    };

@@ -150,7 +151,7 @@ public:
    void scheduleConfigure() override;
    void scheduleFrame() override;

    std::optional<Clock::time_point> getScheduledFrameTime() const override;
    std::optional<scheduler::ScheduleResult> getScheduledFrameResult() const override;
};

} // namespace impl
+1 −1
Original line number Diff line number Diff line
@@ -109,9 +109,9 @@ public:

    void initVsync(frametimeline::TokenManager&, std::chrono::nanoseconds workDuration);

    using Impl::getScheduledFrameTime;
    using Impl::setDuration;

    using Impl::getScheduledFrameResult;
    using Impl::scheduleConfigure;
    using Impl::scheduleFrame;

+15 −7
Original line number Diff line number Diff line
@@ -21,11 +21,15 @@
#include <string>

#include <ftl/mixins.h>
#include <scheduler/Time.h>
#include <utils/Timers.h>

namespace android::scheduler {

using ScheduleResult = std::optional<nsecs_t>;
struct ScheduleResult {
    TimePoint callbackTime;
    TimePoint vsyncTime;
};

enum class CancelResult { Cancelled, TooLate, Error };

@@ -124,10 +128,12 @@ public:
     *
     * \param [in] token           The callback to schedule.
     * \param [in] scheduleTiming  The timing information for this schedule call
     * \return                     The expected callback time if a callback was scheduled.
     * \return                     The expected callback time if a callback was scheduled,
     *                             along with VSYNC time for the callback scheduled.
     *                             std::nullopt if the callback is not registered.
     */
    virtual ScheduleResult schedule(CallbackToken token, ScheduleTiming scheduleTiming) = 0;
    virtual std::optional<ScheduleResult> schedule(CallbackToken token,
                                                   ScheduleTiming scheduleTiming) = 0;

    /*
     * Update the timing information for a scheduled callback.
@@ -135,10 +141,12 @@ public:
     *
     * \param [in] token           The callback to schedule.
     * \param [in] scheduleTiming  The timing information for this schedule call
     * \return                     The expected callback time if a callback was scheduled.
     * \return                     The expected callback time if a callback was scheduled,
     *                             along with VSYNC time for the callback scheduled.
     *                             std::nullopt if the callback is not registered.
     */
    virtual ScheduleResult update(CallbackToken token, ScheduleTiming scheduleTiming) = 0;
    virtual std::optional<ScheduleResult> update(CallbackToken token,
                                                 ScheduleTiming scheduleTiming) = 0;

    /* Cancels a scheduled callback, if possible.
     *
@@ -168,10 +176,10 @@ public:
    VSyncCallbackRegistration& operator=(VSyncCallbackRegistration&&);

    // See documentation for VSyncDispatch::schedule.
    ScheduleResult schedule(VSyncDispatch::ScheduleTiming scheduleTiming);
    std::optional<ScheduleResult> schedule(VSyncDispatch::ScheduleTiming scheduleTiming);

    // See documentation for VSyncDispatch::update.
    ScheduleResult update(VSyncDispatch::ScheduleTiming scheduleTiming);
    std::optional<ScheduleResult> update(VSyncDispatch::ScheduleTiming scheduleTiming);

    // See documentation for VSyncDispatch::cancel.
    CancelResult cancel();
Loading