# nvidiagameworks/nri architecture

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

- Interactive diagram: https://gitdiagram.com/nvidiagameworks/nri
- Repository: https://github.com/nvidiagameworks/nri

## Overview

##### Main Components

a. Core Layer:
- Base interfaces from Include/NRI.h
- Core functionality components (Device, CommandBuffer, etc.)

b. Backend Implementations (arrange as parallel modules):
- Vulkan Backend (Source/VK)
- DirectX 12 Backend (Source/D3D12)
- DirectX 11 Backend (Source/D3D11)
- None/Dummy Backend (Source/NONE)

c. Extensions Layer (arrange as a top layer):
- Device Creation (NRIDeviceCreation)
- Helper Interface (NRIHelper)
- Low Latency Support (NRILowLatency)
- Mesh Shader Support (NRIMeshShader)
- Ray Tracing Support (NRIRayTracing)
- Resource Allocator (NRIResourceAllocator)
- Streamer (NRIStreamer)
- SwapChain Support (NRISwapChain)

d. Validation Layer:
- As a wrapper around the core components
- Validation implementations from Source/Validation

##### Relationships and Interactions

- Extension interfaces connecting to the core
- Backend implementations implementing the core interface
- Validation layer wrapping around core components
- Data flow between components (command submission, resource management)

##### Important Elements to Highlight

a. Core Abstractions:
- Device
- CommandBuffer/Queue
- Resources (Buffer, Texture)
- Pipeline Management
- Memory Management
- Descriptor Management

b. Cross-Platform Support:
- Windows
- Linux
- MacOS (through MoltenVK)
- Android

##### Implementation Details

- Shared components (Source/Shared)
- Extension points
- Validation layer coverage
- Memory management flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef extension fill:#e67e22,stroke:#d35400,color:white
    classDef validation fill:#e74c3c,stroke:#c0392b,color:white
    classDef shared fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Extensions Layer
    subgraph Extensions
        DeviceCreation["Device Creation"]:::extension
        Helper["Helper Interface"]:::extension
        LowLatency["Low Latency"]:::extension
        MeshShader["Mesh Shader"]:::extension
        RayTracing["Ray Tracing"]:::extension
        ResourceAlloc["Resource Allocator"]:::extension
        Streamer["Streamer"]:::extension
        SwapChain["SwapChain"]:::extension
    end

    %% Core Layer
    subgraph Core
        CoreInterface["Core Interface"]:::core
        CoreDesc["Core Descriptors"]:::core
        Device["Device Base"]:::core
        MemoryMgmt["Memory Management"]:::core
        DataUpload["Data Upload Helper"]:::core
        StreamerImpl["Streamer Implementation"]:::core
    end

    %% Backend Layer
    subgraph Backends
        VK["Vulkan Backend"]:::backend
        DX12["DirectX 12 Backend"]:::backend
        DX11["DirectX 11 Backend"]:::backend
        NONE["None/Dummy Backend"]:::backend
    end

    %% Validation Layer
    ValidationLayer["Validation Layer"]:::validation

    %% Backend Resource Allocators
    D3D12Alloc["D3D12 Resource Allocator"]:::backend
    VKAlloc["Vulkan Resource Allocator"]:::backend

    %% Relationships
    Extensions --> Core
    Core --> Backends
    ValidationLayer -.-> Core
    DX12 --> D3D12Alloc
    VK --> VKAlloc

    %% Click Events
    click CoreInterface "https://github.com/NVIDIAGameWorks/NRI/blob/main/Include/NRI.h"
    click CoreDesc "https://github.com/NVIDIAGameWorks/NRI/blob/main/Include/NRIDescs.h"
    click VK "https://github.com/NVIDIAGameWorks/NRI/tree/main/Source/VK/"
    click DX12 "https://github.com/NVIDIAGameWorks/NRI/tree/main/Source/D3D12/"
    click DX11 "https://github.com/NVIDIAGameWorks/NRI/tree/main/Source/D3D11/"
    click NONE "https://github.com/NVIDIAGameWorks/NRI/tree/main/Source/NONE/"
    click DeviceCreation "https://github.com/NVIDIAGameWorks/NRI/blob/main/Include/Extensions/NRIDeviceCreation.h"
    click Helper "https://github.com/NVIDIAGameWorks/NRI/blob/main/Include/Extensions/NRIHelper.h"
    click LowLatency "https://github.com/NVIDIAGameWorks/NRI/blob/main/Include/Extensions/NRILowLatency.h"
    click MeshShader "https://github.com/NVIDIAGameWorks/NRI/blob/main/Include/Extensions/NRIMeshShader.h"
    click RayTracing "https://github.com/NVIDIAGameWorks/NRI/blob/main/Include/Extensions/NRIRayTracing.h"
    click ResourceAlloc "https://github.com/NVIDIAGameWorks/NRI/blob/main/Include/Extensions/NRIResourceAllocator.h"
    click Streamer "https://github.com/NVIDIAGameWorks/NRI/blob/main/Include/Extensions/NRIStreamer.h"
    click SwapChain "https://github.com/NVIDIAGameWorks/NRI/blob/main/Include/Extensions/NRISwapChain.h"
    click ValidationLayer "https://github.com/NVIDIAGameWorks/NRI/tree/main/Source/Validation/"
    click Device "https://github.com/NVIDIAGameWorks/NRI/blob/main/Source/Shared/DeviceBase.h"
    click MemoryMgmt "https://github.com/NVIDIAGameWorks/NRI/blob/main/Source/Shared/HelperDeviceMemoryAllocator.h"
    click DataUpload "https://github.com/NVIDIAGameWorks/NRI/blob/main/Source/Shared/HelperDataUpload.h"
    click StreamerImpl "https://github.com/NVIDIAGameWorks/NRI/blob/main/Source/Shared/Streamer.h"
    click D3D12Alloc "https://github.com/NVIDIAGameWorks/NRI/blob/main/Source/D3D12/ResourceAllocatorD3D12.hpp"
    click VKAlloc "https://github.com/NVIDIAGameWorks/NRI/blob/main/Source/VK/ResourceAllocatorVK.hpp"
```
