Development

Step 1: Test out the base sample app

The base sample is written with classic simple approach:

  • Check CPU / GPU bottleneck

  • Trigger when thermal status is changed

  • Adjust CPU / GPU clock level

  • Adjust quality setting by setting LOD

  • Adjust target FPS

All of these can be controlled in real-time.

Step 2: Install Adpative Performance package

Editor -> Windows -> Package Manager -> Install ‘Adaptive Performance’ Package

Step 3: How to modify C# script

Editor -> Window -> Package Manager -> Import ‘Adaptive Performance’ Package

Double click AdaptivePerformanceController.cs script file to edit.

Modify script as intended.

Step 4: How to build and launch APK

Select File > Build Settings

Check that the device is connected and check the Development Build / Scripts Only Build option.

Then, click Patch and the installed APK on your device will be updated.

Step 5: Performance measurement

To check current application performance, check the FPS and CPU / GPU load counters.

As you can see, performance is not very good. Our next step is to check current status where we will try to:

  • Check performance status to know if there is any bottleneck

  • IAdaptivePerformance.PerformanceStatus.PerformanceMetrics.PerformanceBottleneck

    • CPU: Frame rate is limited by CPU processing

    • GPU: Frame rate is limited by GPU processing

    • TargetFrameRate: Can’t reach target frame rate

      • Frame rate is limited by Application.targetFrameRate. In this case, the application should consider lowering performance requirements.

Step 6: Check thermal status

Register event handler to trigger thermal status and set handler into:

IThermalStatus.ThermalStatus.ThermalEvent

Check ThermalMetrics information in event handler:

  • WarningLevel

  • TemperatureLevel (0.0 ~ 1.0)

    Current normalized temperature level in the range of [0, 1]. A value of 0 means standard operation temperature and the device is not in a throttling state. A value of 1 means that the maximum temperature of the device is reached and the device is going into or is already in throttling state.

  • TemperatureTrend (-1.0 ~ 1.0)

    Current normalized temperature trend in the range of [-1, 1]. A value of 1 describes a rapid increase in temperature. A value of 0 describes a constant temperature. A value of -1 describes a rapid decrease in temperature. Please note that it takes at least 10s until the temperature trend may reflect any changes.

Step 7: Adjust target frame rate

Change target frame rate when thermal status is changed. For example:

Step 8: Dynamic quality scaling

Change the quality setting by adjusting LOD in real-time. For example:

Step 9: Adjust CPU/GPU clock

Change CPU / GPU clock level by IDevicePerformanceControl.

IDevicePerformanceControl

  • AutomaticPerformanceControl

    When set to true (default) CpuLevel and GpuLevel are set automatically by Adaptive Performance.

  • MaxCpuPerformanceLevel

    The maximum valid CPU performance level you use with CpuLevel. The minimum value returned is MinCpuPerformanceLevel. This value does not change after startup is complete.

  • MaxGpuPerformanceLevel

    The maximum valid GPU performance level you use with GpuLevel. The minimum value returned is MinGpuPerformanceLevel. This value does not change after startup is complete.

  • CpuLevel

    The requested CPU performance level. Higher levels typically allow CPU cores to run at higher clock speeds. The consequence is that thermal warnings and throttling may happen sooner when the device cannot sustain high clock speeds. Changes are applied once per frame. We recommended to set the CpuLevel as low as possible to save power. The valid value range is [MinCpuPerformanceLevel, MaxCpuPerformanceLevel].

  • GpuLevel

    The requested GPU performance level. Higher levels typically allow the GPU to run at higher clock speeds. The consequence is that thermal warnings and throttling may happen sooner when the device cannot sustain high clock speeds. Changes are applied once per frame. We recommended to set the GpuLevel as low as possible to save power. The valid value range is [MinGpuPerformanceLevel, MaxGpuPerformanceLevel].

Summary

Check the current status by:

  • ThermalMetrics.WarningLevel (NoWarning/ ThrottlingImminent/ Throtting)

  • PerformanceBottleneck (CPU / GPU / TargetFrameRate)

Control the performance by adjusting:

  • LOD bias

  • CPU / GPU clock level

  • Target frame rate

  • If possible, GFX load (triangles, memory, draw calls..)

Performance results

Frame Rate now displays a stable FPS with Adaptive Performance.

You're done!

Congratulations! You have successfully achieved the goal of this Code Lab activity. Now, you can improve the frame rate using Adaptive Performance by yourself! But, if you're having trouble, you may check out the link below.

Adaptive Performance Complete Code2.25 KB