Since we first announced it last year, our Vulkan wrapper KDGpu has been busy evolving to meet customer needs and our own. Our last post announced the public release of v0.1.0, and version 0.5.0 is available today. It's never been easier to interact with modern graphics technologies, enabling you to focus on the big picture instead of hassling with the intricacies and nuances of Vulkan.
The PBR example in the new KDGpu Examples repository.
Wider device support
KDGpu now supports a wider array of devices, such as older versions of Android. For some context, additional features in Vulkan are supported by extensions. If said features become part of the "core" specification, they are automatically included in Vulkan 1.2, 1.3 and so on. In the past, KDGpu required the device to fully support Vulkan 1.2, which limited what devices you could target. In newer KDGpu versions (>0.4.6) it will now run on certain 1.1 devices (like the Meta Quest) as long as the required extensions are supported.
A KDGpu example running natively on an Android device.
We also added native examples for Android, which can be ran straight from Android Studio! There's also better iOS support alongside a native Apple example.
the KDGpu Hello Triangle example running in the iOS simulator
External memory and images support
When writing applications using KDGpu, you will inevitably have to interface with other APIs or libraries that don't support it or maybe not even Vulkan specifically. For example, if you generate an image using Vulkan graphics and then need to pass that to CUDA for further processing. Now with KDGpu it's possible to grab texture and buffer objects and get their external memory handles:
Additionally, we have added methods to adopt existing VkImages as native KDGpu objects to better support libraries like OpenXR.
Easy & fast XR
OpenXR is the leading API used for writing cross-platform VR/AR experiences. Like Vulkan, code directly using OpenXR tends to be verbose and requires a lot of setup. To alleviate this, KDGpu now includes an optional library called KDXr. It wraps OpenXR, and it even easily integrates into KDGpu. It takes care of initialization, has the C++ classes you expect and can make it painless to integrate XR functionality into your application including support for XR compositor layers, head tracking, input handling and haptic feedback.
For example, to set up a projection view you subclass the ProjectionLayer type:
And implement the required methods like renderView() to start rendering into each eye:
voidProjectionLayer::renderView(){ m_fence.wait(); m_fence.reset();// Update the scene data once per frameif(m_currentViewIndex ==0){updateTransformUbo();}// Update the per-view camera matricesupdateViewUbo();auto commandRecorder = m_device->createCommandRecorder();// Set up the render pass using the current color and depth texture views m_opaquePassOptions.colorAttachments[0].view = m_colorSwapchains[m_currentViewIndex].textureViews[m_currentColorImageIndex]; m_opaquePassOptions.depthStencilAttachment.view = m_depthSwapchains[m_currentViewIndex].textureViews[m_currentDepthImageIndex];auto opaquePass = commandRecorder.beginRenderPass(m_opaquePassOptions);// Do the rest of your rendering commands to this pass...
And add this layer to the compositor, in our examples this is abstracted away for you:
// Create a projection layer to render the 3D sceneconst XrProjectionLayerOptions projectionLayerOptions ={.device =&m_device,.queue =&m_queue,.session =&m_session,.colorSwapchainFormat = m_colorSwapchainFormat,.depthSwapchainFormat = m_depthSwapchainFormat,.samples = m_samples.get()};m_projectionLayer =createCompositorLayer<ProjectionLayer>(projectionLayerOptions);m_projectionLayer->setReferenceSpace(m_referenceSpace);
You can view the complete example here. In this new release, we're continuing to work on multiview support! KDXr supports multiview out of the box (see the example layer code) and you can check out the multiview example.
More in-depth examples are now available
The examples sitting in our main repository are no more than small tests, which don't show the true benefits of using KDGpu in large graphical applications. So, in addition to our previous examples, we now have a dedicated KDGpu Examples repository!
Screenshot from our N-Body Compute example.
And more!
There are also small improvements such as being able to request custom extensions and ignore specific validation layer warnings. Check out the changelog on GitHub for a full list of what's been changed.
Let us know what you think about the improvements we've made, and what could be useful for you in the future!
The KDAB Group is a globally recognized provider for software consulting, development and training, specializing in embedded devices and complex cross-platform desktop applications. In addition to being leading experts in Qt, C++ and 3D technologies for over two decades, KDAB provides deep expertise across the stack, including Linux, Rust and modern UI frameworks. With 100+ employees from 20 countries and offices in Sweden, Germany, USA, France and UK, we serve clients around the world.
Our hands-on Modern C++ training courses are designed to quickly familiarize newcomers with the language. They also update professional C++ developers on the latest changes in the language and standard library introduced in recent C++ editions.