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 a new partnership with FlexIt, a health and wellness solution that makes exercise more convenient and accessible. Starting this month,1 FlexIt will bring personal trainer-based fitness content to Samsung Smart TV users through the new lifestyle hub Samsung Daily+2 on Samsung Tizen OS.
       

       
      “Wellness should be central to our routines, so building healthy habits through Samsung Daily+ makes it convenient to incorporate health and wellness into all different aspects of daily life,” said Demian Hyun, Vice President and Head of the Experience Planning Group of Visual Display Business at Samsung Electronics. “This new partnership underscores Samsung’s commitment as the leader in the global display industry to promoting thoughtful, interconnected health experiences aimed at bettering the lives of consumers.”
       

       
      On the FlexIt app’s online portal, users can find, book and pay for exclusive one-on-one virtual fitness sessions directly on their TVs. With a camera connected — whether it be via a supported webcam3 or a smartphone — virtual health professionals4 provide real-time feedback, adjust workouts and offer form modifications to foster a supportive, safe and effective workout environment.
       

       
      The FlexIt app helps users approach their health in a more holistic way; in addition to workout content, FlexIt offers nutrition training, low-impact wellness activities like meditation and yoga, and physical and occupational therapy. By working virtually with a trainer who understands their personal fitness journey and wellness goals, users craft an attainable routine that suits their needs and lifestyle, all from the comfort of their home or any other location with a connected device.
       

       
      By housing services such as FlexIt, Samsung Daily+ is paving the way for the future of virtual health and wellness experiences through its convenience and accessibility to build productive and convenient daily routines. Samsung Daily+ serves as a new lifestyle hub for Smart TV users, allowing them to conveniently enjoy a wide range of premium lifestyle services and features — such as home fitness, telehealth services, video calls and more — using one single interface.
       
      “Through the innovative FlexIt app for Samsung, we’re furthering our commitment to making fitness more accessible than ever. By delivering personalized, one-on-one immersive training experiences directly to your living room, we’re extending our reach to a broader audience, empowering individuals to achieve their wellness goals with ease and convenience,” said Austin Cohen, FlexIt’s Founder and CEO.
       
      During CES® 2024, Samsung gave consumers an early look at Samsung Daily+ and the FlexIt app on its 2024 Neo QLED 8K. Richard Friedman, FlexIt’s Senior Vice President of Technology, joined the Samsung team in Las Vegas to showcase how the FlexIt app integrates with Samsung TVs. Samsung Daily+ is also a 2024 CES Innovation Awards Honoree, having been recognized as a unique smart home service with an open ecosystem that integrates third-party services.
       
      For more information on health offerings on Samsung’s TV lineup, visit Samsung.com.
       
       
      About FlexIt
      FlexIt has revolutionized the fitness and wellness industry through its innovative, cutting-edge technology, offering a comprehensive approach to holistic well-being for consumers and enterprises. Its core solution centers around live, one-on-one, two-way personal health and wellness sessions with fitness and wellness experts, accessible through both web and app platforms. FlexIt’s platform goes beyond just fitness training, embracing holistic well-being through nutrition coaching (led by registered nutritionists with a focus on weight loss), low-impact wellness activities (yoga, meditation, stretching and dance), health coaching, and physical and occupational therapy (covering preventive, pre/post-natal, senior and recovery), offering 28 health modalities on the platform.
       
      Our comprehensive and innovative approach has earned us recognition within the industry. FlexIt has been selected for the Best Budget-Friendly Coaching App of 2023 by Women’s Health, the Best Personal Trainer Apps of 2023 by Forbes, and the Best Fitness Apps in 2023 by Oprah Daily and has been awarded by Men’s Health, Inc. 5000, US News & World Report, among many others.
       
      For media inquiries, please contact:
      [email protected]
       
       
      1 Availability varies by model and region. The FlexIt app will be available through Samsung Daily+ on all 2024 TV models: Neo QLED 8K, 4K, OLED, UHD (above DU7000) and The Frame. OS upgrade is scheduled to be provided for select 2023 TV models during the second half of 2024. 2022 and 2021 TV model users can download the FlexIt app through the app store.
      2 Starting this year, Samsung Daily+, a hub for lifestyle experiences, provides a wide range of services and features — from personal training and telehealth to video calls and remote PC solutions — in one single interface. With Samsung TVs at the center of the home, users can enjoy the benefits of the latest innovations and seamless connectivity between devices in their day-to-day lives.
      3 Logitech Webcam (C930e, C922 PRO STREAM WEBCAM, C925E, C920s Pro HD Webcam, HD Pro Webcam C920, C920-C, C930c, HD Pro Webcam C920, StreamCam), Samsung (SC-FD100B)
      4 English- and Spanish-speaking FlexIt health professionals and trainers
      View the full article
    • By Samsung Newsroom
      Samsung Electronics, the world’s leading TV manufacturer for 18 consecutive years, has commenced its annual series of Tech Seminars in Frankfurt, Germany. From February 20 to 22, Samsung will showcase its newest display lineup for 2024 that features new, innovative AI technology and smart features on the Neo QLED, OLED and Lifestyle products to professionals in Europe.
       
      Tech Seminar sessions are a longstanding program, having delivered detailed information and exclusive hands-on experiences with new products for the past 13 years. As part of Samsung’s visual display vision — “We look out of the box to inspire new ways of life” — this year the company is displaying select, cutting-edge technologies from its 2024 lineup that offer new lifestyles and new ways of consuming content.
       
      The 2024 European Tech Seminar in Frankfurt sets the stage for similar sessions in major regions worldwide later this year, including Southeast Asia and Latin America. At these events, Samsung will feature new technologies that span across the latest TVs and lifestyle product lineup:
       
      Samsung’s 75-inch Neo QLED 8K QN900D incorporates the new and powerful NQ8 AI Gen3 Processor, which supports features like 8K AI Upscaling Pro and AI Motion Enhancer Pro for the best Neo QLED 8K visuals to date. The 2024 Tizen OS brings content front and center, offering a personalized experience based on different accounts set up on smart TVs. Tizen features services such as Samsung Gaming Hub, an all-in-one game streaming discovery platform, with content recommendations for a convenient and tailored cloud gaming experience. Music Frame is a customizable wireless speaker designed to seamlessly blend into its surroundings. It can operate as a standalone speaker, or it can pair with a Samsung TV and soundbar via Q-Symphony to deliver a more immersive viewing experience with surround sound. New OLED Glare Free technology was specifically designed for Samsung’s 2024 OLED screens and preserves color accuracy and image sharpness while reducing reflections from nearby lighting. The new, specialized hard-coating layer and surface coating pattern overcomes the trade-off between gloss and reflection.  
      ▲ Martin Kim, Picture Quality Solution Lab at Samsung Electronics, explains that the 2024 Neo QLED 8K incorporates the new and powerful NQ8 AI Gen3 Processor, supporting AI-backed features such as 8K AI Upscaling Pro and AI Motion Enhancer Pro.
       
      ▲ Andrew Sohn, Picture Quality Solution Lab at Samsung Electronics, shows off Samsung’s AI engine that can instantly optimize picture and sound quality based on the game or genre being played.
       
      ▲ Haylie Jung, Picture Quality Solution Lab at Samsung Electronics, demonstrates how users can set up their own profiles on the 2024 Tizen OS for Samsung Smart TVs to enjoy a customized experience including personal recommendations.
       
      ▲ Music Frame is a customizable wireless speaker designed to seamlessly blend into its surroundings.
       
      “Kicking off our Tech Seminar series is always something we look forward to,” said Yong-Jae Kim, Executive Vice President of Visual Display Business at Samsung Electronics. “Each year we have the opportunity to meet with local media and professionals, not just to provide in-depth demonstrations and explanations on new technology, but also to discuss the products we are most excited about and hear their feedback.”
       
      For more information on Samsung’s 2024 TV and lifestyle product lineup, visit samsung.com.
      View the full article
    • By Samsung Newsroom
      Samsung Electronics has once again demonstrated its dominance in the global TV market, marking an unprecedented 18-year streak at the forefront of the industry.
       
      Market research firm Omdia reported that Samsung has achieved a 30.1% share of the global TV market in 2023, reinforcing its status as the industry leader since 2006. This success is largely due to the company’s strategic focus on premium and large-screen TV categories, driven by its cutting-edge QLED and OLED models.
       
      Since its launch in 2017, Samsung’s QLED TV lineup, including the latest Neo QLED models, has surpassed cumulative sales of 40 million units. In 2023 alone, the QLED lineup achieved sales of 8.31million units.
       
      ▲ Samsung is ranked No. 1 global TV brand for 18th consecutive year
       
      Samsung asserted notable leadership in the premium TV sector – specifically for TVs over 75 inches and priced above $2,500. The company has recorded an impressive 60.5% market share in terms of sales for TVs priced over $2,500, while also maintaining a lead with 33.9% sales share for TVs over 75 inches. In addition, thanks to robust sales of 98-inch models, TVs over the 90 inches have maintained the lead with a 30.4% market share.
       
      Building on its success in the ultra-large and high-end TV market, Samsung has also made significant strides in the OLED sector. The company’s OLED TV lineup recorded 1.01 million units sold in 2023, capturing a market share of 22.7%. With the expanded OLED lineup in 2024, Samsung’s market share in the OLED sector is projected to surge in 2024.
       
      “We are proud to be recognized as the market leader in the global TV sector for 18 consecutive years, a testament to the enduring trust and loyalty our customers place in Samsung,” stated SW Yong, President and Head of Visual Display Business at Samsung Electronics. “We are deeply committed to advancing the industry, moving beyond exceptional picture quality to offer more meaningful and valuable experiences.”
       
      At CES 2024, Samsung Electronics unveiled the groundbreaking NQ8 AI Gen3 processor, heralding the start of the AI Screen Era. The advancement in state-of-the-art chipsets and capabilities is set to redefine the smart TV domain, integrating sophisticated AI powered by Tizen OS to establish AI screens as center of the smart home innovation.
       
      2024 is shaping up to be another year of significant innovation for Samsung. With advancements in processors and cutting-edge AI features, Samsung is on course to further transform home entertainment and set new benchmarks in the TV industry.
      View the full article
    • By OmeJuup
      An app that I would like to download and use (CAIWAY WebTV) is only supported by Tizen OS 5.0, but my Samsung TV is running on Tizen 4.0, so the app cannot be found. I updated the TV software to the latest version, but this does not update the Tizen OS itself. Is there a way to update the Tizen OS itself?
    • By Mahesh Gadhe
      <article>
              <div><img id="imageTag" src=""></div>
              <div><video id="videoTag" onended="onVideoEnded();" src=""></video></div>
              <!--<div id="YoutubePlayer" width="600" height="400" src="" frameborder="0" sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-top-navigation" style="z-index: 1;"></div>-->
              <div style="position:fixed; top:50%; left:50%; transform:translate(-50%, -50%); z-index:999;">
              <div id="YoutubePlayer" style="width:600px; height:400px;"></div>
          </div>

          </article>
      As to play the youtube video we need to use the youtube iframe, we are facing challenge here. When the youtube video plays on the TV, we lose control over app and hence next video as per CMS does not play. Same happens vice versa i.e when a video from CMS starts playing we are not able to play youtube video if it is next in the list.





×
×
  • Create New...