|
19 | 19 | * |
20 | 20 | * APerformanceHint allows apps to create performance hint sessions for groups |
21 | 21 | * of threads, and provide hints to the system about the workload of those threads, |
22 | | - * to help the system more accurately allocate power for them. It is the NDK |
| 22 | + * to help the system more accurately allocate resources for them. It is the NDK |
23 | 23 | * counterpart to the Java PerformanceHintManager SDK API. |
24 | 24 | * |
| 25 | + * This API is intended for periodic workloads, such as frame production. Clients are |
| 26 | + * expected to create an instance of APerformanceHintManager, create a session with |
| 27 | + * that, and then set a target duration for the session. Then, they can report the actual |
| 28 | + * work duration at the end of each cycle to inform the framework about how long those |
| 29 | + * workloads are taking. The framework will then compare the actual durations to the target |
| 30 | + * duration and attempt to help the client reach a steady state under the target. |
| 31 | + * |
| 32 | + * Unlike reportActualWorkDuration, the "notify..." hints are intended to be sent in |
| 33 | + * advance of large changes in the workload, to prevent them from going over the target |
| 34 | + * when there is a sudden, unforseen change. Their effects are intended to last for only |
| 35 | + * one cycle, after which reportActualWorkDuration will have a chance to catch up. |
| 36 | + * These hints should be used judiciously, only in cases where the workload is changing |
| 37 | + * substantially. To enforce that, they are tracked using a per-app rate limiter to avoid |
| 38 | + * excessive hinting and encourage clients to be mindful about when to send them. |
25 | 39 | * @{ |
26 | 40 | */ |
27 | 41 |
|
@@ -249,6 +263,54 @@ int APerformanceHint_reportActualWorkDuration2( |
249 | 263 | APerformanceHintSession* _Nonnull session, |
250 | 264 | AWorkDuration* _Nonnull workDuration) __INTRODUCED_IN(__ANDROID_API_V__); |
251 | 265 |
|
| 266 | +/** |
| 267 | + * Informs the framework of an upcoming increase in the workload of a graphics pipeline |
| 268 | + * bound to this session. The user can specify whether the increase is expected to be |
| 269 | + * on the CPU, GPU, or both. |
| 270 | + * |
| 271 | + * Sending hints for both CPU and GPU counts as two separate hints for the purposes of the |
| 272 | + * rate limiter. |
| 273 | + * |
| 274 | + * @param cpu Indicates if the workload increase is expected to affect the CPU. |
| 275 | + * @param gpu Indicates if the workload increase is expected to affect the GPU. |
| 276 | + * @param debugName A required string used to identify this specific hint during |
| 277 | + * tracing. This debug string will only be held for the duration of the |
| 278 | + * method, and can be safely discarded after. |
| 279 | + * |
| 280 | + * @return 0 on success. |
| 281 | + * EINVAL if no hints were requested. |
| 282 | + * EBUSY if the hint was rate limited. |
| 283 | + * EPIPE if communication with the system service has failed. |
| 284 | + * ENOTSUP if the hint is not supported. |
| 285 | + */ |
| 286 | +int APerformanceHint_notifyWorkloadIncrease( |
| 287 | + APerformanceHintSession* _Nonnull session, |
| 288 | + bool cpu, bool gpu, const char* _Nonnull debugName) __INTRODUCED_IN(36); |
| 289 | + |
| 290 | +/** |
| 291 | + * Informs the framework of an upcoming reset in the workload of a graphics pipeline |
| 292 | + * bound to this session, or the imminent start of a new workload. The user can specify |
| 293 | + * whether the reset is expected to affect the CPU, GPU, or both. |
| 294 | + * |
| 295 | + * Sending hints for both CPU and GPU counts as two separate hints for the purposes of the |
| 296 | + * this load tracking. |
| 297 | + * |
| 298 | + * @param cpu Indicates if the workload reset is expected to affect the CPU. |
| 299 | + * @param gpu Indicates if the workload reset is expected to affect the GPU. |
| 300 | + * @param debugName A required string used to identify this specific hint during |
| 301 | + * tracing. This debug string will only be held for the duration of the |
| 302 | + * method, and can be safely discarded after. |
| 303 | + * |
| 304 | + * @return 0 on success. |
| 305 | + * EINVAL if no hints were requested. |
| 306 | + * EBUSY if the hint was rate limited. |
| 307 | + * EPIPE if communication with the system service has failed. |
| 308 | + * ENOTSUP if the hint is not supported. |
| 309 | + */ |
| 310 | +int APerformanceHint_notifyWorkloadReset( |
| 311 | + APerformanceHintSession* _Nonnull session, |
| 312 | + bool cpu, bool gpu, const char* _Nonnull debugName) __INTRODUCED_IN(36); |
| 313 | + |
252 | 314 | /** |
253 | 315 | * Creates a new AWorkDuration. When the client finishes using {@link AWorkDuration}, it should |
254 | 316 | * call {@link AWorkDuration_release()} to destroy {@link AWorkDuration} and release all resources |
|
0 commit comments