|
32 | 32 | #include <fmq/AidlMessageQueue.h> |
33 | 33 | #pragma clang diagnostic pop |
34 | 34 |
|
| 35 | +#include <common/trace.h> |
| 36 | +#include <ftl/flags.h> |
35 | 37 | #include <scheduler/Time.h> |
36 | 38 | #include <ui/DisplayIdentification.h> |
37 | 39 | #include "../Scheduler/OneShotTimer.h" |
| 40 | +#include "Workload.h" |
38 | 41 |
|
39 | 42 | #include "SessionManager.h" |
40 | 43 |
|
@@ -109,6 +112,26 @@ class PowerAdvisor { |
109 | 112 | // Get the session manager, if it exists |
110 | 113 | virtual std::shared_ptr<SessionManager> getSessionManager() = 0; |
111 | 114 |
|
| 115 | + // --- Track per frame workloads to use for load up hint heuristics |
| 116 | + // Track queued workload from transactions as they are queued from the binder thread. |
| 117 | + // The workload is accumulated and reset on frame commit. The queued workload may be |
| 118 | + // relevant for the next frame so can be used as an early load up hint. Note this is |
| 119 | + // only a hint because the transaction can remain in the queue and not be applied on |
| 120 | + // the next frame. |
| 121 | + virtual void setQueuedWorkload(ftl::Flags<Workload> workload) = 0; |
| 122 | + // Track additional workload dur to a screenshot request for load up hint heuristics. This |
| 123 | + // would indicate an immediate increase in GPU workload. |
| 124 | + virtual void setScreenshotWorkload() = 0; |
| 125 | + // Track committed workload from transactions that are applied on the main thread. |
| 126 | + // This workload is determined from the applied transactions. This can provide a high |
| 127 | + // confidence that the CPU and or GPU workload will increase immediately. |
| 128 | + virtual void setCommittedWorkload(ftl::Flags<Workload> workload) = 0; |
| 129 | + // Update committed workload with the actual workload from post composition. This is |
| 130 | + // used to update the baseline workload so we can detect increases in workloads on the |
| 131 | + // next commit. We use composite instead of commit to update the baseline to account |
| 132 | + // for optimizations like caching which may reduce the workload. |
| 133 | + virtual void setCompositedWorkload(ftl::Flags<Workload> workload) = 0; |
| 134 | + |
112 | 135 | // --- The following methods may run on threads besides SF main --- |
113 | 136 | // Send a hint about an upcoming increase in the CPU workload |
114 | 137 | virtual void notifyCpuLoadUp() = 0; |
@@ -158,6 +181,11 @@ class PowerAdvisor final : public adpf::PowerAdvisor { |
158 | 181 | void setTotalFrameTargetWorkDuration(Duration targetDuration) override; |
159 | 182 | std::shared_ptr<SessionManager> getSessionManager() override; |
160 | 183 |
|
| 184 | + void setQueuedWorkload(ftl::Flags<Workload> workload) override; |
| 185 | + void setScreenshotWorkload() override; |
| 186 | + void setCommittedWorkload(ftl::Flags<Workload> workload) override; |
| 187 | + void setCompositedWorkload(ftl::Flags<Workload> workload) override; |
| 188 | + |
161 | 189 | // --- The following methods may run on threads besides SF main --- |
162 | 190 | void notifyCpuLoadUp() override; |
163 | 191 | void notifyDisplayUpdateImminentAndCpuReset() override; |
@@ -332,6 +360,11 @@ class PowerAdvisor final : public adpf::PowerAdvisor { |
332 | 360 | static constexpr const Duration kFenceWaitStartDelayValidated{150us}; |
333 | 361 | static constexpr const Duration kFenceWaitStartDelaySkippedValidate{250us}; |
334 | 362 |
|
| 363 | + // Track queued and committed workloads per frame. Queued workload is atomic because it's |
| 364 | + // updated on both binder and the main thread. |
| 365 | + std::atomic<uint32_t> mQueuedWorkload; |
| 366 | + ftl::Flags<Workload> mCommittedWorkload; |
| 367 | + |
335 | 368 | void sendHintSessionHint(aidl::android::hardware::power::SessionHint hint); |
336 | 369 |
|
337 | 370 | template <aidl::android::hardware::power::ChannelMessage::ChannelMessageContents::Tag T, |
|
0 commit comments