I have created a simple scene with one terrain, one camera and one directional light. The target platform is android.
There is nothing special about them. I disabled Terrain’s cast shadow and changed its material to legacy diffuse.
And then created the corresponding shader to customize and boost performance.
Shader "Nature/Terrain/Diffuse" {
Properties {
[HideInInspector] _Control ("Control (RGBA)", 2D) = "red" { }
[HideInInspector] _Splat3 ("Layer 3 (A)", 2D) = "white" { }
[HideInInspector] _Splat2 ("Layer 2 (B)", 2D) = "white" { }
[HideInInspector] _Splat1 ("Layer 1 (G)", 2D) = "white" { }
[HideInInspector] _Splat0 ("Layer 0 (R)", 2D) = "white" { }
[HideInInspector] _MainTex ("BaseMap (RGB)", 2D) = "white" { }
[HideInInspector] _Color ("Main Color", Color) = (1,1,1,1)
}
SubShader {
Tags {
"SplatCount" = "4"
"Queue" = "Geometry-99"
"RenderType" = "Opaque"
}
LOD 300
CGPROGRAM
#pragma surface surf Lambert nolightmap noforwardadd nofog
struct Input {
half2 uv_Control : TEXCOORD0;
float2 uv_Splat0 : TEXCOORD1;
float2 uv_Splat1 : TEXCOORD2;
float2 uv_Splat2 : TEXCOORD3;
float2 uv_Splat3 : TEXCOORD4;
};
sampler2D _Control;
sampler2D _Splat0,_Splat1,_Splat2,_Splat3;
void surf (Input IN, inout SurfaceOutput o) {
fixed4 splat_control = tex2D (_Control, IN.uv_Control);
fixed3 col;
col = splat_control.r * tex2D (_Splat0, IN.uv_Splat0).rgb;
col += splat_control.g * tex2D (_Splat1, IN.uv_Splat1).rgb;
col += splat_control.b * tex2D (_Splat2, IN.uv_Splat2).rgb;
col += splat_control.a * tex2D (_Splat3, IN.uv_Splat3).rgb;
o.Albedo = col;
}
ENDCG
}
As you can see it’s basically the terrain first pass shader with minimal changes. Now when I build and run on android device THIS happens:
Also the rendering path is forward. The vsync option is disbaled. Fog is off. The mobile device is somewhat high-end with 4cores and 2GB ram and PowerVR SGX544 gpu.
So anyone can explain that?
EDIT:
After further investigation it turned out that it is caused by a gpu event. Here is the profiler at a certain period:

and at the same time PowerVR gpu profiling shows:

Consider the resemblance between the occurrence of unity profiler spikes and gray vertical lines in gpu profiling. For every gray line there is a spike in unity profiler. At higher zoom level you can see:

On the top row is renderer tasks and tasks with same color belong to the same frame. You can see that between every three frame there is a huge gap that takes like 10 to 25ms. This amount differs for each gray line. So every few frames there is a huge gap between two frames. So what is the nature of this gap? According to the gpu profiler document:
Power-off periods are represented by vertical grey blocks in the graph view. These events occur when the hardware has gone to sleep or powering down to save power due to a lack of work.
Now here is the question: Why it powers down the gpu to save power when the gpu is under such a heavy load???
