AdaptivePerformanceStableFrameModeProvider
Mode provider that prioritizes consistent frame time over the highest achievable frame rate.
Read time 2 minutesLast updated 8 days ago
Definition
- Type: Class
- Namespace: UnityEngine.AdaptivePerformance
- Assembly: UnityEngine.AdaptivePerformanceModule
- Implements: IAdaptivePerformanceModeProvider
public class AdaptivePerformanceStableFrameModeProvider : IAdaptivePerformanceModeProvider
Remarks
On mode start the provider reads the AdaptiveFramerate scaler's bounds and pins Time.maximumDeltaTime to — a physics-stability clamp so a hitch can never stretch a single physics step past the budget.
1 / MinBoundThe provider then forces vsync off (QualitySettings.vSyncCount to 0) and takes ownership of framerate: vsync's snap-to-refresh-divisor behavior turns a missed deadline into a large frame-time spike, exactly the variance this mode fights. It force-enables the AdaptiveFramerate scaler, starts Application.targetFrameRate at MaxBound, and lets the scaler participate in the indexer's cost-based adjustment so the framerate seeks the highest stably-reachable rate (MinBound is the floor). The original vsync count, framerate, and maximum delta time are all restored on mode end.
Each frame it produces a performance action and adopts whichever signal asks for the most aggressive change. A headroom guard runs on every frame regardless of vsync: it asks for a decrease when CPU/GPU work climbs toward the presented frame interval, which is one load bump from a dropped frame. Alongside it a variance signal runs, whose source depends on whether presentation is vsync-locked. When it is (mobile always is — its compositor paces frames at the hardware level regardless of QualitySettings.vSyncCount), wall-clock frame time quantizes to the display cadence and its variance goes blind until a frame drops, so the provider measures variance on CPU/GPU work time. When it isn't, wall-clock frame time is authoritative and its variance is measured directly. Both paths also honor the MinBound floor via AdaptivePerformanceStableFrameModeProvider.TargetFrameTimeVarianceMs's companion lower-bound check.
Properties
Property | Description |
|---|---|
| CpuUtilizationAction | The action the mode applies in response to the device's CPU utilization data. Always StateAction.Stale because this mode drives scalers from frame-time variance rather than CPU utilization. |
| GpuUtilizationAction | The action the mode applies in response to the device's GPU utilization data. Always StateAction.Stale because this mode drives scalers from frame-time variance rather than GPU utilization. |
| Indexer | The Indexer that this mode adjusts scalers through. |
| ModeName | The name of the operation mode. |
| PerformanceAction | The action the mode applies in response to the device's performance state. |
| Settings | The active Adaptive Performance settings. |
| TargetFrameTimeVarianceMs | Maximum tolerated variance in the mode's frame-cost signal, in ms². |
| ThermalAction | The action the mode applies in response to the device's thermal state. |
Methods
Method | Description |
|---|---|
| ApplyModeActions | Applies stable frame mode's variance, lower-bound, and headroom actions to the active scalers. Adaptive Performance calls this method every frame while stable frame mode is active. |
| OnOperationModeEnd | Called when stable frame mode is replaced by another operation mode. Resets the variance window and restores the framerate bounds it applied. |
| OnOperationModeStart | Called when stable frame mode becomes the active operation mode. Resets the variance window and applies the framerate bounds read from the AdaptiveFramerate scaler. |