# maximebl/dx12_experiments architecture

> Architecture diagram of the GitHub repository maximebl/dx12_experiments, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/maximebl/dx12_experiments
- Repository: https://github.com/maximebl/dx12_experiments

## Overview

##### Main Components Identification
The system should be divided into these primary components:

a) Core Engine Layer
- Graphics Pipeline (DirectX12)
- Memory Management
- Resource Management
- Multi-threading System

b) Rendering Systems
- Deferred Renderer
- Image-Based Lighting
- Particle System
- Shadow Systems
- Post-Processing Pipeline

c) Asset Management
- Model Loading (via Assimp)
- Texture Management
- Shader Management

**[Main Application Entry] --> [UI Context (ImGui)]**

**[Resource Management System]**
- [Descriptor Heap Manager]
- [GPU Memory Manager]

**[Rendering Pipeline]**
- [Deferred Renderer]
- [Image-Based Lighting]
- [Particle System]

**[DirectX12 Interface]**
**[GPU Command Queue Management]**
**[Memory Allocators]**

##### Component Relationships

**[GPU Particle Simulation] --> [Indirect Execution] --> [Frustum Culling] --> [Billboard Rendering]**

**[Image-Based Lighting]**
- [BRDF LUT Generation]
- [Irradiance Map Generation]
- [Specular Map Generation]

**[Shadow Management]**
- [Spot Light Shadows (Multi-threaded)]
- [Point Light Shadows (Geometry Shader)]

##### Technical Details

- Triple buffering synchronization points
- Descriptor heap staging system flow
- Hot reloading mechanism
- Profiler integration points
- Memory allocation strategy

##### Implementation Notes

- Use standardized UML notation where applicable
- Notes for critical synchronization points
- Performance-critical paths
- Areas where hot reloading is supported

##### Optimization Flows

- GPU-driven particle system pipeline
- Image-based lighting pre-computation
- Deferred rendering passes

- The GPU-driven nature of the particle system
- The sophisticated lighting model with PBR
- The multi-threaded shadow mapping system
- The descriptor heap management system

Remember to maintain a balance between showing the high-level architecture while including enough detail to understand the sophisticated graphics pipeline implementation.

This system design should clearly show how the engine manages to handle complex features like PBR rendering, GPU particle systems, and image-based lighting while maintaining performance through proper resource management and multi-threading.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Main Layers
    subgraph Application
        MainApp[Main Application Entry]
        UI[UI System]:::ui
    end

    subgraph Engine
        subgraph ResourceManagement
            ResourceMgr[Resource Management System]
            DescHeap[Descriptor Heap Manager]
            GPUMemMgr[GPU Memory Manager]
        end

        subgraph RenderingPipeline
            DeferredRender[Deferred Renderer]
            IBL[Image-Based Lighting]:::ibl
            ParticleSystem[Particle System]:::particles
            ShadowSystem[Shadow System]:::shadows
            PostProcess[Post-Processing]:::postprocess
        end

        subgraph AssetManagement
            ModelLoader[Model/Mesh System]:::mesh
            TextureMgr[Texture Management]
            ShaderMgr[Shader Management]:::shader
            AssetLoader[Asset Loading]:::assimp
        end
    end

    subgraph LowLevel
        DX12Core[DirectX12 Core Interface]:::dx12
        GPUTimer[GPU Performance Monitor]:::gputimer
        CmdQueue[Command Queue Management]
        MemAlloc[Memory Allocators]
        Camera[Camera System]:::camera
    end

    %% Relationships
    MainApp --> UI
    MainApp --> DeferredRender
    
    ResourceMgr --> DescHeap
    ResourceMgr --> GPUMemMgr
    
    DeferredRender --> IBL
    DeferredRender --> ParticleSystem
    DeferredRender --> ShadowSystem
    DeferredRender --> PostProcess
    
    IBL --> DX12Core
    ParticleSystem --> DX12Core
    ShadowSystem --> DX12Core
    PostProcess --> DX12Core
    
    ModelLoader --> AssetLoader
    TextureMgr --> AssetLoader
    ShaderMgr --> DX12Core
    
    DX12Core --> CmdQueue
    DX12Core --> MemAlloc
    DX12Core --> GPUTimer

    %% Click Events
    click DX12Core "https://github.com/maximebl/dx12_experiments/blob/main/common/gpu_interface.h"
    click GPUTimer "https://github.com/maximebl/dx12_experiments/blob/main/common/gpu_timer.h"
    click ParticleSystem "https://github.com/maximebl/dx12_experiments/blob/main/particles/particles_graphics.h"
    click ShaderMgr "https://github.com/maximebl/dx12_experiments/tree/main/particles/shaders"
    click ModelLoader "https://github.com/maximebl/dx12_experiments/blob/main/common/mesh.h"
    click AssetLoader "https://github.com/maximebl/dx12_experiments/tree/main/dependencies/assimp"
    click UI "https://github.com/maximebl/dx12_experiments/blob/main/common/imgui_helpers.h"
    click Camera "https://github.com/maximebl/dx12_experiments/blob/main/common/camera.h"
    click IBL "https://github.com/maximebl/dx12_experiments/blob/main/particles/shaders/diffuse_irradiance_map.hlsl"
    click ShadowSystem "https://github.com/maximebl/dx12_experiments/blob/main/particles/shaders/shadow_pass.hlsl"
    click PostProcess "https://github.com/maximebl/dx12_experiments/blob/main/particles/shaders/reinhard_tonemapping.hlsl"

    %% Styles
    classDef dx12 fill:#2374ab
    classDef particles fill:#2a9d8f
    classDef shader fill:#e9c46a
    classDef mesh fill:#f4a261
    classDef assimp fill:#e76f51
    classDef ui fill:#8338ec
    classDef camera fill:#3a86ff
    classDef gputimer fill:#ff006e
    classDef ibl fill:#38b000
    classDef shadows fill:#9d4edd
    classDef postprocess fill:#ff7900

    %% Legend
    subgraph Legend
        L1[DirectX12 Core]:::dx12
        L2[Particle System]:::particles
        L3[Shader Management]:::shader
        L4[Mesh System]:::mesh
        L5[Asset Loading]:::assimp
        L6[UI System]:::ui
        L7[Camera]:::camera
        L8[GPU Timer]:::gputimer
        L9[Image-Based Lighting]:::ibl
        L10[Shadows]:::shadows
        L11[Post-Processing]:::postprocess
    end
```
