Better_Software_Header_MobileBetter_Software_Header_Web

Find what you need - explore our website and developer resources

KDGpu 0.5.0 is here!

Our Vulkan wrapper now has OpenXR integration and more.

The PBR example in the new KDGpu Examples repository.

A KDGpu example running natively on an Android device.

the KDGpu Hello Triangle example running in the iOS simulator

const TextureOptions textureOptions = {
    .type = TextureType::TextureType2D,
    .format = Format::R8G8B8A8_SNORM,
    .extent = { 512, 512, 1 },
    .mipLevels = 1,
    .usage = TextureUsageFlagBits::SampledBit,
    .memoryUsage = MemoryUsage::GpuOnly,
    .externalMemoryHandleType = ExternalMemoryHandleTypeFlagBits::OpaqueFD,
};

Texture t = device.createTexture(textureOptions);
const MemoryHandle externalHandleOrFD = t.externalMemoryHandle();
class ProjectionLayer : public XrProjectionLayer
{
public:
void ProjectionLayer::renderView()
{
    m_fence.wait();
    m_fence.reset();

    // Update the scene data once per frame
    if (m_currentViewIndex == 0) {
        updateTransformUbo();
    }

    // Update the per-view camera matrices
    updateViewUbo();

    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...
// Create a projection layer to render the 3D scene
const 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);

Screenshot from our N-Body Compute example.

About KDAB


JoshuaGoins

Joshua Goins

Software Engineer

Learn Modern C++

Learn more