How nvidia-rtx/rtxpt works
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: SampleCommon.cpp Common Runtime · RtxdiPass.cpp RTXDI Pass · PathTracer.hlsli Path Tracer · SampleBaseApp.cpp Base App
Components 25
Application
Executable entry points and sample variants
Sample Framework
Windowing, config, capture, scene loading, and runtime services
- Base App · Reusable app shell for runtime setup and orchestration
Rtxpt/SampleCommon/SampleBaseApp.cpp - Common Runtime · 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 · Compute sorting utility used by rendering stages
Rtxpt/GPUSort/GPUSort.cpp - Accumulation · Frame accumulation and history management
Rtxpt/ProcessingPasses/AccumulationPass.cpp - Guides Baker · Produces denoising guide buffers and related data
Rtxpt/ProcessingPasses/DenoisingGuidesBaker.cpp - RTXDI Pass · Orchestrates ReSTIR/RTXDI light sampling flow
Rtxpt/RTXDI/RtxdiPass.cpp - Prepare Lights · Builds light data for RTXDI and shading
Rtxpt/RTXDI/PrepareLightsPass.cpp - Ray Tracing · Ray dispatch and tracing orchestration
Rtxpt/RTXDI/RayTracingPass.cpp - NRD · NVIDIA NRD integration and configuration
Rtxpt/NRD/NrdIntegration.cpp - Materials Baker · CPU-side material preparation and baking
Rtxpt/Materials/MaterialsBaker.cpp - Lights Baker · CPU-side light baking and scene light preparation
Rtxpt/Lighting/LightsBaker.cpp - Env Baker · Environment map preprocessing and importance sampling
Rtxpt/Lighting/Distant/EnvMapBaker.cpp - Tone Mapper · Tone mapping and final image color conversion
Rtxpt/ToneMapper/ToneMappingPasses.cpp - Post Process · Final finishing before presentation
Rtxpt/ProcessingPasses/PostProcess.cpp
Scene & Assets
Imported content, game-side scene abstractions, and asset inputs
- Extended Scene · Higher-level scene layer above imported content
Rtxpt/SampleCommon/ExtendedScene.cpp - Game Scene · Sample-specific scene and prop composition
Rtxpt/SampleGame/GameScene.cpp - Game Model · Geometry and object-side content helpers
Rtxpt/SampleGame/GameModel.cpp
Shader Contracts
Shared CPU/GPU bindings and core shader libraries
- Bindings · Shared structured bindings and shader parameter contracts
Rtxpt/Shaders/Bindings/BindingDataTypes.hlsli - Path Tracer · Core path tracing shader logic and shared types
Rtxpt/Shaders/PathTracer/PathTracer.hlsli - PT Lighting · Light sampling, shaping, and lighting algorithms
Rtxpt/Shaders/PathTracer/Lighting/LightingAlgorithms.hlsli - PT Materials · BSDF and material evaluation helpers
Rtxpt/Shaders/PathTracer/Rendering/Materials/StandardBSDF.hlsli
Support & External
Bundled tooling, validation scripts, and vendored dependencies
- Tests · Render/compare scripts and golden images
Support/tests/run_tests.ps1 - External Dirs · Bundled third-party SDKs and tools
External/CMakeLists.txt
Connections 27
- 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