i.MX8 - Multimedia - GPU - Vulkan

From RidgeRun Developer Wiki
< IMX8‎ | Multimedia‎ | GPU


Previous: Multimedia/GPU/OpenVG Index Next: Multimedia/VPU






Vulkan

The i.MX8 supports Vulkan®, which is a graphics and compute API consisting of procedures and functions to specify shader programs, compute kernels, objects, and operations involved in producing high-quality graphical images, specifically color images of three-dimensional objects. Vulkan is also a pipeline with programmable and state-driven fixed-function stages that are invoked by a set of specific drawing operations. You can find more information and official documentation in this reference.

Subgroups

Vulkan 1.1 supports subgroups as a new feature. They enable highly-efficient sharing and manipulation of data between multiple tasks running in parallel on a GPU. Modern heterogeneous hardware like GPUs gains performance by using parallel hardware and exposing a parallel programming model to target this hardware. When a user wants to run N parallel tasks for their algorithm, a GPU would divide this N-sized workload between the compute units of that GPU. Each compute unit of the GPU is then capable of running one or more of these parallel tasks concurrently. In Vulkan, the data that runs on a single compute unit of a GPU is referred to as the local workgroup, and an individual parallel task as an invocation.

Vulkan 1.1 introduces a mechanism to share data between the invocations that run in parallel on a single compute unit. These concurrently running invocations are named the subgroup. This subgroup allows for the sharing of data between a much smaller set of invocations than the local workgroup could, but at a significantly higher performance. While shared memory is only available in compute shaders, sharing data via subgroup operations is allowed in all shader stages via optionally supported stages.

In this tutorial you can find how to use the subgroup functionality of Vulkan 1.1.

Software Development Kit

The Vulkan applications can be developed for Windows, Linux, macOS, and Android.

Windows, Linux, Yocto & macOS

The LunarG SDK provides Vulkan application developers with essential tools to accelerate the development process. There are Windows, Linux, Yocto and macOS versions of LunarG SDK for Vulkan. You can find the official LunarG SDK in this site.

Android

Google provides everything needed to incorporate Vulkan into Android games and other apps where graphics performance is key. You are able to download the API, samples, and documentation from the Android developer website.

Demo Examples

There are some examples on this repository that can be used to check the basics required to understand how to write applications on Vulkan. You can find those examples on the /opt/imx-gpu-sdk/Vulkan/ directory inside the i.MX8 system.

Folder Content

Below you can find a brief description of the examples present inside the Vulkan folder:

  • Triangle: This is the most basic example. Renders a colored triangle using an indexed vertex buffer. Vertex and index data are uploaded to device local memory using so-called "staging buffers". Uses a single pipeline with basic shaders loaded from SPIR-V and a single uniform block for passing matrices that are updated on changing the view. This example is far more explicit than the other examples and is meant to be a starting point for learning Vulkan from the ground up. Much of the code is boilerplate that you'd usually encapsulate in helper functions and classes (which is what the other examples do).
Triangle Output
Triangle Output
  • ComputeParticles: This demo is about an attraction based particle system. A shader storage buffer is used to store particle on which the compute shader does some physics calculations. The buffer is then used by the graphics pipeline for rendering with a gradient texture. It demonstrates the use of memory barriers for synchronizing vertex buffer access between a compute and graphics pipeline.
ComputeParticles Output
ComputeParticles Output
  • DevBatch: This demo is about an early development prototype of a basic quad batch implementation that can be used to implement the native batch for Vulkan. This will allow the UI library to work with Vulkan.
DevBatch Output
DevBatch Output
  • Gears: This is a Vulkan interpretation of glxgears. Procedurally generates separate meshes for each gear, with every mesh having its own uniform buffer object for animation. It also demonstrates how to use different descriptor sets.
Gears Output
Gears Output
  • MeshInstancing: This demo shows the use of instancing for rendering many copies of the same mesh using different attributes and textures. A secondary vertex buffer containing instanced data, stored in device local memory, is used to pass instance data to the shader via vertex attributes with a per-instance step rate. The instance data also contains a texture layer index for having different textures for the instanced meshes.
MeshInstancing Output
MeshInstancing Output
  • Texturing: It shows how to upload a 2D texture into video memory for sampling in a shader. Loads a compressed texture into a host visible staging buffer and copies all mip levels to a device local optimal tiled image for best performance. Also demonstrates the use of combined image samplers. The samplers are detached from the actual texture image and only contain information on how an image is sampled in the shader.
Texturing Output
Texturing Output
  • TexturingArrays: Texture arrays allow storing of multiple images in different layers without any interpolation between the layers. This example demonstrates the use of a 2D texture array with instanced rendering. Each instance samples from a different layer of the texture array.
TexturingArrays Output
TexturingArrays Output
  • TexturingCubeMap: Building on the basic texture loading example, a cubemap texture is loaded into a staging buffer and is copied over to a device local optimal image using buffer to image copies for all of its faces and mip maps. The demo uses two different pipelines (and shader sets) to display the cubemap as a skybox (background) and as a source for reflections.
TexturingCubeMap Output
TexturingCubeMap Output
  • VulkanComputeMandelbrot: This demo calculates and draws the Mandelbrot set using the core Vulkan API.
VulkanComputeMandelbrot Output
VulkanComputeMandelbrot Output
  • VulkanInfo: This demo is a commandline tool to dump Vulkan system information to the console.


Previous: Multimedia/GPU/OpenVG Index Next: Multimedia/VPU