Skip to content

Commit 274141a

Browse files
committed
ReSTIR PT
1 parent 300f9e5 commit 274141a

228 files changed

Lines changed: 14010 additions & 5484 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
[submodule "NRD"]
55
path = External/NRD
66
url = https://github.com/NVIDIA-RTX/NRD.git
7-
[submodule "DLSS"]
8-
path = External/DLSS
9-
url = https://github.com/NVIDIA/DLSS.git
107
[submodule "rtxdi-runtime"]
118
path = Libraries/Rtxdi
12-
url = https://github.com/NVIDIA-RTX/RTXDI-Library.git
9+
url = https://github.com/NVIDIA-RTX/RTXDI-Library
1310
[submodule "thirdparty/cxxopts"]
1411
path = External/cxxopts
1512
url = https://github.com/jarro2783/cxxopts.git
1613
[submodule "Assets/Media"]
1714
path = Assets/Media
18-
url = https://github.com/NVIDIA-RTX/RTXDI-Assets.git
15+
url = https://github.com/NVIDIA-RTX/RTXDI-Assets
16+
[submodule "External/NVAPI"]
17+
path = External/NVAPI
18+
url = https://github.com/NVIDIA/nvapi.git

CMakeLists.txt

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10)
22

33
project(RTXDI)
44

5-
set(CMAKE_CXX_STANDARD 17)
5+
set(CMAKE_CXX_STANDARD 20)
66
set(CMAKE_CXX_STANDARD_REQUIRED ON)
77
set(CMAKE_CXX_EXTENSIONS ON)
88

@@ -37,6 +37,12 @@ option(DONUT_WITH_DX11 "" OFF)
3737
option(DONUT_WITH_VULKAN "" ON)
3838
option(DONUT_WITH_LZ4 "" OFF)
3939
option(DONUT_WITH_MINIZ "" OFF)
40+
option(DONUT_WITH_DLSS "" ON)
41+
42+
# Setup NVAPI support
43+
option(NVRHI_WITH_NVAPI "Include NVAPI support (requires NVAPI SDK)" ON)
44+
set(NVAPI_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/External/NVAPI/" CACHE STRING "Path to NVAPI include headers/shaders" )
45+
set(NVAPI_LIBRARY "${CMAKE_CURRENT_SOURCE_DIR}/External/NVAPI/amd64/nvapi64.lib" CACHE STRING "Path to NVAPI .lib file")
4046

4147
# Helper to download and unzip a package from a URL
4248
# Uses a zero-length file to identify the version of the package
@@ -60,20 +66,20 @@ endfunction()
6066

6167
# Download DXC
6268
if (WIN32)
63-
CheckAndDownloadPackage("DXC" "v1.7.2212.1" ${CMAKE_CURRENT_SOURCE_DIR}/External/dxc https://github.com/microsoft/DirectXShaderCompiler/releases/download/v1.7.2212.1/dxc_2023_03_01.zip)
64-
set(REDIST_DXC "${CMAKE_CURRENT_SOURCE_DIR}/External/dxc/bin/x64/dxc.exe")
69+
CheckAndDownloadPackage("DXC" "v1.8.2505.1" ${CMAKE_CURRENT_SOURCE_DIR}/External/dxc https://github.com/microsoft/DirectXShaderCompiler/releases/download/v1.8.2505.1/dxc_2025_07_14.zip)
70+
set(SHADERMAKE_DXC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/External/dxc/bin/x64/dxc.exe")
6571
else()
66-
CheckAndDownloadPackage("DXC" "v1.7.2212.1" ${CMAKE_CURRENT_SOURCE_DIR}/External/dxc https://github.com/microsoft/DirectXShaderCompiler/releases/download/v1.7.2212.1/linux_dxc_2023_03_01.x86_64.tar.gz)
72+
CheckAndDownloadPackage("DXC" "v1.8.2505.1" ${CMAKE_CURRENT_SOURCE_DIR}/External/dxc https://github.com/microsoft/DirectXShaderCompiler/releases/download/v1.8.2505.1/linux_dxc_2025_07_14.x86_64.tar.gz)
6773
# Add execute permissions
6874
file(CHMOD ${CMAKE_CURRENT_SOURCE_DIR}/External/dxc/bin/dxc PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
69-
set(REDIST_DXC "${CMAKE_CURRENT_SOURCE_DIR}/External/dxc/bin/dxc")
75+
set(SHADERMAKE_DXC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/External/dxc/bin/dxc")
7076
endif()
71-
if (EXISTS "${REDIST_DXC}")
77+
if (EXISTS "${SHADERMAKE_DXC_PATH}")
7278
if (WIN32 AND NOT DXC_PATH)
73-
set(DXC_PATH "${REDIST_DXC}" CACHE STRING "Path to DirectX Shader Compiler for DXIL output")
79+
set(DXC_PATH "${SHADERMAKE_DXC_PATH}" CACHE STRING "Path to DirectX Shader Compiler for DXIL output")
7480
endif()
7581
if (NOT DXC_SPIRV_PATH)
76-
set(DXC_SPIRV_PATH "${REDIST_DXC}" CACHE STRING "Path to DirectX Shader Compiler for SPIR-V output")
82+
set(DXC_SPIRV_PATH "${SHADERMAKE_DXC_PATH}" CACHE STRING "Path to DirectX Shader Compiler for SPIR-V output")
7783
endif()
7884
endif()
7985
# Have ShaderMake use included DXC
@@ -96,12 +102,12 @@ add_subdirectory(External/donut)
96102
set(DONUT_PATH "${CMAKE_CURRENT_LIST_DIR}/External/donut")
97103

98104
include(External/NRD.cmake)
99-
include(External/DLSS.cmake)
100105

101106
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/Libraries/Rtxdi/CMakeLists.txt")
102107

103108
add_subdirectory(Libraries/Rtxdi)
104109
set(RTXDI_RUNTIME_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Libraries/Rtxdi/Include")
110+
set_target_properties(Rtxdi PROPERTIES FOLDER "RTXDI SDK")
105111

106112
endif()
107113

@@ -118,7 +124,11 @@ add_subdirectory(Samples/FullSample/Shaders)
118124
add_subdirectory(Samples/FullSample/Source)
119125
add_subdirectory(Samples/MinimalSample/Shaders)
120126
add_subdirectory(Samples/MinimalSample/Source)
127+
add_subdirectory(Support/Tests/FullSampleStructAlignmentTests)
121128
add_subdirectory(Support/Tests/RtxdiRuntimeShaderTests)
129+
add_subdirectory(Support/Tests/RtxdiRuntimeStructAlignmentTests)
130+
131+
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT FullSample)
122132

123133
if (MSVC)
124134
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT FullSample)

ChangeLog.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# RTXDI SDK Change Log
22

3+
## 3.0.0
4+
5+
**Release highlights:**
6+
7+
- Added ReSTIR PT resampling functions to the runtime and their integration in the Full Sample application.
8+
- Added shader debug print for D3D12.
9+
- Added path tracer visualization tool.
10+
- Added Primary Surface Replacement (PSR) support for NRD integrations.
11+
- Added visualization tools for DI, GI, and PT reservoirs.
12+
13+
**Breaking changes:**
14+
15+
- The RTXDI_PathTracerContext interface uses a primitive #define-based interface for maximum compatibility and requires an additional preprocessor macro.
16+
17+
**Fixed issues:**
18+
19+
- Removed ghosting issues that appeared on recent drivers.
20+
21+
**Misc improvements:**
22+
23+
- Updated Donut
24+
- Updated NRD
25+
- DLSS integration replaced by Donut's DLSS integration
26+
- Added NVAPI for D3D12
27+
328
## 2.3.0
429

530
**Release highlights:**

Doc/DebugUtilities.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Debug Utilities
2+
3+
The RTXDI SDK contains several tools for debugging and visualizing data.
4+
5+
## Shader Debug Print
6+
7+
Shader debug printing is supported in D3D12 for a single pixel, which is selected by mouse click. Enabling it requires setting `SHADER_DEBUG_PRINT_ENABLED` to 1, as well as binding several buffers to the shader and running the proper initialization code, which can be seen in the `RAB_Buffers.hlsli` and `GenerateInitialSamples.hlsl` files. Once enabled, the `DebugPrint_` function can send formatted strings, which support primitive types such as scalars and vectors, back to the host side. When run from the MSVS debugger, this output shows up in the Output panel. When run standalone, it can be seen by running [Debug View](https://learn.microsoft.com/en-us/sysinternals/downloads/debugview). The `RuntimeShaderDebugPrintUtilities.hlsli` file contains helper functions for printing the `RTXDI_PTReservoir` and `RTXDI_PTPathTraceInvocationType` types.
8+
9+
`DebugPrint_` works like printf, but uses braced numbers instead of percentage signs to send out variables. For example, `DebugPrint_("Hello pixel: {0}", pixelPos);` and `DebugPrint_("Diffuse is {0} and specular is {1}", diffuse, specular);` will work as expected.
10+
11+
**Note:** `DebugPrint_` degrades shader performance proportional to its usage - the more and longer the strings, the slower the shader gets. Performance should be fine for debugging, but don't forget to turn it off to measure performance.
12+
13+
**Note:** There are rare cases when `DebugPrint_` may cause general shader corruption for unknown reasons, typically from overuse. Try disabling `DebugPrint_` if you find the sample has gone haywire.
14+
15+
## Path Visualization
16+
17+
The path visualization tool tracks the bounces of the path tracer and records each hit, normal vector, and NEE sample, if one is taken. All five path tracing invocations are supported - initial sampling, temporal shift, temporal inverse shift, spatial shift, and spatial inverse shift. Two additional passes of temporal retrace and spatial retrace re-run the path tracer from the temporal or spatial neighbor's primary surface to the maximum bounce depth. Paths can be individually enabled and colored.
18+
19+
Performance note: Enabling path visualization causes a minor hit to performance and is compiled out by default. To enable it, set the `PT_PATH_VIZ_ENABLED` define to 1 and recompile. The two temporal and spatial retrace options are additionally toggled by the `RTXDI_DEBUG` define, which lives in the runtime rather than in the sample, and it must also be set to 1 to enable them.
20+
21+
**Note:** Sometimes the path visualization tool ends up adding an extra vertex (and often normal and NEE ray) at the camera position as a result of encountering stale data. This shows up as a line jumping across the screen. Just try clicking again to get a different path.
22+
23+
## Intermediate Buffer Visualization
24+
25+
The Intermediate Buffer Visualization menu in the GUI allows users to visualize buffer data in several ways
26+
27+
- Intermediate Texture Display blits the selected buffer directly to the screen. The list includes GBuffer layers and their PSR counterparts, as well as lighting components such as direct and indirect illumination.
28+
- Reservoir Subfield Display sends the chosen field of the selected reservoir type to the screen, transforming some values to help in visualization.
29+
- NRD Validation blits the NRD validation texture to the screen, with the option of overlaying it on top of the regularly rendered output.

Doc/Images/ReSTIRPT_no_reuse.png

843 KB
Loading
4.74 MB
Loading

Doc/Integration.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
# Three Algorithms in One SDK
1+
# Four Algorithms in One SDK
22

33
The RTXDI SDK originally contained a single algorithm, ReSTIR DI. Over time, however, the SDK has been expanded to include the ReGIR and ReSTIR GI algorithms. These three algorithms are grouped together because they all deal with importance sampling for path tracing. While something like "RTX IS" might therefore be a clearer name today, RTXDI is kept for historical continuity, and the DI now stands for Dynamic Illumination. Here is a summary of the three algorithms:
44

55
- ReSTIR DI, short for **Re**servoir **S**patio**T**emporal **I**mportance **R**esampling for **D**irect **I**llumination, is a screen space light sampling technique used for illuminating primary surfaces during path tracing. It cheaply selects several lights from an initial distribution, such as a uniform or power-based one, then selects one light of that group based on a more expensive distribution, such as one including geometry, BRDF, and visibility terms, and uses that one for illumination. These samples are then resampled over time and across neighboring pixels to increase effective sample count.
66
- ReGIR, short for Reservoir-based Grid Importance Sampling, is a world space light sampling technique that can be used for illuminating primary or subsequent surfaces. It samples lights from an initial distribution, such as a uniform or power-based one, for each grid cell. Other algorithms, such as ReSTIR DI and ReSTIR GI, can sample lights from this grid if the surface they are illuminating falls in a grid cell.
77
- ReSTIR GI, short for **Re**servoir **S**patio**T**emporal **I**mportance **R**esampling for **G**lobal **I**llumination, is a screen space light sampling technique used for illuminating secondary surfaces during path tracing. ReSTIR GI requires an initial light sampling technique be implemented by the path tracer for the secondary surface. In the `full-sample` project, this method is the initial sampling pass from ReSTIR DI, although any technique may be used. This secondary surface sample is then resampled across other pixels in space and time.
8+
- ReSTIR PT, short for **Re**servoir **S**patio**T**emporal **I**mportance **R**esampling for **P**ath **T**racing, is a screen space path resampling technique used for illuminating secondary surfaces. ReSTIR PT requires an integration of the RTXDI_PathTracingContext into a path tracer that calculates indirect lighting starting from the primary hit.
89

910
The algorithms in the SDK are implemented largely independent from one another, and the C++-side of each is centered around an accordingly named context class (`ReSTIRDIContext`, `ReGIRContext`, and `ReSTIRGIContext`). However, ReSTIR DI has a close integration of ReGIR for initial sampling. Likewise, the `full-sample` project uses ReSTIR DI's light sampling functions to illuminate secondary surfaces during multi-bounce path tracing.
1011

0 commit comments

Comments
 (0)