# milkru/vulkanizer architecture

> Architecture diagram of the GitHub repository milkru/vulkanizer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/milkru/vulkanizer
- Repository: https://github.com/milkru/vulkanizer

## Overview

##### Main Components
- Rendering Engine Core:
- Includes core graphics routines and resource management (see files in src/core such as device, buffer, pipeline, swapchain, shader, texture, frame_pacing, pass, and query).
- Responsible for interfacing with Vulkan and managing GPU resources.
- Window and Input Management:
- Handled via GLFW (with its related integration code in src/window.cpp/h and camera.cpp/h).
- Manages the creation of the window and handles user input and camera movement.
- Shader and GPU Pipeline:
- Located in src/shaders. Contains shader code (vertex, fragment, compute, mesh/task shaders) essential for defining the rendering pipeline.
- Mesh and Geometry Handling:
- Implements multiple mesh rendering, LOD system, and culling (occlusion, frustum).
- GUI Overlay:
- GUI implementation for performance and settings windows (src/gui.cpp/h).
- Uses a custom Vulkan backend for Dear ImGui.
- Profiling:
- Contains both CPU (via easy_profiler integration) and GPU profiling capabilities (src/gpu_profiler.cpp/h).
- Third Party Libraries:
- The 3rdparty directory contains integrated libraries such as volk (for Vulkan meta loading), VulkanMemoryAllocator, glfw, glm, imgui, SPIRV-Reflect, and others that enhance the engine’s capabilities.
- Build and Configuration:
- Build files like CMakeLists.txt and configuration files (e.g., .gitignore) indicate usage of CMake, making it easier to manage dependencies and builds.

##### Relationships and Interactions
- The Main Application (src/main.cpp) acts as the orchestrator, initializing the window, setting up the Vulkan device (using the functions encapsulated in core/device.cpp/h) and linking all other subsystems.
- The Window Module (using GLFW) is tightly coupled with the rendering core to handle swap chain recreation, event processing, and camera updates.
- The Core Rendering Module interacts with:
- Shader management (loading and compiling shaders from src/shaders).
- Memory management, using VulkanMemoryAllocator for GPU resource allocation.
- The Mesh & Geometry subsystem:
- Imports mesh data using fast_obj and refines it via meshoptimizer.
- Implements LOD and culling strategies before passing the data to the rendering pipeline.
- The GUI Module interacts with the rendering core by drawing overlay menus and performance stats using ImGui with a custom Vulkan backend.
- Profiling components (both CPU and GPU) hook into various stages of the rendering loop, logging performance statistics.

##### Architectural Patterns and Principles
- Modular Design: Each component (core rendering, windowing, GUI, mesh processing) is separated into clearly defined modules.
- Abstraction Layers: The core directory encapsulates low-level Vulkan operations, while higher-level modules (like window and GUI) build on top of these abstractions.
- Integration of Third Party Libraries: The design leverages multiple specialized libraries to simplify tasks (e.g., memory allocation, shader reflection), emphasizing reusability.
- Performance and Real-Time Constraints: Specialized profiling and culling techniques highlight the engine’s emphasis on throughput and efficiency.

##### Technologies and Frameworks to Highlight
- Vulkan 1.3 for the rendering backend.
- GLFW for window and input handling.
- VulkanMemoryAllocator, SPIRV-Reflect, volk, and Vulkan’s dynamic rendering features.
- CUDA-like mesh and vertex processing pipelines (mesh shaders, task shaders) with traditional rendering support.
- Integration with easy_profiler and GPU query timing for performance analysis.
- Dear ImGui for in-engine GUI support.

##### Essential Elements
- Clear labels for each module (e.g., Application/Main, Window Management, Rendering Engine Core, Shader Pipeline, Mesh Processing, GUI, Profiling, Third Party Libraries).

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Main/Application"]
    Core["Rendering Engine Core (Device, Buffer, Pipeline, Swapchain, Shader, Texture, FramePacing, Pass, Query)"]
    
    subgraph "Window & Input Management"
        WI1["Window.cpp"]
        WI2["Window.h"]
        WI3["Camera.cpp"]
        WI4["Camera.h"]
    end

    ShaderPipeline["Shader & GPU Pipeline"]
    
    subgraph "Mesh & Geometry Handling"
        MG1["Geometry.cpp/h"]
        MG2["Draw.cpp/h"]
    end

    subgraph "GUI Overlay"
        GUI1["GUI.cpp"]
        GUI2["GUI.h"]
    end

    subgraph Profiling
        P1["GPU_Profiler.cpp"]
        P2["GPU_Profiler.h"]
    end

    ThirdParty["Third Party Libraries (volk, VulkanMemoryAllocator, GLFW, glm, SPIRV-Reflect, imgui, easy_profiler, fast_obj, meshoptimizer)"]
    
    subgraph "Build & Configuration"
        B1["CMakeLists.txt"]
        B2[".gitignore"]
    end

    %% Connections
    A -->|"initialize"| WI1
    A -->|"sets_up"| Core
    WI1 -->|"handles_events"| Core
    Core -->|"loads_shaders"| ShaderPipeline
    Core -->|"renders_meshes"| MG1
    MG1 -->|"uses"| ThirdParty
    Core -->|"integrates_with"| GUI1
    P1 -->|"profiles"| Core
    P1 -->|"displays_stats"| GUI1
    Core -->|"utilizes"| ThirdParty
    WI1 -->|"uses"| ThirdParty
    A -->|"builds_via"| B1
    GUI1 -->|"uses"| ThirdParty

    %% Click Events
    click Core "https://github.com/milkru/vulkanizer/tree/main/src/core"
    click WI1 "https://github.com/milkru/vulkanizer/blob/main/src/window.cpp"
    click WI2 "https://github.com/milkru/vulkanizer/blob/main/src/window.h"
    click WI3 "https://github.com/milkru/vulkanizer/blob/main/src/camera.cpp"
    click WI4 "https://github.com/milkru/vulkanizer/blob/main/src/camera.h"
    click ShaderPipeline "https://github.com/milkru/vulkanizer/tree/main/src/shaders"
    click MG1 "https://github.com/milkru/vulkanizer/blob/main/src/geometry.cpp"
    click MG2 "https://github.com/milkru/vulkanizer/blob/main/src/draw.cpp"
    click GUI1 "https://github.com/milkru/vulkanizer/blob/main/src/gui.cpp"
    click GUI2 "https://github.com/milkru/vulkanizer/blob/main/src/gui.h"
    click P1 "https://github.com/milkru/vulkanizer/blob/main/src/gpu_profiler.cpp"
    click P2 "https://github.com/milkru/vulkanizer/blob/main/src/gpu_profiler.h"
    click ThirdParty "https://github.com/milkru/vulkanizer/tree/main/3rdparty"
    click B1 "https://github.com/milkru/vulkanizer/blob/main/CMakeLists.txt"
    click B2 "https://github.com/milkru/vulkanizer/blob/main/.gitignore"

    %% Styles
    classDef app fill:#a2d5f2,stroke:#000,stroke-width:2px;
    classDef core fill:#f2a2a2,stroke:#000,stroke-width:2px;
    classDef window fill:#d5f2a2,stroke:#000,stroke-width:2px;
    classDef shader fill:#f2d5a2,stroke:#000,stroke-width:2px;
    classDef mesh fill:#a2f2d5,stroke:#000,stroke-width:2px;
    classDef gui fill:#d5a2f2,stroke:#000,stroke-width:2px;
    classDef profiling fill:#f2a2d5,stroke:#000,stroke-width:2px;
    classDef third fill:#d5d5d5,stroke:#000,stroke-width:2px;
    classDef build fill:#a2a2f2,stroke:#000,stroke-width:2px;

    class A app;
    class Core core;
    class WI1,WI2,WI3,WI4 window;
    class ShaderPipeline shader;
    class MG1,MG2 mesh;
    class GUI1,GUI2 gui;
    class P1,P2 profiling;
    class ThirdParty third;
    class B1,B2 build;
```
