- 17 September 2018
- Imagination Technologies
Once, when you were looking to develop a mobile application with complex graphics, in most cases you immediately thought of OpenGL ES. In this blog post we’ll be discussing the benefits of Vulkan and why you really ought to consider using this next-generation of graphics API.
Released in 2016, Vulkan® is the successor to OpenGL ES™, the Khronos Group’s answer to competitor APIs such as Direct3D 12 and Metal. It offers developers greater control and transparency in crafting their applications, and overall has a greater potential for maximising performance than OpenGL ES. However, this does come at the cost of increased complexity and there’s no denying that Vulkan requires more effort to use effectively than OpenGL ES. However, that shouldn’t stop you from making the leap. Granted, the change is comparable to moving from fixed-function pipelines to shader-based ones, but it is worth remembering how that move revolutionised the industry. Yes, there was a lot to learn, but the amount of flexibility, control, and freedom we got after the change made it all worth it.
Alright, so why is it so important I switch to Vulkan?
Firstly, Vulkan is supported by Android, Linux, Windows, Tizen, Nintendo Switch, macOS, iOS (via MoltenVK) and more to come. We have already started seeing games making use of Vulkan on these platforms, such as Wolfenstein II, Roblox, and DOTA2, with the number only going to go up.
To stay competitive, it may well be time for you to put OpenGL ES away and get to grips with Vulkan. Most of the time, the move will be beneficial, unless you lack the necessary resources to afford the move – as this blog post expands upon later.
The benefits of Vulkan
Recently, we have seen the release of many new rendering APIs, not just Vulkan – APIs such as Direct3D 12 and Metal. These new APIs are all moving in a similar direction when it comes to the best way to tackle driver overhead and full control.
One of Vulkan’s biggest advantages is that it supports a myriad of platforms. This means developers can save a lot of time and money, as instead of learning and supporting all the new APIs for each platform, they can just learn Vulkan.
It also enjoys wide adoption by game engine developers. The biggest game engines used today already feature full Vulkan support – engines such as Unity, Unreal Engine 4, and CryEngine, to name a few. So, you can enjoy all the benefits of Vulkan without any of the hassle of developing your own engine to take advantage of it.
Vulkan also features batching to reduce the load on CPUs, accelerating effects with on-chip memory thanks to being prioritised by the API, and finer-grained control over memory allocation.
So… how do I know if it’s worth the effort?
Vulkan offers benefits such as those mentioned above by removing the requirement for software drivers to guess at what is happening in an application. Instead, developers must be explicit in their usage.
As a result, you may be feeling somewhat apprehensive over porting your applications to Vulkan. After all, what guarantee is there that it will be worth the blood, sweat, and tears? Well, we’ve compiled a quick list of the various situations in which it’d be beneficial for you to move your application to Vulkan, and situations in which it’d be best to leave things be.
For sure: when your application is CPU-bound, and you would like to improve performance by distributing work on multiple cores
Vulkan excels at making heavy API usage CPU-bound applications faster. The low driver overhead it provides really helps in such situations, and it can also help if you need to parallelise the graphics work you want to submit.
For sure: when starting a new project on a new platform
When targeting new platforms, it’s usually better to use Vulkan. This is because even though there are optimisations suitable for different platforms, if you optimise for mobile your application will probably be fine on all mobile platforms because they are quite similar. A well-structured and optimised Vulkan build should run efficiently across various platforms without the need for special workarounds. But when you’re focusing on a select few platforms, you can afford to spend more time on optimisation. In such situations, it is worthwhile to switch to Vulkan and get the most out of the hardware. As you have full control over synchronisation with Vulkan, it is possible to reduce frame-rate spikes, hitches, and jitters. It is up to you to take the opportunity, but it’s certainly there.
Maybe: when working on a heavily GPU-bound application
Vulkan may be of use to you if you’re working on an application that is heavily GPU-bound. Getting rid of driver overhead could reduce CPU usage, and therefore power consumption and heat, enabling the GPU to run at higher frequencies.
Maybe: when a heavily CPU-bound application is limited due to non-API work
In the case of a heavily CPU-bound application that’s mainly bottlenecked by non-API work, Vulkan may not provide much in the way of benefits. Again, it may help a little as there would be more time for the CPU to do everything else, but it might be a good idea to optimise the non-API workload first.
Probably not: when you’ve already written an application that is GPU-bound and heavily optimised
If you have an application already heavily optimised with the last generation’s APIs, such as following Approaching-Zero-Driver-Overhead (AZDO) principles, then Vulkan will be of little use to you.
OK, Vulkan is for me. What next?
The important thing to keep in mind when moving to Vulkan from OpenGL ES is that there are issues that can arise when adopting a new, more complex API. Vulkan has a level of verbosity that makes it quite hard to learn. The improved performance comes at a price; Vulkan requires more maintenance and a higher level of responsibility to ensure everything is running correctly.
OpenGL ES is built in such a way that a lot of the operations required to run an application correctly are hidden. These operations are:
- Resource management
- Some synchronisation
- Error checking and validation
- Pre-compiling shaders
Vulkan is much more hands-off and requires code to explicitly define and execute these operations. That being said, there are often tools and libraries out there that can help developers with some of these aspects.
How does PowerVR support Vulkan?
PowerVR provides valuable support for our developers. If you want to start taking advantage of Vulkan, look no further than our SDK. It features a Framework built from the ground up to support development on this new API. It has helpers, reduces boilerplate code, and comes with accompanying documentation.
We also offer a step-by-step introduction to Vulkan called HelloAPI, which is a thorough guide taking you through all the steps needed to render a triangle. It is available on GitHub alongside our SDK and Framework.
To stay in touch with the latest developments with PowerVR be sure to follow us on Twitter @ImaginationTech, Facebook, and LinkedIn.