Skip to content

KDGpu API Overview

Introduction

KDGpu is a modern, type-safe C++ wrapper around the Vulkan graphics API. It provides a simplified, high-level interface while maintaining complete control over the underlying Vulkan resources. KDGpu's design philosophy focuses on:

  • Type Safety: Strong typing through handles and enums
  • Resource Management: Handle-based ownership model with automatic resource cleanup
  • Simplicity: Reduced boilerplate compared to raw Vulkan
  • Performance: Zero-cost abstractions over Vulkan
  • Familiarity: API structure closely mirrors Vulkan concepts

API Architecture

The KDGpu API is organized into several logical groups:

Core Instance & Device Management

GPU Resources

Pipelines & Shaders

Descriptors & Bindings

Command Recording

Synchronization

Presentation

Ray Tracing (Extensions)

Query Operations

Resource Ownership Model

KDGpu uses a handle-based resource management system. See KDGpu Handle-Based Ownership Model for details.

Key principles:

  • Frontend KDGpu resources (e.g. Texture, Buffer) are wrappers around Vulkan resources
  • Frontend KDGpu resources use handles to safely reference underlying Vulkan wrapped resources
  • Resources lifetime is RAII-based, automatically cleaned up when owning objects are destroyed
  • Move semantics: Resources can be moved but not copied
  • Reference invalidation: Handles become invalid when resources are destroyed

Basic Initialization Flow

Here's a minimal example showing how to initialize KDGpu for rendering:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
    // Typical initialization flow:
    KDGpu::VulkanGraphicsApi vulkanGraphisApi;
    KDGpu::Instance instance = vulkanGraphisApi.createInstance(KDGpu::InstanceOptions{ /* ... */ });
    KDGpu::Adapter *adapter = instance.selectAdapter(KDGpu::AdapterDeviceType::Default); // Select GPU
    KDGpu::Device device = adapter->createDevice(KDGpu::DeviceOptions{
            .requestedFeatures = adapter->features(),
    });
    // Device ready to create resources and submit work
    KDGpu::Buffer buffer = device.createBuffer(KDGpu::BufferOptions{
            .usage = KDGpu::BufferUsageFlagBits::UniformBufferBit,
            .memoryUsage = KDGpu::MemoryUsage::GpuOnly,
    });

Filename: kdgpu_doc_snippets.cpp

Typical Usage Pattern

1
2
3
4
5
6
7
    // KDGpu API consists of:
    // 1. Instance - entry point, enumerates adapters
    // 2. Adapter - represents physical GPU
    // 3. Device - logical GPU handle, creates resources
    // 4. Resources - buffers, textures, pipelines, etc.
    // 5. Command recording - record GPU work
    // 6. Synchronization - fences, semaphores for CPU-GPU and GPU-GPU sync

Filename: kdgpu_doc_snippets.cpp

See Also


Updated on 2026-03-14 at 00:03:56 +0000