GPU bound or CPU bound?

I developed my game in android with my Samsung Epic 4G and the game runs great with no perforamance issues. Now I’m porting it to iOS and it barely runs at all on my 32GB 4th gen ipod touch running 4.3.2.

I’m using a unity terrain and thought that might be it, so I turned off the terrain and it’s still completely jacked. I’m running the game with the internal profiler enabled and here is the relevant output.

Does this look like a graphics problem or a CPU problem?

thanks in advance!


iPhone Unity internal profiler stats:
cpu-player> min: 9.2 max: 18.9 avg: 11.3
cpu-ogles-drv> min: 3.0 max: 10.0 avg: 3.5
cpu-waits-gpu> min: 95.0 max: 161.3 avg: 120.1
msaa-resolve> min: 0.0 max: 0.0 avg: 0.0
frametime> min: 116.2 max: 183.9 avg: 138.3
draw-call #> min: 38 max: 38 avg: 38 | batched: 2
tris #> min: 6022 max: 6084 avg: 6064 | batched: 14
verts #> min: 5209 max: 5333 avg: 5294 | batched: 28
player-detail> physx: 1.6 animation: 0.0 culling 0.0 skinning: 0.7 batching: 0.0 render: -114.2 fixed-update-count: 6 … 9
mono-scripts> update: 1.1 fixedUpdate: 0.1 coroutines: 0.0
mono-memory> used heap: 438272 allocated heap: 643072 max number of collections: 0 collection total duration: 0.0

iPhone Unity internal profiler stats:
cpu-player> min: 8.4 max: 12.5 avg: 10.1
cpu-ogles-drv> min: 3.0 max: 6.1 avg: 3.5
cpu-waits-gpu> min: 97.2 max: 119.0 avg: 108.0
msaa-resolve> min: 0.0 max: 0.0 avg: 0.0
frametime> min: 113.0 max: 136.6 avg: 124.4
draw-call #> min: 38 max: 38 avg: 38 | batched: 2
tris #> min: 5878 max: 6014 avg: 5949 | batched: 14
verts #> min: 4921 max: 5193 avg: 5063 | batched: 28
player-detail> physx: 1.4 animation: 0.0 culling 0.0 skinning: 0.7 batching: 0.0 render: -102.2 fixed-update-count: 5 … 7
mono-scripts> update: 0.9 fixedUpdate: 0.1 coroutines: 0.0
mono-memory> used heap: 475136 allocated heap: 643072 max number of collections: 0 collection total duration: 0.0

iPhone Unity internal profiler stats:
cpu-player> min: 8.2 max: 12.2 avg: 9.4
cpu-ogles-drv> min: 2.8 max: 6.1 avg: 3.2
cpu-waits-gpu> min: 97.8 max: 119.7 avg: 108.9
msaa-resolve> min: 0.0 max: 0.0 avg: 0.0
frametime> min: 116.2 max: 133.9 avg: 124.4
draw-call #> min: 37 max: 38 avg: 37 | batched: 2
tris #> min: 5852 max: 5878 avg: 5855 | batched: 14
verts #> min: 4869 max: 4921 avg: 4875 | batched: 28
player-detail> physx: 1.4 animation: 0.0 culling 0.0 skinning: 0.7 batching: 0.0 render: -103.7 fixed-update-count: 5 … 7
mono-scripts> update: 0.9 fixedUpdate: 0.1 coroutines: 0.0
mono-memory> used heap: 524288 allocated heap: 643072 max number of collections: 0 collection total duration: 0.0

iPhone Unity internal profiler stats:
cpu-player> min: 8.4 max: 15.8 avg: 10.1
cpu-ogles-drv> min: 2.9 max: 5.3 avg: 3.2
cpu-waits-gpu> min: 95.0 max: 119.5 avg: 107.6
msaa-resolve> min: 0.0 max: 0.0 avg: 0.0
frametime> min: 113.4 max: 136.5 avg: 123.9
draw-call #> min: 37 max: 38 avg: 37 | batched: 2
tris #> min: 5852 max: 5898 avg: 5859 | batched: 14
verts #> min: 4869 max: 4961 avg: 4883 | batched: 28
player-detail> physx: 1.3 animation: 0.0 culling 0.0 skinning: 0.9 batching: 0.0 render: -101.7 fixed-update-count: 5 … 7
mono-scripts> update: 0.9 fixedUpdate: 0.1 coroutines: 0.0
mono-memory> used heap: 409600 allocated heap: 643072 max number of collections: 1 collection total duration: 3.3

iPhone Unity internal profiler stats:
cpu-player> min: 8.8 max: 16.3 avg: 10.5
cpu-ogles-drv> min: 3.0 max: 8.7 avg: 3.6
cpu-waits-gpu> min: 93.6 max: 118.3 avg: 107.6
msaa-resolve> min: 0.0 max: 0.0 avg: 0.0
frametime> min: 114.5 max: 135.5 avg: 125.1
draw-call #> min: 38 max: 38 avg: 38 | batched: 2
tris #> min: 5902 max: 6042 avg: 5974 | batched: 14
verts #> min: 4969 max: 5249 avg: 5113 | batched: 28
player-detail> physx: 2.1 animation: 0.0 culling 0.0 skinning: 0.7 batching: 0.0 render: -102.1 fixed-update-count: 5 … 7
mono-scripts> update: 0.8 fixedUpdate: 0.1 coroutines: 0.0
mono-memory> used heap: 442368 allocated heap: 643072 max number of collections: 0 collection total duration: 0.0

iPhone Unity internal profiler stats:
cpu-player> min: 9.1 max: 16.8 avg: 11.8
cpu-ogles-drv> min: 3.1 max: 10.3 avg: 3.9
cpu-waits-gpu> min: 93.8 max: 133.9 avg: 110.1
msaa-resolve> min: 0.0 max: 0.0 avg: 0.0
frametime> min: 111.6 max: 150.2 avg: 128.8
draw-call #> min: 38 max: 38 avg: 38 | batched: 2
tris #> min: 6044 max: 6088 avg: 6072 | batched: 14
verts #> min: 5253 max: 5341 avg: 5309 | batched: 28
player-detail> physx: 1.3 animation: 0.0 culling 0.0 skinning: 1.1 batching: 0.0 render: -104.0 fixed-update-count: 6 … 7
mono-scripts> update: 1.1 fixedUpdate: 0.1 coroutines: 0.0
mono-memory> used heap: 491520 allocated heap: 643072 max number of collections: 0 collection total duration: 0.0

looks like a gpu issue.

with a render time already hitting negative, yeah I would suspect it on the render end too :slight_smile: must be something pretty hefty like post fx / heave alpha surface usage as the geometry etc does not imply that you are overdoing it there. a 2d game where you by error used pure alpha materials or at worst alpha test ones could cause such heavy hits especially when on HD resolutions on 4th gen /ipad1

Something like ipad2 can eat the fillrate hit, but when you go for an iphone 4/ipad1 you’re asking for it to stall since those two devices are apple’s dirty secret in the development world, and simply don’t have the fillrate to perform well.

thats why I assume its the fillrate, also due to the hardware he mentions where it works vs where it doesn’t

Thank you both for your posts.

I think I may have just found the problem. I’m doing a bunch on calculations for my Radar HUD in the scope of OnGUI, if I remember correclty this is a big no no. I’m reworking it now, hopefully that takes care of the problem.

hehe yeah generally using ongui itself is worse enough but doing calcs in there especially when not even encapsulated is ‘suicide’.

but that should not kill you on rendering, ongui is cpu heavy …

I reworked it so only the gui calls are performed in onGUI and the calcs are done in Update. That helped slightly but its still unplayable.

My render stats show a max of the following:

Draw calls: 70
Tris: 15k
Verts: 14k
Batched Draw calls: 2 - 8
Used Textures: 29 - 8.5 MB
Render Textures: 0 - 0B switches: 0
VRAM usage 5.9 MB to 16.7 MB (of 256 MB)
VBO Total 250 - 2.3 MB
Shadow Casters: 0
Visible Skinned Meshes: 0
Animations: 0

Any objects that share materials are batched, but thats not many. Most objects are textured differently, and I haven’t gone the extra mile of sharing a single texture for mutiple materials.

I also have not implemented occlusion culling, I’m wondering if that will solve these problems.

Any suggestions you can give me? I have spent quite a bit of time following the Unity documentation on iOS optimization and will continue to do so, just hoping someone out there can save me some time.

Thanks again!

the statistics imply that you kill it with overdraw so you will need to reduce the overdraw, significantly.

don’t use transparent materials where its not needed, remove any fullscreen effect and alike (and if you do large draw operations in ongui that cover large parts of the screen get rid of them, they have the same fillrate impact)

  • there may be a few materials I can change to opaque diffuse
  • I’m only using OnGUI for the radar control, other than that I don’t use it at all
  • I’ve turned off the flare and gui layers on both of my cameras (I have two cameras, the fps camera with a far clip of 40 and a HUD camera with a far clip of 10, the hud camera only renders objects marked with a specific layer, and the fps camera renders all layers except the hud obejcts)

Come to think of it, I will try dropping the far clip on the HUD camera even more, that should help a bit.

Thanks again!!

I had several materials using the standard diffuse shader instead of mobile\diffuse. Changing those helped a bit.

Unfortunately the fog I have enabled in Render settings is the biggest culprit. Kinda sucks because thats a big part of the atmosphere I’m trying to create for the player. Guess I better find another way.