Jump to content

Sign in to follow this  
STF News

Vulkan Mobile Best Practice: How To Configure Your Vulkan Swapchain

Recommended Posts

At GDC 2019, Arm and Samsung were joined on stage in the “All-in-One Guide to Vulkan on Mobile” talk to share their learning from helping numerous developers and studios in optimizing their Vulkan mobile games. In tandem, Arm released Vulkan Best Practices for Mobile Developers to address some of the most common challenges faced when coding Vulkan applications on mobile. It includes an expansive list of runnable samples with full source code available online.

This blog series delves in detail into each sample, investigates individual Vulkan features, and demonstrates best practices of how to use them.


Setting up a Vulkan swapchain involves picking between options that don’t have a straightforward connection to performance. The default options might not be the most efficient ones, and what works best on a desktop may be different from what works on mobile.

Looking at the VkSwapchainCreateInfoKHR struct, we identified three options that need a more detailed analysis:

  • presentMode: what does each present mode imply in terms of performance?
  • minImageCount: which is the best number of images?
  • preTransform: what does it mean, and what do we need to do about it?

This blog post covers the first two points, as they are both tied to the concept of buffering swapchain images. Surface transform is quite a complex topic that we’ll cover in a future post on the Arm community.

Choosing a present mode

Vulkan has several present modes, but mobile GPUs only support a subset of them. In general, presenting an image directly to the screen (immediate mode) is not supported.

The application will render an image, then pass it to the presentation engine via vkQueuePresentKHR. The presentation engine will display the image for the next VSync cycle, and then it will make it available to the application again.

The only present modes which support VSync are:


We will now each of these in more detail to understand which one is better for mobile.


Figure 1 shows an outline of how the FIFO present mode works. The presentation engine has a queue (or “FIFO”) of images, in this case, three of them. At each VSync signal, the image in front of the queue displays on screen and is then released. The application will acquire one of the available ones, draw to it and then hand it over to the presentation engine, which will push it to the back of the queue. You may be used to this behavior from other graphics APIs, double or triple buffering – more on that later!

An interesting property of the FIFO present mode is that if the GPU can process images really fast, the queue can become full at some point. When this happens, the CPU and the GPU will idle until an image finishes its time on screen and is available again. The framerate will be capped at a stable 60 fps, corresponding to VSync.

This idling behavior works well on mobile because it means that no unnecessary work is performed. The extra CPU and GPU budget will be detected by the DVFS (Dynamic Voltage and Frequency Scaling) system, which reduces their frequencies to save power at no performance cost. This limits overheating and saves battery life – even a small detail such as the present mode can have a significant impact on your users’ experience!

Let us take a look at MAILBOX now. The main difference, as you can see from Figure 2 below, is that there is no queue anymore. The presentation engine will now hold a single image that will be presented at each VSync signal.


The app can acquire a new image straight away, render to it, and present it. If an image is queued for presentation, it will be discarded. Mobile demands efficiency; hence, the word “discarded” should be a big red flag when developing on mobile – the aim should always be to avoid unnecessary work.

Since an image was queued for presentation, the framerate will not improve. What is the advantage of MAILBOX then? Being able to keep submitting frames lets you ensure you have the latest user input, so input latency can be lower versus FIFO.

The price you pay for MAILBOX can be very steep. If you don’t throttle your CPU and GPU at all, one of them may be fully utilized, resulting in higher power consumption. Unless you need low-input latency, our recommendation is to use FIFO.


Choosing the number of images

It is now clear that FIFO is the most efficient present mode for mobile, but what about minImageCount? In the context of FIFO, minImageCount differentiates between double and triple buffering, which can have an impact on performance.

The number of images you ask for needs to be bound within the minimum and maximum images supported by the surface (you can query these values via surface capabilities). You will typically ask for 2 or 3 images, but the presentation engine can decide to allocate more.

Let us start with double buffering. Figure 4 outlines the expected double-buffering behavior.


Double buffering works well if frames can be processed within 16.6ms, which is the interval between VSync signals at a rate of 60 fps. The rendered image is presented to the swapchain, and the previously presented one is made available to the application again.

What happens if the GPU cannot process frames within 16.6ms?


Double buffering breaks! As you can see from Figure 5, if no images are ready when the VSync signal arrives, the only option for the presentation engine is to keep the current image on screen. The app has to wait for another whole VSync cycle before it acquires a new image, which effectively limits the framerate to 30 fps. A much higher rate could be achieved if the GPU could keep processing frames. This may be ok for you if you are happy to limit framerate to 30 fps, but if you’re aiming for 60 fps, you should consider triple buffering.

Even if your app can achieve 60 fps most of the time, with double buffering the tiniest slowdown below 60 fps results in an immediate drop to 30 fps.


Figure 6 shows triple buffering in action. Even if the GPU has not finished rendering when VSync arrives, a previous frame is queued for presentation. This means that the presentation engine can release the currently displayed image and the GPU can acquire it as soon as it is ready.

In the example shown, triple buffering results in ~50 fps versus 30 fps with double buffering.

The sample

Our Vulkan Best Practice for Mobile Developers project on Github has a sample on swapchain images, that specifically compares double and triple buffering. You can check out the tutorial for the Swapchain Images sample.




As you can see from Figures 7 and 8, triple buffering lets the app achieve a stable 60 fps (16.6 ms frame time), providing x2 higher frame rate. When switching to double buffering the framerate drops.

We encourage you to check out the project on the Vulkan Mobile Best Practice GitHub page and try this or other samples for yourself! The sample code gives developers on-screen control to demonstrate multiple ways of using the feature. It also shows the performance impact of the different approaches through real-time hardware counters on the display. You are also warmly invited to contribute to the project by providing feedback and fixes and creating additional samples.

Please also visit the Arm Community for more in-depth blogs on the other Vulkan samples.

View the full blog at its source

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Similar Topics

    • By STF News
      Start Date May 28, 2020
      Location Online
      We are excited to announce our May Technical Talk. This time let's talk about Background Services in the browser!
      Time (UTC) Time (PDT) Topic 6:00 PM GMT+1 10:00 AM Welcome, Latest Samsung Internet News 6:20 PM GMT+1 10:20 AM Background Services in browsers by Maxim Salnikov, Microsoft 7: 00 PM GMT+1 11:00 AM Q&A Background Services in Browsers
      Is there an app life after closing a tab?
      The user closes the tab in the browser, and your wonderful front-end application evaporates. But, what if you could leave some parts of it to work a little more for the benefit of improving UX? To respond to some events, to complete the started communication with the network, in general - to execute some code with the tab closed and even the browser.
      We'll discuss interesting features of the APIs from the service workers family. Service Workers allow you to extend the life of the application so that you always have fresh data at hand, not be afraid of network problems, and be able to show notifications - all for the sake of a great user experience.
      About Maxim
      Maxim Salnikov is an Oslo-based cloud and web front-end geek who builds web applications since the end of the last century and shares his extensive experience with many aspects of the web platform by speaking/training at developer events around the world and running his own conferences & meetups. He is actively exploring new features of the web and the idea of progressive web applications (PWA) in particular.
      View the full blog at its source
    • By STF News
      In this episode of POW, Tony interviews Roger Kibbe, Senior Developer Evangelist for Bixby, Samsung’s intelligent assistant technology. Roger is a tech geek when it comes to voice technology, even launching his own voice startup. Join us as we discuss Roger’s journey to Samsung and the great things around Bixby. Learn how to get started building capsules for Bixby and the magic that drives Viv, the Bixby team at Samsung.
      Topics Covered:
      • Intelligent Assistant Technology
      • Multi-Modality
      • Bixby Capsules
      • Bixby Developer Studio
      • Bixby Marketplace
      • Bixby Developers Chat Podcast
      • Adam Cheyer
      • Viv Labs
        View the full blog at its source
    • By STF News
      Nanobit is an award-winning game publisher headquartered in Zagreb, Croatia with a branch office in Budapest, Hungary. They are developers of popular game titles including My Story, Tabou, and Hollywood Story. Nanobit’s games allow their users to escape from the ordinary into non-reality, which is more popular now than ever.
      Filip Cindrić, Head of Business Development for Nanobit, shares how to develop a successful game, what models are used to make money in the gaming business, and emphasizes the opportunity for game developers in our current global climate.

      Who and what is Nanobit?
      Nanobit is a global gaming studio started by two entrepreneurs in 2008. Today the team consists of more than 120 experts of various backgrounds, all dedicated to one goal - the development of high-quality, super-fun, mobile games! We specialize in mobile casual games, with over 10 million happy gamers who play our games monthly. Both our games and apps have been downloaded over 130 million times.
      We have been recognized by the likes of EY Entrepreneur of the Year 2014, Deloitte’s Technology Fast 50 Central Europe 2014, 2015, multiple times on Deloitte’s Technology Fast 500 EMEA, and FT 1000: Europe’s Fastest Growing Companies.
      There are many indie game developers working on the next big game title. You have a very similar story. Can you share your journey?
      Nanobit was founded by two young entrepreneurs, Alan and Zoran, in Zagreb, Croatia. These two programmers who were completely self-taught. They started the company with 1 iPhone and developed one of the first lifestyle apps for calorie tracking, Tap & Track. This soon paved the way for more apps, and games followed as they were determined to bring more fun into the world.
      Today, Nanobit is a world renowned publisher for lifestyle, narrative, and fashion games, with hits such as Hollywood Story, the winner of Samsung’s Best of Galaxy Store Awards 2019 for “Best Choose Your Own Adventure Game”, and My Story.
      Little did Alan and Zoran know how successful they would be, which makes Nanobit’s journey even more exciting and admirable.

      You specialize in mobile casual games which have amassed over 100 million downloads. What is the basic structure for developing a successful game?
      There is no secret formula on how to develop a successful game. Basically, the first step is to do proper research of the industry and see if your idea is of interest to the potential users. Secondly, you need to have an excellent team of people, including great artists, developers, producers, game testers, and many others. Once you publish your game, you need to stay in touch with your users and listen to their needs and wants. That is the basic structure, but as we said, there is no secret formula!
      Is there a preferred language for game developers?
      The preferred programming language of game developers used to be C/C++, and to some extent, it still is. However, with the rise of quality and accessibility of cross-platform frameworks and game engines, the language used tends to be whatever your engine of choice supports.
      That being said, C/C++ is basically the only natively supported cross-platform language and is still unmatched when it comes to getting every last bit of performance from your game.
      Hollywood Story is a game full of unique, fun characters. What systems do you use to create game concepts and story characters?
      We brainstorm a lot! There are lots of discussions every day on how to spice up the virtual lives of our users. Each novelty, whether it is a game concept, or a new character in the existing game, is discussed by various team members. We need to make sure that our next step is the right one to introduce to our players. We also want to increase the variety of our characters, so regardless of your position within the team (be it developers, artists or analysts), every input is very valuable!
      What are some of the challenges you face while developing your games?
      It is definitely a super-competitive market, where there are many great producers and where consumers are becoming more and more demanding. User acquisition is becoming challenging as well. Speaking of internal challenges, sometimes there are too many good ideas at the same time, which makes it difficult for us to decide what idea to implement first. Fortunately for us, it seems that we made good decisions so far.
      Are there common errors made by developers while programming games?
      Most common errors tend to be general beginner's mistakes that are often related to a framework or a language used. However, one thing specifically related to game programming are the errors caused by the fact that the changes in the game scene often don't take effect until the "next frame" i.e. the next iteration in the core loop.
      What are the models used to make money in the gaming business?
      Things have certainly changed over the years for video games and monetization models fueling its growth. The evolution has taken games from the premium model only, in which users had to commit spending even before making a download, to a more accessible free to play model that has made games widely available for anyone with a proper device. Nowadays, free to play model is definitely a dominant one on mobile devices and that is where we at Nanobit found our success as well.
      The majority of Nanobit’s revenue is generated through micro-transactions, also well known as in-app purchases (IAP), where the user is making a purchase of low value and is being delighted with premium in-game currency, special outfits, etc. Apart from this, ad monetization has seen tremendous growth over the years, and developers have become ever so sophisticated in finding ways to earn more while also enhancing user experience.
      The most popular ad format today is rewarded video, which gives in-game rewards to players in exchange for their time, however formats such as interstitial ads, banners, offer wall, and native ads also follow. And then, of course, there are games that, due to their immense popularity and scale, are able to sign bespoke deals with consumer or other brands and secure extra income through custom advertising, brand partnership, or affiliate deals.
      How do you stay up to date with the latest game and software trends?
      We are continuously researching current trends in technology and gaming industry and are always re-evaluating our development strategy in that regard.
      What advice do you have for indie developers and designers attempting to develop a successful game business?
      We would definitely advise them to focus on the idea and to create something unique and fun, rather than focusing on the monetization model and how to make the game (super) profitable. If you make something unique and creative, success will follow.
      The current global climate has resulted in an increase in gameplay, and a spike in game downloads and sales. Is this an especially unique opportunity for game developers?
      The times we are living in are definitely uncertain, and there is no doubt that this global pandemic has negatively influenced many businesses worldwide. However, this really is a unique opportunity for game developers. Many people worldwide are at home and have more time than usual, so game developers should use this opportunity to gain as many new users as possible.
      With all of your current success, what’s next for Nanobit and Hollywood Story?
      We are working on exciting updates for the current top titles and have new projects in pipeline in the narrative and lifestyle genre.
      We want to thank Filip for talking with us about Nanobit’s journey from game entrepreneurs to their success as an award winning game publisher, and for sharing the importance of staying in touch with your users.
      If you want to check out one of Nanobit’s award winning games, and escape from the ordinary into non-reality, you can download Hollywood Story on the Galaxy Store from your Samsung device.
      Follow us on Twitter at @samsung_dev for more developer interviews as well as tips for building games, apps, and more for the Galaxy Store. Find out more about our Best of Galaxy Store Awards.
      View the full blog at its source
    • By STF News
      We're excited to announce the launch of the Samsung Developers podcast: POW!
      Hosted by Senior Developer Evangelist Tony Morelan, Podcasts of Wisdom (POW!) is where we engage, educate, and inspire designers and developers to succeed with Samsung.
      Hear from Samsung developers talking about the latest tech and new trends. Get insight into all of the opportunities available for Android developers looking to develop for Samsung. Learn about all of the fascinating things our developer community is building for its users. The first three episodes are waiting for you on your favorite podcast player. Hear from
      Jong Woo, head of Game Services for Samsung Electronics America Dan Appelquist, head of Developer Advocacy for Samsung Internet Tony Morelan, your host There are many more guests, including external developers, partners, and industry experts to come in the next few months.
        🎵 It's time to put on music, it's time to light the lights. It's time to get things started on the Samsung show tonight!🎵
      View the full blog at its source
    • By STF News
      A major update for VR and the web
      Hi! I’m Ada Rose Cannon. As well as being a Developer Advocate for the web browser, Samsung Internet, I am a co-chair of the W3C Immersive Web Working Group and Community Group. These two groups work together to produce the WebXR Device API and related specifications.
      As you can imagine, getting WebXR support in Samsung Internet is pretty close to my heart.
      I am pleased to say that since Samsung Internet 11.2, we have initial support for WebXR in our browser. You can view the full support table here. WebXR is a very large API with many modules still being worked out. The core module which is in a stable state is for supporting VR.
      You maybe thinking that VR in the web is old news. At Samsung, we have supported the WebVR API for years. The WebVR device API is now being deprecated since it had some core issues preventing it from being future proof. WebXR is being designed to replace WebVR and reach further to support many features WebVR was unable to such as Augmented Reality and better support for gamepads.
      If you have been supporting a website or JavaScript library designed around WebVR, now is the to migrate it to WebXR to ensure it isn’t broken in the near future.
      Our current support for WebXR is to use the Android VR system to render the experience side by side in the browser so it can be used with cardboard VR devices.
      WebXR on Android (Link to Demo)
      Looking to the future for Samsung Internet, we are working on supporting the AR portions of the WebXR device API so you can build websites which place virtual objects into the user’s environment. For more news about WebXR on Samsung Internet please follow us on Twitter (@SamsungInternet) or keep an eye on https://immersiveweb.dev.
      View the full blog at its source

  • Create New...