# nvidia-rtx/rtxpt architecture

> Architecture diagram of the GitHub repository nvidia-rtx/rtxpt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nvidia-rtx/rtxpt
- Repository: https://github.com/nvidia-rtx/rtxpt

## Overview

1. **Repository purpose and runtime shape**
   This is a Windows-focused real-time path tracing application/sample. The executable is built from the `Rtxpt` target, and the app loads scenes and assets from `Assets/`. The runtime is a hybrid C++/HLSL renderer built on top of the Donut framework and NVIDIA RTX-related SDKs.

2. **Top-level application boundary**
   `Rtxpt/Sample.cpp`, `Sample.h`, and `SampleCommon/SampleBaseApp.*` form the app-facing entry path. Around that sits a reusable sample framework that handles windowing, command line parsing, local config, capture scripts, splash screen, shader compilation, render targets, and scene loading. This framework is the boundary between platform/runtime concerns and the rendering pipeline.

3. **Core rendering pipeline**
   The project is organized around a path tracing pipeline rather than raster-first rendering. The main flow is: scene/material/light data are prepared on the CPU, uploaded to GPU resources, then evaluated in ray tracing and compute passes, and finally post-processed and tone-mapped for presentation. The core path tracing shaders live under `Rtxpt/Shaders/PathTracer/`.

4. **Pass-oriented GPU architecture**
   Rendering is decomposed into named passes under `Rtxpt/ProcessingPasses`, `Rtxpt/RTXDI`, `Rtxpt/Lighting`, `Rtxpt/ToneMapper`, and related folders. These include accumulation, denoising-guides generation, post-process, tone mapping, light preparation, ray tracing, PDF mip generation, and environment/light baking. The C++ side owns pass orchestration; the HLSL side contains the GPU work.

5. **Scene and asset subsystem**
   Scene content appears to be glTF-centric, with support for animation and a subset of glTF extensions. `SampleCommon/ExtendedScene.*` and `Rtxpt/SampleGame/*` suggest a scene abstraction layer above raw imported content. Scene data is then consumed by path tracing shaders through shared bindings and structured buffers.

6. **Material and lighting model**
   Material handling is split between CPU-side baking/preparation and GPU-side shading definitions. Under `Rtxpt/Materials`, `Rtxpt/Lighting`, and `Rtxpt/Shaders/PathTracer/Materials`, the repo defines the material data model, BSDF/BxDF logic, emissive/analytic/environment lighting, and light sampling helpers. This is where the path tracer’s physically based shading model is encoded.

7. **RTXDI / ReSTIR integration**
   `Rtxpt/RTXDI` contains a substantial subsystem for direct and indirect light sampling using RTXDI. It includes passes for preparing lights, generating initial samples, temporal/spatial resampling, environment-map presampling, and ray tracing support. This subsystem feeds the main path tracer with better light samples and improves real-time convergence.

8. **Denoising and guide-buffer path**
   The repo has explicit support for denoiser integration and path-space decomposition. `Rtxpt/NRD` integrates NVIDIA NRD, while `ProcessingPasses/DenoisingGuidesBaker.*` and `NRD/NrdConfig.*` indicate guide buffers and configuration are produced upstream for denoising. The readme also mentions DLSS-RR and multiple path-space layers, so the denoising path is a first-class part of the frame graph.

9. **Ray tracing acceleration and geometry helpers**
   Geometry and ray tracing support is split across common utilities and specialized acceleration features. `SampleCommon/AccelerationStructureUtil.h` and `RTXDI/RayTracingPass.*` point to TLAS/BLAS management and ray dispatch orchestration. The project also includes OMM support under `Rtxpt/OpacityMicroMap`, enabling faster alpha-tested geometry handling.

10. **Platform and API abstraction**
   The codebase is designed to run on DirectX 12 and Vulkan, with NVRHI and Donut providing much of the abstraction. The readme notes Vulkan is optional and requires extra configuration, while DirectX 12 has optional Agility SDK support. This means rendering features are implemented above a backend abstraction rather than directly against one graphics API.

11. **Shader organization and shared contracts**
   Shader code is centralized under `Rtxpt/Shaders/` and split by domain: bindings, path tracer internals, introductory sample shaders, common libraries, and utility headers. Files like `BindingDataTypes.hlsli`, `ShaderParameters.h`, `SampleConstantBuffer.h`, and `SubInstanceData.h` define the shared contract between CPU and GPU. This contract is critical for architecture diagrams because most systems communicate through these structured bindings.

12. **Tone mapping, post, and output**
   The final image pipeline is separated from the tracer itself. `ToneMapper/` implements tone mapping and color utilities, while `ProcessingPasses/PostProcess.*` handles the finishing steps before presentation. The readme mentions TAA, bloom, and screenshot-oriented reference mode, so presentation is a distinct stage after transport evaluation and denoising.

13. **Interactive UI and debugging tools**
   `SampleUI.*`, `Misc/ShaderDebug.*`, `Misc/ZoomTool.*`, and debug line shaders indicate an interactive inspection layer on top of the renderer. The app exposes controls for performance/quality presets, scene selection, camera movement, and feature toggles. This is not just a rendering engine; it has a substantial live tuning/debug surface.

14. **External dependencies and support tooling**
   External functionality is vendored under `External/` and `Support/`. Important integrations include Donut, NVAPI, NRD, RTXDI, RTXTF, OMM, cxxopts, ImageMagick, and an OptiX denoiser binary. `Support/tests/` provides PS1-based render/compare automation and golden images, showing the repo includes repeatable image-quality validation tooling alongside the renderer.

Main entry points: [`Rtxpt/SampleCommon/SampleCommon.cpp`](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/SampleCommon/SampleCommon.cpp) (Common Runtime), [`Rtxpt/RTXDI/RtxdiPass.cpp`](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/RTXDI/RtxdiPass.cpp) (RTXDI Pass), [`Rtxpt/Shaders/PathTracer/PathTracer.hlsli`](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/Shaders/PathTracer/PathTracer.hlsli) (Path Tracer), [`Rtxpt/SampleCommon/SampleBaseApp.cpp`](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/SampleCommon/SampleBaseApp.cpp) (Base App)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_sample_entry["Sample<br/>app entry<br/>[Sample.cpp]"]
  node_sample_ui["Sample UI<br/>debug ui<br/>[SampleUI.cpp]"]
end

subgraph group_framework["Sample Framework"]
  node_sample_base["Base App<br/>framework core<br/>[SampleBaseApp.cpp]"]
  node_sample_common["Common Runtime<br/>framework services<br/>[SampleCommon.cpp]"]
end

subgraph group_rendering["Rendering Pipeline"]
  node_gpu_sort["GPU Sort<br/>gpu utility<br/>[GPUSort.cpp]"]
  node_accumulation["Accumulation<br/>render pass"]
  node_guides_baker["Guides Baker<br/>render pass"]
  node_rtxdi_pass["RTXDI Pass<br/>light sampling pipeline<br/>[RtxdiPass.cpp]"]
  node_prepare_lights["Prepare Lights<br/>lighting prep"]
  node_ray_tracing["Ray Tracing<br/>rt dispatch<br/>[RayTracingPass.cpp]"]
  node_nrd["NRD<br/>denoiser integration<br/>[NrdIntegration.cpp]"]
  node_materials_baker["Materials Baker<br/>material prep<br/>[MaterialsBaker.cpp]"]
  node_lights_baker["Lights Baker<br/>lighting prep<br/>[LightsBaker.cpp]"]
  node_env_baker["Env Baker<br/>environment prep<br/>[EnvMapBaker.cpp]"]
  node_tone_mapper["Tone Mapper<br/>post process"]
  node_post_process["Post Process<br/>final pass<br/>[PostProcess.cpp]"]
end

subgraph group_scene["Scene & Assets"]
  node_extended_scene["Extended Scene<br/>scene abstraction<br/>[ExtendedScene.cpp]"]
  node_game_scene["Game Scene<br/>scene model<br/>[GameScene.cpp]"]
  node_game_model["Game Model<br/>scene content<br/>[GameModel.cpp]"]
end

subgraph group_shaders["Shader Contracts"]
  node_bindings["Bindings<br/>cpu-gpu contract"]
  node_path_tracer["Path Tracer<br/>shader core<br/>[PathTracer.hlsli]"]
  node_pt_lighting["PT Lighting<br/>shader library"]
  node_pt_materials["PT Materials<br/>shader library<br/>[StandardBSDF.hlsli]"]
end

subgraph group_support["Support & External"]
  node_support_tests["Tests<br/>validation tooling<br/>[run_tests.ps1]"]
  node_external_deps["External Dirs<br/>vendored deps<br/>[CMakeLists.txt]"]
end

node_sample_entry -->|"boots"| node_sample_base
node_sample_base -->|"uses"| node_sample_common
node_sample_base -->|"drives"| node_sample_ui
node_sample_common -->|"loads"| node_extended_scene
node_extended_scene -->|"specializes"| node_game_scene
node_game_scene -->|"contains"| node_game_model
node_sample_common -->|"shares"| node_bindings
node_sample_common -->|"prepares"| node_materials_baker
node_sample_common -->|"prepares"| node_lights_baker
node_sample_common -->|"prepares"| node_env_baker
node_sample_common -->|"orchestrates"| node_ray_tracing
node_ray_tracing -->|"feeds"| node_rtxdi_pass
node_rtxdi_pass -->|"builds"| node_prepare_lights
node_rtxdi_pass -->|"uses"| node_gpu_sort
node_rtxdi_pass -->|"supports"| node_nrd
node_ray_tracing -->|"executes"| node_path_tracer
node_path_tracer -->|"depends on"| node_pt_lighting
node_path_tracer -->|"depends on"| node_pt_materials
node_sample_common -->|"runs"| node_accumulation
node_sample_common -->|"runs"| node_guides_baker
node_accumulation -->|"hands off"| node_tone_mapper
node_tone_mapper -->|"finishes"| node_post_process
node_bindings -->|"contracts"| node_path_tracer
node_bindings -->|"contracts"| node_rtxdi_pass
node_support_tests -->|"validates"| node_sample_entry
node_external_deps -->|"supports"| node_sample_common
node_external_deps -->|"supports"| node_rtxdi_pass

click node_sample_entry "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/Sample.cpp"
click node_sample_base "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/SampleCommon/SampleBaseApp.cpp"
click node_sample_common "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/SampleCommon/SampleCommon.cpp"
click node_extended_scene "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/SampleCommon/ExtendedScene.cpp"
click node_game_scene "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/SampleGame/GameScene.cpp"
click node_game_model "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/SampleGame/GameModel.cpp"
click node_gpu_sort "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/GPUSort/GPUSort.cpp"
click node_accumulation "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/ProcessingPasses/AccumulationPass.cpp"
click node_guides_baker "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/ProcessingPasses/DenoisingGuidesBaker.cpp"
click node_rtxdi_pass "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/RTXDI/RtxdiPass.cpp"
click node_prepare_lights "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/RTXDI/PrepareLightsPass.cpp"
click node_ray_tracing "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/RTXDI/RayTracingPass.cpp"
click node_nrd "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/NRD/NrdIntegration.cpp"
click node_materials_baker "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/Materials/MaterialsBaker.cpp"
click node_lights_baker "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/Lighting/LightsBaker.cpp"
click node_env_baker "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/Lighting/Distant/EnvMapBaker.cpp"
click node_tone_mapper "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/ToneMapper/ToneMappingPasses.cpp"
click node_post_process "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/ProcessingPasses/PostProcess.cpp"
click node_sample_ui "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/SampleUI.cpp"
click node_bindings "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/Shaders/Bindings/BindingDataTypes.hlsli"
click node_path_tracer "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/Shaders/PathTracer/PathTracer.hlsli"
click node_pt_lighting "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/Shaders/PathTracer/Lighting/LightingAlgorithms.hlsli"
click node_pt_materials "https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/Shaders/PathTracer/Rendering/Materials/StandardBSDF.hlsli"
click node_support_tests "https://github.com/nvidia-rtx/rtxpt/blob/main/Support/tests/run_tests.ps1"
click node_external_deps "https://github.com/nvidia-rtx/rtxpt/blob/main/External/CMakeLists.txt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_sample_entry,node_sample_ui toneBlue
class node_sample_base,node_sample_common toneAmber
class node_gpu_sort,node_accumulation,node_guides_baker,node_rtxdi_pass,node_prepare_lights,node_ray_tracing,node_nrd,node_materials_baker,node_lights_baker,node_env_baker,node_tone_mapper,node_post_process toneMint
class node_extended_scene,node_game_scene,node_game_model toneRose
class node_bindings,node_path_tracer,node_pt_lighting,node_pt_materials toneIndigo
class node_support_tests,node_external_deps toneTeal
```

## Components

### Application

Executable entry points and sample variants

- [Sample](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/Sample.cpp): app entry · Main application target and sample bootstrap · `Rtxpt/Sample.cpp`
- [Sample UI](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/SampleUI.cpp): debug ui · Interactive controls and live tuning surface · `Rtxpt/SampleUI.cpp`

### Sample Framework

Windowing, config, capture, scene loading, and runtime services

- [Base App](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/SampleCommon/SampleBaseApp.cpp): framework core · Reusable app shell for runtime setup and orchestration · `Rtxpt/SampleCommon/SampleBaseApp.cpp`
- [Common Runtime](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/SampleCommon/SampleCommon.cpp): framework services · Command line, config, capture, splash, shader compile, render targets, and scene loading · `Rtxpt/SampleCommon/SampleCommon.cpp`

### Rendering Pipeline

GPU passes, lighting, denoising, tone mapping, and acceleration support

- [GPU Sort](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/GPUSort/GPUSort.cpp): gpu utility · Compute sorting utility used by rendering stages · `Rtxpt/GPUSort/GPUSort.cpp`
- [Accumulation](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/ProcessingPasses/AccumulationPass.cpp): render pass · Frame accumulation and history management · `Rtxpt/ProcessingPasses/AccumulationPass.cpp`
- [Guides Baker](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/ProcessingPasses/DenoisingGuidesBaker.cpp): render pass · Produces denoising guide buffers and related data · `Rtxpt/ProcessingPasses/DenoisingGuidesBaker.cpp`
- [RTXDI Pass](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/RTXDI/RtxdiPass.cpp): light sampling pipeline · Orchestrates ReSTIR/RTXDI light sampling flow · `Rtxpt/RTXDI/RtxdiPass.cpp`
- [Prepare Lights](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/RTXDI/PrepareLightsPass.cpp): lighting prep · Builds light data for RTXDI and shading · `Rtxpt/RTXDI/PrepareLightsPass.cpp`
- [Ray Tracing](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/RTXDI/RayTracingPass.cpp): rt dispatch · Ray dispatch and tracing orchestration · `Rtxpt/RTXDI/RayTracingPass.cpp`
- [NRD](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/NRD/NrdIntegration.cpp): denoiser integration · NVIDIA NRD integration and configuration · `Rtxpt/NRD/NrdIntegration.cpp`
- [Materials Baker](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/Materials/MaterialsBaker.cpp): material prep · CPU-side material preparation and baking · `Rtxpt/Materials/MaterialsBaker.cpp`
- [Lights Baker](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/Lighting/LightsBaker.cpp): lighting prep · CPU-side light baking and scene light preparation · `Rtxpt/Lighting/LightsBaker.cpp`
- [Env Baker](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/Lighting/Distant/EnvMapBaker.cpp): environment prep · Environment map preprocessing and importance sampling · `Rtxpt/Lighting/Distant/EnvMapBaker.cpp`
- [Tone Mapper](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/ToneMapper/ToneMappingPasses.cpp): post process · Tone mapping and final image color conversion · `Rtxpt/ToneMapper/ToneMappingPasses.cpp`
- [Post Process](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/ProcessingPasses/PostProcess.cpp): final pass · Final finishing before presentation · `Rtxpt/ProcessingPasses/PostProcess.cpp`

### Scene & Assets

Imported content, game-side scene abstractions, and asset inputs

- [Extended Scene](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/SampleCommon/ExtendedScene.cpp): scene abstraction · Higher-level scene layer above imported content · `Rtxpt/SampleCommon/ExtendedScene.cpp`
- [Game Scene](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/SampleGame/GameScene.cpp): scene model · Sample-specific scene and prop composition · `Rtxpt/SampleGame/GameScene.cpp`
- [Game Model](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/SampleGame/GameModel.cpp): scene content · Geometry and object-side content helpers · `Rtxpt/SampleGame/GameModel.cpp`

### Shader Contracts

Shared CPU/GPU bindings and core shader libraries

- [Bindings](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/Shaders/Bindings/BindingDataTypes.hlsli): cpu-gpu contract · Shared structured bindings and shader parameter contracts · `Rtxpt/Shaders/Bindings/BindingDataTypes.hlsli`
- [Path Tracer](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/Shaders/PathTracer/PathTracer.hlsli): shader core · Core path tracing shader logic and shared types · `Rtxpt/Shaders/PathTracer/PathTracer.hlsli`
- [PT Lighting](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/Shaders/PathTracer/Lighting/LightingAlgorithms.hlsli): shader library · Light sampling, shaping, and lighting algorithms · `Rtxpt/Shaders/PathTracer/Lighting/LightingAlgorithms.hlsli`
- [PT Materials](https://github.com/nvidia-rtx/rtxpt/blob/main/Rtxpt/Shaders/PathTracer/Rendering/Materials/StandardBSDF.hlsli): shader library · BSDF and material evaluation helpers · `Rtxpt/Shaders/PathTracer/Rendering/Materials/StandardBSDF.hlsli`

### Support & External

Bundled tooling, validation scripts, and vendored dependencies

- [Tests](https://github.com/nvidia-rtx/rtxpt/blob/main/Support/tests/run_tests.ps1): validation tooling · Render/compare scripts and golden images · `Support/tests/run_tests.ps1`
- [External Dirs](https://github.com/nvidia-rtx/rtxpt/blob/main/External/CMakeLists.txt): vendored deps · Bundled third-party SDKs and tools · `External/CMakeLists.txt`

## Connections

- Sample → Base App: boots · Application enters the reusable base app
- Base App → Common Runtime: uses · Base app delegates shared runtime services
- Base App → Sample UI: drives · Runtime exposes interactive controls and debugging UI
- Common Runtime → Extended Scene: loads · Common runtime builds the higher-level scene abstraction
- Extended Scene → Game Scene: specializes · Game scene adds sample-specific composition
- Game Scene → Game Model: contains · Scene is assembled from game models and props
- Common Runtime → Bindings: shares · Framework and shaders exchange structured contracts
- Common Runtime → Materials Baker: prepares · Runtime bakes material data for GPU use
- Common Runtime → Lights Baker: prepares · Runtime bakes light data for GPU use
- Common Runtime → Env Baker: prepares · Runtime preprocesses environment lighting
- Common Runtime → Ray Tracing: orchestrates · Runtime schedules ray tracing work
- Ray Tracing → RTXDI Pass: feeds · Tracing is paired with RTXDI light sampling
- RTXDI Pass → Prepare Lights: builds · RTXDI begins with light preparation
- RTXDI Pass → GPU Sort: uses · Sampling pipeline relies on GPU sorting
- RTXDI Pass → NRD: supports · Denoiser integration consumes RTXDI-produced data
- Ray Tracing → Path Tracer: executes · Tracing work is implemented in path tracing shaders
- Path Tracer → PT Lighting: depends on · Core path tracing calls into lighting helpers
- Path Tracer → PT Materials: depends on · Core path tracing evaluates material models
- Common Runtime → Accumulation: runs · Frame accumulation is part of the frame graph
- Common Runtime → Guides Baker: runs · Guide buffers are generated upstream for denoising
- Accumulation → Tone Mapper: hands off · Accumulated output is post-processed for presentation
- Tone Mapper → Post Process: finishes · Tone mapping feeds the final presentation pass
- Bindings → Path Tracer: contracts · Shared bindings define the shader-side interface
- Bindings → RTXDI Pass: contracts · RTXDI passes use the same CPU/GPU parameter schema
- Tests → Sample: validates · Scripts render and compare the application output
- External Dirs → Common Runtime: supports · Vendored SDKs and tools underpin runtime services
- External Dirs → RTXDI Pass: supports · RTXDI and related integrations are provided externally
