Successfully reported this slideshow.
Upcoming SlideShare
×

# Mobile Performance Tuning: Poor Man's Tips And Tricks

5,511 views

Published on

Unity iOS performance optimizations by Mantas Puida, Unity Technologies.

Published in: Technology
• Full Name
Comment goes here.

Are you sure you want to Yes No

### Mobile Performance Tuning: Poor Man's Tips And Tricks

1. 1. Mobile performance tuning:   poor man’s tips and tricks Mantas Puida / Unity iOS
2. 2. Maybe it is too pretty? :)
3. 3. Why this happens? •Many people perceive <20 fps as bad performance •60 fps = 16.7 ms / frame,   30 fps = 33.3 ms / frame,   20 fps = 50.0 ms / frame •Rendering at some point is synced with LCD •CPU is working too long •or… GPU is working too long
4. 4. Two most common problems: exhausted ﬁll rate or too much geometry
5. 5. Or too much moving geometry, but let’s talk about bit later
6. 6. Poor man’s explanation of the things •Fill rate - how many pixels you can draw per second* •Triangle throughput - how many triangles you can process per second* *- in reality things are bit more complicated
7. 7. Some school* grade math: iPhone 5s •Fill rate: 3304 Mtex/s, Triangle t.: 68Mtri/s •Screen resolution: 1136x640 •Can ﬁll screen X times running @ 60 fps: X = 3304000000 / (60*1136*640) = 75.7 (lots of overdraw) •Can handle Y static triangles running @ 60 fps: Y = 68000000/60 = 1.1 Mtris *- most of my students fail this test
8. 8. Some school grade math: iPhone 4* •Fill rate: 400 Mtex/s, Triangle t.: 14Mtri/s •Screen resolution: 960x640 •Can ﬁll screen X times running @ 60 fps: X = 400000000 / (60*960*640) = 10.8 (not good) •Can handle Y static triangles running @ 60 fps: Y = 14000000/60 = 0.2 Mtris *- don’t trust much numbers you ﬁnd on internet
9. 9. How should I know if I’m GPU bound?  Xcode 5 + iOS 7 (Debug Navigator)!
10. 10. Practical measurement •iPhone 5s - up 55 layers of full screen transp. (75 theoretical) still allow 60 fps / 31 layer with Diffuse shader •iPhone 4 - only 8 layers of full screen transp. (10 theoretical) still allow 60 fps / 1.6 layer with Diffuse shader Advice #1: always measure what are device limits with your own setup of things. Start with lowest spec device ﬁrst. Advice #2: use simple and effective shaders when possible
11. 11. Transparentfullscreenlayers 0 12.5 25 37.5 50 iPhone 4 iPhone 5 iPhone 5S iPad M ini1 iPad 3 iPad Air 30 10.8 21.6 50 44 9.48
12. 12. Switching from transparent to opaque •iPhone 5s - up to 320 layers of full screen opaque still allow 60 fps •iPhone 4 - 41 layer of full screen opaque still allow 60 fps Advice #3: use opaque (non-transparent) shaders when possible
13. 13. Opaquefullscreenlayers 0 100 200 300 400 iPhone 4 iPhone 5 iPhone 5S iPad M ini1 iPad 3 iPad Air 7569 172 317 278 41.4
14. 14. Dynamic content •2D sprites: makes quite some pressure on GLES driver, which means higher CPU usage. Also could result in high overdraw, which also makes pressure on GPU too. •3D animations: makes quite some pressure on CPU, maybe less pressure on GPU (unless expensive shaders)
15. 15. Dynamic 2D content •iPhone 5S - 578 sprites, iPhone 4 - 113 sprites (square mesh 36 spr. / GPU bound) and still maintaining 60 fps.
16. 16. 2DSprites 0 150 300 450 600 iPhone 4 iPhone 5 iPhone 5S iPad M ini1 iPad 3 iPad Air 372 284298 578 439 113
17. 17. iPhone 4: tight 2D mesh vs full rect
18. 18. Tons of objects = bad •Lots of separate objects makes great pressure on GLES driver. •Dynamic and static batching to the rescue! (Player Settings tab in Unity) Advice #4: few bigger objects is better than lots of small objects
19. 19. Dynamic 3D content •iPhone 5S - 309 low poly (384 pol.) CPU skinned meshes / 160 low poly GPU skinned meshes,     iPhone 4 - 55 low poly CPU skinned meshes and still maintaining 60 fps.     CPU skinning bounded by CPU performance, GPU skinning (GLES 3.0 only) bounded by GPU perf.
20. 20. Disabling tangents •iPhone 5S - 318 characters with CPU skinning / 202 characters with GPU skinning, •iPhone 4 - still 55 characters (draw call bound). Advice #5: Keep amount of dynamic geometry (and skinned data) low.
21. 21. Lowpolyanimatedcharacters 0 100 200 300 400 iPhone 4 iPhone 5 iPhone 5S iPad M ini1 iPad 3 iPad Air 303 118123 318 200 55
22. 22. Switching to big objects •iPhone 5S - 122 characters (5K polies) with CPU skinning / 26 characters with GPU skinning, •iPhone 4 - 18 characters.
23. 23. Mediumsize(5Kpol.)animatedcharacters 0 35 70 105 140 iPhone 4 iPhone 5 iPhone 5S iPad M ini1 iPad 3 iPad Air 119 3840 122 70 18.9
24. 24. Dynamic 3D content •iPhone 5S - handles 90-400K moving polygons @ 60 fps (having less, but more detailed characters allows higher throughput)      •iPhone 4 - handles 20-90 K moving polygons @ 60 fps.
25. 25. Animatedpolygoncount(KTris) 0 150 300 450 600 iPhone 4 iPhone 5 iPhone 5S iPad M ini1 iPad 3 iPad Air 584 186198 596 343 92
26. 26. Practical measurement: static content •iPhone 5S - easily handles ~1.1 M static polygons @ 60 fps   •iPhone 4 - handles ~270 K static polygons @ 60 fps. •Good match with other synthetic tests
27. 27. Staticpolygoncount(KTris) 0 300 600 900 1200 iPhone 4 iPhone 5 iPhone 5S iPad M ini1 iPad 3 iPad Air 845 657 597 1 1161 113 276
28. 28. Summary •Don't trust numbers on the internet, proﬁle in your environment. Small details matter. •Proﬁle worst and best devices. Estimate budgets for transparent and dynamic geometry. •Use Xcode to ﬁgure out if you are CPU or GPU bound. •Large portions of screen covering transparent objects (or with expensive shaders) make you GPU bound. •Lots of objects, dynamic geometry makes you CPU bound.
29. 29. •Use tight meshes for transparent 2D stuff. •Use non-transparent shaders when possible. •Minimize amount of skinnable data (drop tangents when not needed). •Lowering target framerate to 30-20 fps increases budgets 2x-3x. •Need tons of small characters? 2D is less challenging (but you should care about details)
30. 30. Resources from Unity Asset Store •Unity Chan •Low Poly Micro Monster Pack •Primitives •2d CHARACTERS sprite package