Better_Software_Header_MobileBetter_Software_Header_Web

Find what you need - explore our website and developer resources

KDGpu v.0.1.0 is released

a Vulkan wrapper to make modern graphics easier

Using KDGpu to render a textured glTF 2 model. KDGpu makes it easy to manage resources for shaders. The glTF parsing was performed using the excellent tinygltf library.

Instanced rendering of the glTF 2 buggy model. Each sub-mesh is drawn using instancing to reduce the number of draw calls and binding operations.

Example showing various styles of text effect using multi-channel signed distance fields.

void HelloTriangle::render()
{
    // m_device is a KDGpu::Device
    auto commandRecorder = m_device.createCommandRecorder();

    // m_opaquePassOptions is a KDGpu::RenderPassCommandRecorderOptions struct that we use to specify the render pass setup
    m_opaquePassOptions.colorAttachments[0].view = m_swapchainViews.at(m_currentSwapchainImageIndex);
    auto opaquePass = commandRecorder.beginRenderPass(m_opaquePassOptions);

    // Get ready to draw
    opaquePass.setPipeline(m_pipeline);
    opaquePass.setVertexBuffer(0, m_buffer);
    opaquePass.setIndexBuffer(m_indexBuffer);
    opaquePass.setBindGroup(0, m_transformBindGroup);

    // Record the draw command
    const DrawIndexedCommand drawCmd = { .indexCount = 3 };
    opaquePass.drawIndexed(drawCmd);

    // End the render pass and finish the command recording
    opaquePass.end();
    m_commandBuffer = commandRecorder.finish();

    // Submit command buffer
    ...
}
struct BufferOptions {
    DeviceSize size;
    BufferUsageFlags usage;
    MemoryUsage memoryUsage;
    SharingMode sharingMode{ SharingMode::Exclusive };
    std::vector queueTypeIndices{};
};
std::array<uint32_t, 3> indexData = { 0, 1, 2 };
const DeviceSize dataByteSize = indexData.size() * sizeof(uint32_t);
const BufferOptions bufferOptions = {
    .size = dataByteSize,
    .usage = BufferUsageFlagBits::IndexBufferBit | BufferUsageFlagBits::TransferDstBit,
    .memoryUsage = MemoryUsage::GpuOnly
};
m_indexBuffer = m_device.createBuffer(bufferOptions);
const BufferUploadOptions uploadOptions = {
    .destinationBuffer = m_indexBuffer,
    .dstStages = PipelineStageFlagBit::VertexAttributeInputBit,
    .dstMask = AccessFlagBit::IndexReadBit,
    .data = indexData.data(),
    .byteSize = dataByteSize
};
m_queue.uploadBufferData(uploadOptions);

About KDAB


SeanHarmer

Sean Harmer

Managing Director KDAB UK