Quantcast
Jump to content


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.

Overview

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:

  • FIFO: VK_PRESENT_MODE_FIFO_KHR
  • MAILBOX: VK_PRESENT_MODE_MAILBOX_KHR

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

Screen-Shot-2019-07-26-at-3.09.02-PM.png

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.

Screen-Shot-2019-07-26-at-3.09.16-PM.png

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.

Screen-Shot-2019-07-26-at-3.09.30-PM.png

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.

Screen-Shot-2019-07-26-at-3.09.45-PM.png

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?

Screen-Shot-2019-07-26-at-3.09.59-PM.png

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.

Screen-Shot-2019-07-26-at-3.10.12-PM.png

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.

Screen-Shot-2019-07-26-at-3.10.38-PM.png

 

Screen-Shot-2019-07-26-at-3.10.52-PM.png

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

Link to comment
Share on other sites



  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
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.

Loading...
  • Similar Topics

    • By Samsung Newsroom
      Samsung Electronics today announced that its Tizen OS will be embedded in Loewe’s latest premium TV, stellar, set to launch on July 15 in Europe. This is a significant milestone for the Tizen Licensing Program, which started in 2022 and is now rapidly growing in Europe and worldwide.
       
      “This new collaboration with Loewe ensures that its latest luxury TV, stellar, will exceed expectations with the high-end experiences it brings to consumers,” said YS Kim, EVP, Head of the Service Business Team, Visual Display Business at Samsung Electronics. “It’s also more momentum for Tizen OS, which has established itself as the software platform of choice for premium TVs. Moving forward, we will continue to push the boundaries of how users interact with their TVs.”
       
      Loewe, renowned for its luxury and high-end TVs, has chosen Tizen OS to enhance the viewing experience of its consumers. In particular, the brand is celebrated for its impeccable design and use of premium and unique materials — including stone and concrete back panels. Building on that foundation, this partnership with Samsung underscores the mutual commitment of both companies to deliver superior user experiences.
       
      Tizen OS, based on the newest 2024 Tizen licensing platform, offers a wealth of content and service options, making it the ideal choice for Loewe’s discerning customer base. With Tizen OS, users have access to a wide variety of features, ensuring an unparalleled entertainment experience. Key features include:
       
      Samsung TV Plus: A vast array of free channels and on-demand content, providing a diverse selection of entertainment options. Gaming Hub: Access to top gaming platforms and services, offering an integrated gaming experience of 1,000+ titles without the need of a console. SmartThings: Seamless connection to smart devices in your home.  
      Outside of licensing partnerships, Tizen OS powers 270 million Samsung Smart TVs and offers an intuitive interface that minimizes the steps required for navigation and customization. Tizen OS users can stream their favorite content and play thousands of games — all on one screen — and every aspect of the TV experience is personalized and secured by Samsung Knox.
      View the full article
    • By Shashank Suryavanshi
      Hi, I've developed the Tizen app using the web and now after building it, the build is created in wgt format.
      I want to install the build directly on Samsung Tv so that I can test the app there once.
      I've already created the certificates and it's also verified by the Tizen team.
      Now, when I tried to connect the SamsungTv with Tizen using the Device Manager I'm getting these following errors
      The remote device is already connected by another one. This remote device is running on a non-standard port or There is no IP address, please check the physical connection What I've done?
      I opened the developer mode of Samsung tv and updated the IP address with my system IP address and in the device manager I added all the details what was required and after clicking on add button then I faced the above errors.
      Can anyone help me like how can we either create the build in .tmg format because Usb demo packaging tool is not supported now.  Or how can I connect the SamsungTv with Tizen Studio using the Device Manager. 
      I've read and went through the documentation from official site still I face this issue.
    • By Samsung Newsroom
      The Samsung Odyssey OLED G8 (model name: G80SD) has been making waves in the tech world since its launch on June 4. Garnering accolades like Editor’s Choice, 5-Star Ratings and Highly Recommended badges from multiple review publications, this monitor is being celebrated for its next-level OLED experience and new AI capabilities.
       
      ▲ Samsung Odyssey OLED G8 (G80SD) has been recognized by many leading outlets as a top-rated gaming monitor
       
      The Odyssey OLED G8 is the 32” flat OLED gaming monitor with 4K UHD (3840 x 2160) resolution and a 16:9 aspect ratio. It boasts innovative features such as OLED Glare Free and Samsung’s proprietary burn-in protection technology. Additionally, the monitor is powered by the NQ8 AI Gen3 processor, the same one used in Samsung’s 2024 8K TV. This processor upscales content to nearly 4K when using native Smart TV apps or Samsung Gaming Hub,1 providing a superior viewing experience.
       
      See what each of the following review outlets said about the monitor (listed below in alphabetical order):
       
      CGMagazine Forbes Home Theater Review Newsweek Trusted Reviews  
       
      Groundbreaking Innovations in Gaming Monitors
      Forbes noted that “Samsung has taken the wraps off two cutting edge new additions to its acclaimed Odyssey range of premium gaming monitors, both equipped with advanced features the likes of which we haven’t seen in the monitor world before.”
       
      “What really sets the S32G80SD apart, though, is a trio of ground-breaking new features for the monitor world,” said Forbes. These features include:
       
      The Pulsating Heat Pipe, the first of its kind in a monitor to help prevent burn-in, “delivered in an ultra-thin screen design…can work on an extremely local level, efficiently only impacting the parts of the screen Samsung’s processor identifies as being potential ‘hot spots’.” The OLED Glare Free screen, which “‘rejects’ both ambient and direct light sources almost defies belief… This helps you appreciate the screen’s OLED-powered contrast better and removes one of the most common gaming distractions.” The S32G80SD-optimized NQ8 AI Gen 3 processor, which demonstrates “increased crossover between the gaming monitor and TV worlds.”  
      ▲ The Odyssey OLED G8 is the first monitor in the world to apply a Pulsating Heat Pipe that helps prevent burn-in


      Versatile Gaming and Entertainment Powerhouse
      In addition to Forbes’ recognition, both Home Theater Review and Trusted Reviews acknowledged the groundbreaking features of the G80SD, awarding it top ratings and prestigious accolades.
       
      Trusted Reviews praised the Odyssey OLED G8 with a 5-star rating and their coveted Highly Recommended badge. They noted that the monitor delivers on its multipurpose promises, providing both immersive video performance and exceptional gaming experiences. “Samsung’s S32G80SD is on a mission to take the brand’s gaming monitor division to a whole new level,” said Trusted Reviews. For those looking for a well-rounded monitor, “There’s no other monitor out there right now that does such a fantastic job of switching between its gaming and video ‘sides’ without either feeling compromised by the other.”
       
      Home Theater Review echoed the praise, awarding Samsung’s OLED G8 their 2024 Editors’ Choice award and giving it an overall 5-star rating. They note that Samsung has “cracked the code” with the Odyssey OLED G8, stating that “whether you’re a casual gamer or a die-hard esports competitor, the G8 has you covered… For gamers, the G8 is an absolute dream.”
       
      The outlet was also impressed by the monitor’s versatility, highlighting that “the integrated Samsung Gaming Hub transforms the display into a full-fledged gaming platform.” In fact, the Odyssey OLED G8 can also be used as a standalone TV through the Smart TV functionality, providing access to all the latest apps and streaming services. Home Theater Review concluded, “The G8 delivers an unparalleled experience… setting a new gold standard for all-in-one monitors.”
       
      ▲ The Odyssey OLED G8’s Core Lighting+ provides a more immersive ambiance to the gaming environment
       

      Superior Performance and Design
      Following the recognition from Home Theater Review and Trusted Reviews, both Newsweek and CGMagazine also selected the G80SD as their Editor’s Choice, further affirming its standout performance and design.
       
      Newsweek added to the praise, stating, “The Samsung 32G80SD is a fast 4K OLED monitor with a good smart TV interface and the ability to act as a smart home hub. The display delivers an incredibly fast refresh rate at full 4K resolution and a super fast response rate to give you as much of an edge as you can.” Newsweek also commended the monitor’s “stealthy” and slim design. They also described it as easy to install, taking less than five minutes to do so without any tools.
       
      Impressed by these features, Newsweek credited the Samsung OLED G8 with their Editors’ Choice Award, emphasizing that the display provides “several upgrades to your PC or even a next gen console.”
       
      CGMagazine awarded the Samsung OLED G8 with their Editor’s Choice accolade, giving the monitor an impressive review score of 9 out of 10. They remarked, “The Samsung Odyssey OLED G80SD struts the most when it is pedaling its breakneck 240hz refresh rate over its stunning 4K display.” They were particularly impressed by the monitor’s imagery, noting, “Where the Samsung Odyssey OLED G80SD separates itself from the rest of the pack is with onboard NQ8 AI Gen3 Processing…it feels like it’s the first time you’re seeing a game again through a fresh lens.”
       
      ▲ Samsung Odyssey OLED G8 (G80SD) has been recognized by many leading outlets as a top-rated gaming monitor
       
       
      1 Gaming Hub is available in select countries, with app availability varying by region. AI upscaling functions only when using the built-in Smart TV apps and Samsung Gaming Hub. (PQ priority mode)
      View the full article
    • By Samsung Newsroom
      “Walking along the beach takes me back to my childhood, looking at reflections on the water and the way the horizon keeps changing”
      — Serge Hamad, photographer
       
      Serge Hamad is a visual storyteller whose multifaceted talents as a journalist, photographer and artist have informed the rich tapestry of his work. Having documented sociopolitical issues in war zones earlier in his career as a journalist, he now captures calm and serene seaside images as a photographer. Hamad’s work, including the highly acclaimed “Relax” series, captures tranquility in his signature style and also supports human rights groups with its impact.
       
      Born in the Mediterranean, Hamad has been profoundly influenced by his lifelong fascination with the sea. His photography, characterized by comforting and reflective qualities, has gained widespread recognition from global audiences. Since joining Samsung Art Store in 2020, his work has gained an even wider following as people have interacted with his art in new ways.
       
      This June, Samsung Art Store added two more of his notable pieces — “Beach #61” in the “Colors of Pride” collection and “Beach #64” in “Hello Summer.”
       
      In an interview with Samsung Newsroom, Hamad shared his creative process and how his background and life experiences shape his art, as well as the profound impact his evocative images have had on viewers.
       
      ▲ Serge Hamad
       
       
      An Artist’s Journey
      Q: Please describe your journey into the world of visual arts. What inspired you to move in that direction?
       
      Earlier in my career, I used photography and videography to document various sociopolitical issues as a war zone journalist. In 2011, I decided to shift my focus to capturing more sincere and lighthearted scenes with my lens.
       
      With the “Relax” series,1 my first body of work in fine art, I wanted to share peaceful and placid images with human rights organizations and support them with the proceeds. The public response well surpassed my expectations, so I decided to continue on this path.
       
      Q: Your “Relax” series is well known. What inspired you to shoot a series on the beach?
       
      I was born on the Mediterranean coast, and the sea has always fascinated me. Walking along the beach takes me back to my childhood. I used to love looking at reflections on the water and the way the horizon kept changing.
       
      My multicultural background, being half North African and half Westerner, has profoundly influenced my artistic vision and the themes I explore in my work. This unique blend of cultures allows me to draw from a rich tapestry of traditions and aesthetics, especially when it comes to colors. It has given me a broader perspective, enabling me to see and interpret the world through diverse lenses.
       
      Q: How do you make your beach photography so engaging?
       
      When it comes to capturing an engaging image, planning and timing are crucial. Planning is more than just checking the weather before a shoot — it’s also about selecting the right filming location. For example, I would go to a beach near a marina if I want a shot of a boat on the horizon. To capture a pelican diving into the sea, I would pick a specific beach and go there an hour before sunset. The rest of the atmosphere depends on human interactions with natural elements.
       
      Q: Why does the beach hold so much significance for you?
       
      Consistency is my top priority when developing a collection. I started the “Relax” series at the beach because it is one of the most relaxing places on the planet for millions of people, including myself. I enjoy working at the beach because it reminds me of both the Sahara Desert and the Mediterranean Sea from my childhood.
       
      “I started the ‘Relax’ series at the beach because it is one of the most relaxing places on the planet for millions of people, including myself.”
       
       
      Collaborating With Samsung Art Store
      Q: How do you choose which pieces to share with Samsung Art Store? What emotions or themes do you wish to share? 
       
      I work with Samsung to select pieces that align with a particular themed curation because that way, I can focus on the message delivered to viewers. I strive to convey tranquility and harmony through my pieces on Samsung Art Store.
       
      Q: Samsung Art Store featured “Beach #61” and “Beach #64” in its June collections. Can you share the meaning behind these pieces?
       
      ▲ “Beach #61” (2023)
       
      “Beach #61” was shot in California. The rainbow-colored lifeguard house symbolizes tolerance.
       
      ▲ “Beach #64” (2023)
       
      “Beach #64” is more of a friendly invitation for the viewer to follow my footsteps on a walk at the beach.
       
      Q: Of all the works you’ve made available on Samsung Art Store, what are your three favorites?
       
      I’d have to choose “Beach #4,” “Beach #37” and “Beach #32.” All three photographs show how humans share nature with seabirds.
       
      ▲ “Beach #4” (2011)
       
      “Beach #4” uses a minimalistic approach to convey serenity with natural lines and colors. Before taking this photo, I wondered who would call a taxi to go surfing. It was only when the car approached that I realized it was a lifeguard vehicle.
       
      ▲ “Beach #37” (2016)
       
      I couldn’t resist capturing this scene of a seagull resting on a dune that looked like a charcoal painting.
       
      ▲ “Beach #32” (2014)
       
      Even if the seagulls in “Beach #32” had left and weren’t in the shot, we would still know that they had shared the dune with humans and enjoyed it together. The footprints of both humans and birds on the same dune symbolize their different influences on nature.
       
      “Embracing culture in our homes is always a great idea, and The Frame does just that.”
       
       
      Embracing the Future
      Q: As an artist, how do you feel about the impact of technology on the art world?
       
      Technology has always impacted my work and influenced my approach to photography. As a photographer, I use various tools every day to express myself — and different situations and subjects calls for different tools. Improving technology means giving artists more powerful capabilities to express themselves, so I embrace both analog and digital tools.
       
      In my opinion, artists in all kinds of disciplines have always benefited from innovations. During my career as a photographer, I have seen the popularization of imaging technology to a level that made it accessible to everyone. I believe this has created new artists and will continue to do so. The main thing to keep in mind, though, is that technology is a tool. The artistic process happens in your own mind.
       
      Q: How do you believe your collaboration with Samsung Art Store and The Frame has changed the way people appreciate art in their homes?
       
      The Frame is a brilliant concept, making art more accessible to a wider audience. Embracing culture in our homes is always a great idea, and The Frame does just that.
       
      Q: Is there anything else you would like to share with our readers?
       
      I’m working on a new series called “A table here, a table there.” I plan to spend a few months traveling along the U.S. West Coast to produce it and hope to share the collection by the end of this year.
       
       
      1 All the “Beach” artwork on Samsung Art Store are part of the “Relax” series.
      View the full article





×
×
  • Create New...