PerfDoc – How to Optimize Early With Vulkan Validation Layer Tools at GDC18

On this sunny, if incredibly breezy, San Francisco day, we were ushered into the Moscone Centre once again and greeted by Jungwoo Kim from Samsung, who took a moment to recap the benefits of Vulkan’s cross platform capabilities for those attendees who may not yet be working with this most recent API from Khronos. He explained that, whilst Samsung’s view of game development comes from the angle of the device manufacturer rather than developer, that doesn’t mean Vulkan uptake isn’t incredibly important to them. Samsung recognise the importance of enabling high-fidelity mobile gaming as it’s a key experience requirement for both their customers and partners.

The growth of High Fidelity Mobile Gaming

As we’ve discussed before, mobile gaming is no longer just about casual, 2D and arcade titles, now we’re seeing the boundaries between PC and mobile collapse, as mobile users expect to be able to enjoy the latest, complex titles from PC and console. There are a few key enablers to supporting HFMG:

  • High quality graphics
  • Immersive game play
  • Ultra-high performance

These elements make the underlying API ever more important in order to be able to optimise as far as possible and get the best out of the limitations of the mobile form factor. This will always require a certain level of trade-off between quality and performance, targeting larger resolutions, faster framerates, and greater shader complexity and precision. The great thing about Vulkan is that it’s cross platform and ultra-lightweight, with predictable, explicit control, as well as a whole host of great optimisation tools. It reduces the CPU overhead, supporting more drawcalls in the same duration as OpenGL ES, providing more FPS.


Samsung are so invested in the uptake of Vulkan to improve the game dev experience that they’ve announced a new Galaxy GameDev initiative to support those wanting to embrace it, delivering best practices from real-world projects built on Vulkan. Working with over 100 game devs, as well as Unreal Engine and Unity to support the porting of Vulkan to their engines, they are dedicated to helping applications achieve high fidelity at 60fps.

Having already worked on high profile titles such as Lineage Revolution 2 and Final Fantasy, Samsung had established that with the right approach to Vulkan, these games could achieve better quality, shorter loading time and up to an additional 10FPS. With the increased efficiency, you can then free up resources to add more post processing effects, growing fidelity and bringing an even higher quality experience.


Vulkan isn't easy

However, the first Vulkan build they worked on showed significantly worse performance than with OpenGl ES, and it took some serious investigation to establish that this was caused by using the wrong barrier sets. This is because, whilst the explicit nature of Vulkan means developers have a whole lot more control, we all know that with great power comes great responsibility, and there are some potential pitfalls, especially on mobile. This is where PerfDoc comes in, and Arm’s Hans-Kristian Arntzen took the stage to explain the Arm belief that hardware vendors therefore need to step up to support the developer community and make sure we can exploit the full potential of the Vulkan API.

PerfDoc is an open source validation layer freely available on GitHub. It runs on all Vulkan implementations and operating systems and doesn’t need to hook directly into the Mali driver, it only cares about Vulkan. It effectively takes the best practices guide Arm made available last year, and provides a way of automatically checking that those best practices have been followed. The goal of PerfDoc was to make these best practices easily actionable. Whilst you should be checking out these best practices before ever writing your first line of code, even if you do so, you can make mistakes in a larger system by using the API in ways you didn’t intend, so there needed to be a way to implement these as you go along.

It works like this:

The system is basically the same as for Validation layers. Vulkan supports these layers which can be plugged in between the application and the driver during development. PerfDoc is responsible for analyzing your API calls, reporting back to the app with a callback, and forwarding the call to the driver.

Catching these issues early saves a huge amount of development and optimisation time. Not least because, in practice, most developers will start on desktop then port to mobile later, which is when you’ll suddenly start to see the issues that might come with tilers, for example. The great thing about PerfDoc is that you can run it on the PC before you even begin to port it to mobile in order to validate the basics right from the start, making the process of porting considerably smoother and less frustrating.

Multisampling is one area that can be tricky, so PerfDoc checks for the most common pitfalls and tells you what you might have got wrong before it ever becomes an issue. There are also some complexities with index buffers which can be checked and addressed in the simplest way. There are best practices that can be statically checked, like using an alternative API function, errors in the index buffer layout, or pipeline barriers which will cause scheduling bubbles.

There will of course always be some things, like shader performance and cache issues, that are platform specific, but if you find you do need further optimisation for those you should already have cleared the basics with PerfDoc.

But it’s not just for developers, it also enables hardware vendors who receive an APK, for example, to use a debug layer to check for any issues in a smart and streamlined way. In the case of an external audit, PerfDoc is ideal as the first pass to ensure basic best practices have been followed.

Hans Kristian then ran an awesome live demo, showing just how easy it is to identify and avoid common issues. It’s exciting to see how resources like this will help millions more developers get the very best from the Vulkan API.

Graphics & Multimedia blog