- 1. Advanced Mobile Optimizations How to go to 60 fps after you
have removed all Sleep calls ;-)
2. Disclaimer
- The views expressed here are my personal views and do not
necessarily reflect the thoughts, opinions, intentions, plans or
strategies ofUnity
3. Optimization Mindset
- you can't just make your game faster
-
-
- not the same as scripting charachter
4. Optimization Mindset
5. Optimization Mindset
- You can't avoid any of that
6. Optimization Mindset
- know + think = shoot in the dark
-
- you just write code hoping for the best
- know + measure = shoot in the dark
-
- you are missing "understand" part
- think + measure = shoot in the dark
-
- you solve abstract problem, not real
7. Optimization Mindset:know + think
- hardware is more complex then you think
-
- when you write asm - high-level already
8. Optimization Mindset:know + measure
- knowledge comes from the past
9. Optimization Mindset:know + measure
- but you are missing the point
-
- parallel sorting network?
10. Optimization Mindset:think + measure
-
-
- optimizing for RIVA TNT and GTX is different
11. Optimization Mindset
- well, if you are missing two from the three
12. Know
-
- knowing data is interleaved with think
-
- we will talk more of it in "think"
13. Know your hardware
14. Know your hardware: GPU
-
- meaning - slow step = slow everything
-
- you are as slow as your bottleneck
- Won't go into full pipeline spec
- Just common/biggest problems
15. Know your hardware:GPU Geometry
-
- should use indexed geometry or not
16. Know your hardware:GPU Textures
17. Know your hardware:GPU Shaders
- VertexProgram vs FragmentShader
-
- CG: float/half/fixed (iirc)
18. Know your hardware:GPU Rasterization
19. Know your hardware: CPU
-
- for stupid code far worse than CISC
20. Know your hardware:CPU Memory
- This is single most important factor
-
- memory access far slower then computation
21. Know your hardware:CPU Computations
-
- better arithmetic usage (4 vals instead of 1)
22. Know your target hardware
- But you are running on that particular piece of sh...
hardware
23. Know your target hardware: PowerVR
-
- perfect hidden surface removal
- Tegra / ATI-AMD / Adreno more common
24. Know your target hardware: ARM
- VFP = FPU on steroids (not real SIMD)
-
- scalar instructions at same speed as vectorized
-
- awesome load/store instructions
-
- not as cool as Altivec but cool enough for mobiles
25. Know your target hardware: ARM
- Conditional execution of most instructions
- Fold shifts and rotates into the "data processing"
instructions
-
- load structure from array by index
-
- switch back and forth between Thumb mode and regular 32-bit
mode
26. Know your hardware: Resources
-
- powerVR (imgtech) tegra (nvidia) adreno (qualcomm)
-
- AMD/ATI - basically the same as X360, but much smaller
tiles
27. Think
- Think about your algorithms
- Think about your constraints
- Think about your hardware
28. Think Basics
29. Think Memory
30. Think Constraints
- GPU: will you see the difference?
-
- on that one small thingy in the corner?
-
- e.g. physics in casual game?
- Memory: will you need that?
-
- will you need more then XXX actors?
31. Measure
- you didn't optimize anything if you didn't measure
difference
- you can't optimize if you don't know what needs to be
optimized
-
- if you can't measure what takes time
32. Measure Tools
-
- adreno profiler (qualcomm)
33. Unity use case: random bits
-
- specialized of usual built-ins
-
-
- usually 10-15% of c-code time
-
-
-
- and we are not done optimizing it ;-)
- Rej's baking material to texture and coming soon BRDF baking to
texture
34. Unity use case: random bits
-
- run on target hw, data is transferred over wifi
-
- collect in Editor and show pretty graphs ;-)
- Sort alpha-test *after* opaque
- check *lots* of extensions
- Vertex Cache optimization - after LODs ;-)
35. Closing Words
- You should be always optimizing
36. Questions