Adaptive Performance in Call of Duty Mobile



Introduction


Temperature control and the balance between performance and power management is always a complicated task in Mobile game development. In this article, we are going to show how to make the ideal solution for power management and performance optimization by using Unity’s “Adaptive Performance”. What’s more, we will show how Adaptive Performance works on real in-market game, Call of Duty Mobile, a First-Person shooter which aims to match the full quality of the famous PC original.


Before this project, Unity had already released the 1st preview version of Adaptive Performance through the collaboration with Samsung. Based on this, we started a technical collaboration with the Call of Duty Mobile team, Timi Studio J3 from Tencent, in which we aimed to make their game have minimal power consumption with a highly stable frame rate. Of course, this kind of technical collaboration will help to bring Adaptive Performance more and more games as developers see the clear benefits.


We will discuss what developers can achieve by using Adaptive Performance and how to use it to develop your own optimization solution for your game learning from the example in Call Of Duty Mobile.



First Steps


Baseline Performance Analysis


The first step with any new project is to get an idea of where we currently are. The final target is to provide a predictable frame rate and a decrease in thermal buildup, enabling longer play times and a much more enjoyable player experience while at the same time preserving battery life.

Initially, Call of Duty Mobile was using the Android default solution to manage the thermal throttling situation on Samsung devices. So as a first step, we integrated the default Adaptive Performance package from Unity which only contained a simple solution that can adjust CPU/GPU frequency. As we can see below, Adaptive Performance immediately provided a slower temperature increase and better FPS stability while maintaining the target of 60 FPS. However, there is always room for improvement and with our goal of pushing the limits even further, boosting overall performance with limited temperature, work would begin in earnest!


Initial Project Investigation


Along with establishing performance, there were some other areas that required investigating.

Let’s see some screen captures from this game:



We can see Call of Duty Mobile has PC-like rendering quality, the game is using PBR material with high resolution textures, this will create a heavy work load on both the CPU and GPU. So it seemed likely that adjusting only CPU/GPU frequency automatically would not be enough to avoid Thermal Throttling and consequential performance degradation. We discussed with the Call of Duty team the idea of making multiple types of scalable quality factors, and of course these were confirmed with the Art designer and Project Staff of the game to make sure the adjustments of these factors did not impact the game experience. The scalable factors for Call of Duty were:


  • Shadow Distance : The shadows in the game usually demand complex calculations. The game needs to take into account many variables to calculate the shadow such as the sources of light, the object creating the shadow, and the object upon which the shadow is cast. The whole process requires a lot of processing power.

  • Foliage LOD : An effective method to reduce the on-screen polygon count by replacing the high quality model with a lower level (lower polygon count) mesh when it reaches a specific distance from the camera. In Call of Duty Mobile, we mainly adjust the LOD of foliage rendering.

  • Animation Rate : The calculation of Bone animations usually needs to manage huge amounts of bone data and frequently update matrices. But realistically we don't always need to update the full animation every frame, reducing the update rate can effectively reduce the CPU and GPU calculation costs.

  • Target Frame rate : Higher frame rates always cost more power and result in higher temperature for the device (especially if the game is running at high refresh rates). In Call of Duty Mobile, we lowered the target frame rate when the temperature rose quickly, thereby we could restrict the peak temperature and have more stable performance with limited CPU/GPU frequency at the same time.



Optimization solution Implementation


Adaptive Performance Basics

Adaptive Performance is built on top of Samsung’s GameSDK which can provide you with feedback about the thermal state of mobile devices. Developers can subscribe to events or query the information from the Adaptive Performance API during runtime to react in real-time.

Thermal Throttling

Left to its-self the mobile device will trigger an immediate reaction to deal with high surface temperature by throttling chip frequencies, which naturally will cause the performance to drop.



  • Access current thermal warning level Listening API 'onHighTempWarnig()', you can detect the thermal throttling timing through warning levels.


  • Get detailed temperature level This provides some APIs such as 'getTempLevel(), getCPU/GPUJTLevel(), getSkinTempLevel()'. Applications can then use these functions' feedback values to make modifications and avoid getting throttled. Each temperature lies in the range 0~7.



Power Management


The CPU and GPU of a mobile device make up for a very large part of the power utilization of a mobile device, especially when running a game.

CPU and GPU cores are actually less efficient when run at their maximum clock speeds. The API ‘setLevelWithScene(String scene, int cpuLevel, int gpuLevel)’ limits the maximum allowed clock speeds which can avoid situations where the operating system throttles the frequency of the CPU and GPU to cool down the device.



Applications can determine cpuLevel and gpuLevel which range from 0 ~ 3 based on the thermal feedback provided by the Adaptive Performance API and can use some special knowledge of the application like:

  • Is the application in an in-game scene or in a menu?
  • Is the game achieving the target frame rate?


Bottleneck Identify


Developers can subscribe to receive performance bottleneck events that let the application know if you are in GPU, CPU or “frame-rate bound”. In the case of being “frame-rate bound”, an application should consider lowering its performance requirements.


Depending on the game and scenario, Developer can react differently when the game is CPU or GPU bound according to the thermal state changes.



Optimization Solution as implemented in Call of Duty Mobile


Quality Scale Factors


The Scaling Factor did not greatly impact the CPU / GPU power consumption, but can obviously reduce the thermal problems by adjusting power use before Thermal Throttling occurs, the game can get the device statuses by using Adaptive Performance, and reduce rendering details to control the heat.

Here are the detail rendering factors for Call of Duty Mobile, and of course, the adjustment will not impact the game experience:


Feature Parameter Scaling Impact
Shadow Distance 80 ~ 50 CPU 0 ~ 10% offloading
Foliage LOD 1 ~ 0.8 GPU 0 ~ 5% offloading
Target Frame Rate 60 ~ 57 CPU 0 ~ 5% offloading
GPU 0~5% offloading

Animation LOD 0 ~ 2 CPU 0 ~ 5% offloading
GPU 0~5% offloading


Shadow Distance (80 ~ 50)


Foliage LOD (1.0 ~ 0.8)


Dynamically changing quality scale factors features were encapsulated into funtions “LowerCoDFeatures()”and “RaiseCoDFeatures()”in which we set prefered scale factors’ value:


DynamicChange.SetFoliageLOD(m_FoliageLOD);
DynamicChange.ChangeShadowQuality(m_ShadowDistance);
DynamicChange.ChangeAnimLOD(m_AnimateIndex, m_AnimateHeight, m_AnimateUpdateRate);
DynamicChange.SetFrameRate(m_TargetFrameRate);



Auto Perf Control


In every game frame, we performed bottleneck detection and analyzed the temp trend to decide how to update CPU/GPU level.


  • Bottleneck Detection Whether an application is “frame-rate bound” depends on the delta between target frame time and actual frame time, whether the application is CPU bound or GPU bound can be decided by the gpu frame time and cpu frame time.

According to the temerature of the game, from low to high, We divided the game into three stages “Normal”, “NearThrottling”and “CloseThrottling”.The algorithem of each is totally different:
  • Normal : We kept target frame rate and checked the performance boottleneck, In case of “GPU bound”, we raised GPU level and called “LowerCoDFeatures()”. In case of “CPU bound”, We raised CPU level and also called “LowerCoDFeatures()”.If “frame rate bound”happened, we made sure that the target frame rate can be maintained for a perid of time before reducing CPU or GPU level.

  • NearThrottling : We checked the temerature trend, If it was still increasing we deceased CPU and GPU level and called “LowerCoDFeatures()”. Or else, we increased CPU and GPU level and invoked “RaiseCoDFeatures()”.

  • CloseThrottling : We firstly changed frme rate then checked the temperature trend, If it was still increasing, we decreased GPU and CPU level and called “LowerCoDFeatures()”.



Performance Result


FPS



This is the FPS compare result from 3 battles of BR mode in Call Of Duty Mobile. As shown here the FPS with Adaptive Performance is much more stable and the average FPS is higher, about 7%.



Power and heat



With Adaptive Performance, the temperature is on average 2, and a maximum OF 3 degree celcius lower.
Also as shown in the Max Freq graph, in the normal case, the device works at higher CPU freq. at the beginning time, so it quickly meets Thermal Throttling and then the FPS drops and power control also shakes badly.
Using Adaptive Performance, the device can set a lower level CPU frequency and also keep the GPU frequency at a much more stable level. For this reason, Adaptive Performance’s temperature and performance are much better than the normal case.



Conclusion


As we showed above, we can make sure that there can be a clear benefit from using Adaptive Performance for real games. If a developer wants to maintain performance without allowing thermal throttling on a device and wants to provide a stable gaming experience with optimal visual quality on mobile, Adaptive Performance is by far the best solution.