Get the Most Out of Mobile
withVulkan in Unity
Roberto Lopez Mendez
DevGAMM Moscow 2017
Senior Engineer
18/05/2017
©ARM20172
Agenda
 The benefits of theVulkan graphics API
 Multi-threading
 Multipass
 Vulkan vs OpenGL ES with Sky Force Reloaded
 Mali Graphics Debugger (MGD)
 Integration in Unity
 Live demo
 Wrap up
©ARM 20173
The benefits of theVulkan graphics API
©ARM20174
Multi-threading / multicore efficiency
 Created from the ground to be thread-friendly
 Multi-threading widely considered in the specs
 Multi-threading responsibility moved to application level
 The application has better visibility
 Efficient utilization of multiprocessor architecture
 Lower CPU load and energy consumption
 Spread work out faster to multiple cores
 Able to schedule and migrate tasks between ARM ® big.LITTLETM cores according to the load
©ARM20175
Multi-pass rendering
 Everything is declared ahead of time in the render pass
 Each sub pass can specify different outputs and they can be chained together
 Very performant in tiled GPUs such as ARM Mali GPUs
 Each pixel in a sub-pass can access the result of the previous sub-pass
 All data can be contained on the fast on-chip memory, saving bandwidth
 Example of use-cases:
 Deferred rendering
 Soft-particles
 Tone-mapping
©ARM20176
Vulkan benefits in Lofoten demo
SCENE INFO
• ~ 100 lights with shadow
maps
• 3M primitives (reduced to
500K with very efficient
occlusion culling)
• 500 draw calls
• Sun light with cascade
shadow map
• ~ 10 reflection probes
• FFT compute in ocean
rendering
• Deferred shading using
multi-pass
• 10x less load on CPU
with multithreading
©ARM 20177
Sky Force Reloaded with
Vulkan and Unity
©ARM20178
What is Sky Force Reloaded?

 Modern shoot‘em experience
 Intense action, very rich graphics
 Pushing CPU and GPU to the limits
©ARM20179
©ARM201710
Performance issues in Sky Force Reloaded
 Performance issues on OpenGL ES
 Even on high-end devices it was not possible to maintain 60 FPS all of the time
 Fill rate was not the bottleneck
 Up to 1000 draw calls per frame
 CPU was spending a lot of time preparing data for GPU
©ARM201711
Performance benchmark
 Draw calls are expensive
 OpenGL ES driver is not optimal
 PerhapsVulkan can help?
 Vulkan is supported by Unity!
©ARM201712
Sky Force Reloaded:Vulkan vs OpenGL ES
Best case 21% faster
using Vulkan.
On average 15%
faster using Vulkan.
©ARM201713
Sky Force Reloaded: Increased workload
Best case 82% faster
using Vulkan.
On average 32%
faster using Vulkan.
©ARM201714
Extra power enabled byVulkan
 More content
 Add more particle, objects or animations
 Keep the same FPS with richer graphics
©ARM201715
©ARM201716
Power consumption test
 Power consumption is a problem
 Players were not happy
 Console-like quality games consume a lot of power
 Can Vulkan help?
©ARM201717
©ARM201718
Power consumption test
 Vulkan consumed 10 to 12% less power in the game
 Majority of savings come from the CPU
 Extra minutes of playtime with Vulkan!
©ARM201719
Summary
 Great to use “out of the box”
 Improves your FPS
 Adds some extra minutes of playtime
 You can add some more graphics and make your game look better
©ARM 201720
Mali Graphics Debugger (MGD)
integration in Unity
©ARM201721
Mali Graphics Debugger (MGD)
 Draw-call by Draw-call stepping
To identify draw call related issues, redundant draw calls and other opportunities to optimize
 TextureView
Visualize an application’s texture usage, to identify opportunities to compress textures or
change formats
 Shader Statistics
Understand which vertex and fragment shaders are the most expensive with cycle
count reporting
 Vertex Attribute / UniformView
See vertex data and index buffers
 StateView
Full visibility of graphics state and tracking of state changes
 Dynamic Optimization Advice
Highlighting of common API misusage and dynamic performance improvement advice
Download MGD for free at developer.arm.com
©ARM201722
Mali Graphics Debugger
Vulkan
adb install -r MGD.apk
adb install -r MGD.apk
OpenGL ES
Assets/Plugins/Android/libs/armeabi-v7a/
libVkLayerMGD32.so
©ARM 201723
Live demo: debugging Unity
application with MGD
©ARM201724
Wrap Up
APPLICATION
Single threaded/context
ARM Mali GPU
DRIVER
Context management
Memory management
Error management
GLSL compiler
CPU overhead
APPLICATION
Memory management
Thread management
Multi-threaded command
buffers
SPIR-V shader pre-
compilation
ARM Mali GPU
DRIVER
Very Light Driver
Lower overall power
consumption
VULKAN BENEFITS
• Portability across multiple platforms
• Native thread friendly
• Efficient utilization of multiprocessor
architecture
• Lower CPU load
• Reduced energy consumption
• Extra benefits for mobile platform and tiling
architectures such as ARM Mali GPUs
• Pixel access to result of previous sub-pass
• Data contained on fast on-chip memory
• Memory bandwidth saving
• Loadable validation and debug layers
Mali Graphics Debugger
©ARM201725
 AddVulkan to the list of Graphics API – save performance, battery last longer
 Upgrade to Unity 5.6 – very easy to use MGD as it is integrated into Unity
Takeaways
The trademarks featured in this presentation are registered and/or unregistered trademarks of ARM Limited (or its
subsidiaries) in the EU and/or elsewhere. All rights reserved. All other marks featured may be trademarks of their
respective owners.
Copyright © 2017 ARM Limited
Thank you
Questions
©ARM201727
 Find out more info about the topics of this talk at:
• https://www.youtube.com/watch?v=VCSkp-QZ37M
• https://www.youtube.com/watch?v=WI7nXq8oozw
• https://community.arm.com/graphics/b/blog/posts/mgd-integration-in-unity
• https://developer.arm.com/products/software-development-tools/graphics-development-tools/mali-graphics-debugger
• https://developer.arm.com/products/software-development-tools/ds-5-development-studio/resources/ds-5-media-
articles/2017/04/mali-graphics-debugger-introduction-part-1
• https://developer.arm.com/products/software-development-tools/ds-5-development-studio/resources/ds-5-media-
articles/2017/04/mali-graphics-debugger-introduction-part-2
• http://malideveloper.arm.com/armunityguide
• https://developer.arm.com/graphics/unity/unity-engine-tutorials
• https://developer.arm.com/graphics/vulkan/vulkan-tutorials
To find out more….

Get the most out of mobile with Vulkan in Unity

  • 1.
    Get the MostOut of Mobile withVulkan in Unity Roberto Lopez Mendez DevGAMM Moscow 2017 Senior Engineer 18/05/2017
  • 2.
    ©ARM20172 Agenda  The benefitsof theVulkan graphics API  Multi-threading  Multipass  Vulkan vs OpenGL ES with Sky Force Reloaded  Mali Graphics Debugger (MGD)  Integration in Unity  Live demo  Wrap up
  • 3.
    ©ARM 20173 The benefitsof theVulkan graphics API
  • 4.
    ©ARM20174 Multi-threading / multicoreefficiency  Created from the ground to be thread-friendly  Multi-threading widely considered in the specs  Multi-threading responsibility moved to application level  The application has better visibility  Efficient utilization of multiprocessor architecture  Lower CPU load and energy consumption  Spread work out faster to multiple cores  Able to schedule and migrate tasks between ARM ® big.LITTLETM cores according to the load
  • 5.
    ©ARM20175 Multi-pass rendering  Everythingis declared ahead of time in the render pass  Each sub pass can specify different outputs and they can be chained together  Very performant in tiled GPUs such as ARM Mali GPUs  Each pixel in a sub-pass can access the result of the previous sub-pass  All data can be contained on the fast on-chip memory, saving bandwidth  Example of use-cases:  Deferred rendering  Soft-particles  Tone-mapping
  • 6.
    ©ARM20176 Vulkan benefits inLofoten demo SCENE INFO • ~ 100 lights with shadow maps • 3M primitives (reduced to 500K with very efficient occlusion culling) • 500 draw calls • Sun light with cascade shadow map • ~ 10 reflection probes • FFT compute in ocean rendering • Deferred shading using multi-pass • 10x less load on CPU with multithreading
  • 7.
    ©ARM 20177 Sky ForceReloaded with Vulkan and Unity
  • 8.
    ©ARM20178 What is SkyForce Reloaded?   Modern shoot‘em experience  Intense action, very rich graphics  Pushing CPU and GPU to the limits
  • 9.
  • 10.
    ©ARM201710 Performance issues inSky Force Reloaded  Performance issues on OpenGL ES  Even on high-end devices it was not possible to maintain 60 FPS all of the time  Fill rate was not the bottleneck  Up to 1000 draw calls per frame  CPU was spending a lot of time preparing data for GPU
  • 11.
    ©ARM201711 Performance benchmark  Drawcalls are expensive  OpenGL ES driver is not optimal  PerhapsVulkan can help?  Vulkan is supported by Unity!
  • 12.
    ©ARM201712 Sky Force Reloaded:Vulkanvs OpenGL ES Best case 21% faster using Vulkan. On average 15% faster using Vulkan.
  • 13.
    ©ARM201713 Sky Force Reloaded:Increased workload Best case 82% faster using Vulkan. On average 32% faster using Vulkan.
  • 14.
    ©ARM201714 Extra power enabledbyVulkan  More content  Add more particle, objects or animations  Keep the same FPS with richer graphics
  • 15.
  • 16.
    ©ARM201716 Power consumption test Power consumption is a problem  Players were not happy  Console-like quality games consume a lot of power  Can Vulkan help?
  • 17.
  • 18.
    ©ARM201718 Power consumption test Vulkan consumed 10 to 12% less power in the game  Majority of savings come from the CPU  Extra minutes of playtime with Vulkan!
  • 19.
    ©ARM201719 Summary  Great touse “out of the box”  Improves your FPS  Adds some extra minutes of playtime  You can add some more graphics and make your game look better
  • 20.
    ©ARM 201720 Mali GraphicsDebugger (MGD) integration in Unity
  • 21.
    ©ARM201721 Mali Graphics Debugger(MGD)  Draw-call by Draw-call stepping To identify draw call related issues, redundant draw calls and other opportunities to optimize  TextureView Visualize an application’s texture usage, to identify opportunities to compress textures or change formats  Shader Statistics Understand which vertex and fragment shaders are the most expensive with cycle count reporting  Vertex Attribute / UniformView See vertex data and index buffers  StateView Full visibility of graphics state and tracking of state changes  Dynamic Optimization Advice Highlighting of common API misusage and dynamic performance improvement advice Download MGD for free at developer.arm.com
  • 22.
    ©ARM201722 Mali Graphics Debugger Vulkan adbinstall -r MGD.apk adb install -r MGD.apk OpenGL ES Assets/Plugins/Android/libs/armeabi-v7a/ libVkLayerMGD32.so
  • 23.
    ©ARM 201723 Live demo:debugging Unity application with MGD
  • 24.
    ©ARM201724 Wrap Up APPLICATION Single threaded/context ARMMali GPU DRIVER Context management Memory management Error management GLSL compiler CPU overhead APPLICATION Memory management Thread management Multi-threaded command buffers SPIR-V shader pre- compilation ARM Mali GPU DRIVER Very Light Driver Lower overall power consumption VULKAN BENEFITS • Portability across multiple platforms • Native thread friendly • Efficient utilization of multiprocessor architecture • Lower CPU load • Reduced energy consumption • Extra benefits for mobile platform and tiling architectures such as ARM Mali GPUs • Pixel access to result of previous sub-pass • Data contained on fast on-chip memory • Memory bandwidth saving • Loadable validation and debug layers Mali Graphics Debugger
  • 25.
    ©ARM201725  AddVulkan tothe list of Graphics API – save performance, battery last longer  Upgrade to Unity 5.6 – very easy to use MGD as it is integrated into Unity Takeaways
  • 26.
    The trademarks featuredin this presentation are registered and/or unregistered trademarks of ARM Limited (or its subsidiaries) in the EU and/or elsewhere. All rights reserved. All other marks featured may be trademarks of their respective owners. Copyright © 2017 ARM Limited Thank you Questions
  • 27.
    ©ARM201727  Find outmore info about the topics of this talk at: • https://www.youtube.com/watch?v=VCSkp-QZ37M • https://www.youtube.com/watch?v=WI7nXq8oozw • https://community.arm.com/graphics/b/blog/posts/mgd-integration-in-unity • https://developer.arm.com/products/software-development-tools/graphics-development-tools/mali-graphics-debugger • https://developer.arm.com/products/software-development-tools/ds-5-development-studio/resources/ds-5-media- articles/2017/04/mali-graphics-debugger-introduction-part-1 • https://developer.arm.com/products/software-development-tools/ds-5-development-studio/resources/ds-5-media- articles/2017/04/mali-graphics-debugger-introduction-part-2 • http://malideveloper.arm.com/armunityguide • https://developer.arm.com/graphics/unity/unity-engine-tutorials • https://developer.arm.com/graphics/vulkan/vulkan-tutorials To find out more….