├── .gitignore
├── .gitmodules
├── .vscode
└── launch.json
├── CMakeLists.txt
├── ChangeLog.md
├── License.txt
├── README.md
├── docs
├── Algorithms.md
├── DDGIVolume.md
├── Integration.md
├── Math.md
├── QuickStart.md
├── ShaderAPI.md
├── images
│ ├── cmake.jpg
│ ├── ddgivolume-classification-01.jpg
│ ├── ddgivolume-classification-02.jpg
│ ├── ddgivolume-fixedRays.gif
│ ├── ddgivolume-movement-isv.gif
│ ├── ddgivolume-nsight-scrubber.jpg
│ ├── ddgivolume-octahedral-border.png
│ ├── ddgivolume-octahedral-param.jpg
│ ├── ddgivolume-relocation-off.jpg
│ ├── ddgivolume-relocation-on.jpg
│ ├── ddgivolume-textures-atlases.jpg
│ ├── ddgivolume-textures-probedata.jpg
│ ├── ddgivolume-textures-probevariability-avg.jpg
│ ├── ddgivolume-textures-probevariability.jpg
│ ├── ddgivolume-textures-ray-data-slices.jpg
│ ├── ddgivolume-textures-raydata.jpg
│ ├── integration-ddgi-ddgivolume.jpg
│ ├── integration-ddgi-ddgivolume.svg
│ ├── integration-ddgi-flow.svg
│ ├── math-eq-1.svg
│ ├── math-eq-2.svg
│ ├── math-eq-ddgi-3.svg
│ ├── math-eq-ddgi-4.svg
│ ├── math-eq-ddgi-5.svg
│ ├── math-eq-ddgi-6.svg
│ ├── math-eq-ddgi-7.svg
│ ├── pbrt-irradiance-from-radiance.svg
│ ├── rtxgi-cornell.jpg
│ ├── rtxgi-ddgi-algorithm.jpg
│ ├── rtxgi-sponza.jpg
│ ├── vs17.jpg
│ └── vscode.jpg
└── nvidia.jpg
├── rtxgi-sdk
├── CMakeLists.txt
├── FindSDKs.cmake
├── include
│ └── rtxgi
│ │ ├── Common.h
│ │ ├── Defines.h
│ │ ├── Math.h
│ │ ├── Types.h
│ │ ├── VulkanExtensions.h
│ │ └── ddgi
│ │ ├── DDGIRootConstants.h
│ │ ├── DDGIVolume.h
│ │ ├── DDGIVolumeDescGPU.h
│ │ └── gfx
│ │ ├── DDGIVolume_D3D12.h
│ │ └── DDGIVolume_VK.h
├── shaders
│ ├── Common.hlsl
│ ├── Platform.hlsl
│ └── ddgi
│ │ ├── Irradiance.hlsl
│ │ ├── ProbeBlendingCS.hlsl
│ │ ├── ProbeClassificationCS.hlsl
│ │ ├── ProbeRelocationCS.hlsl
│ │ ├── ReductionCS.hlsl
│ │ └── include
│ │ ├── Common.hlsl
│ │ ├── DDGIRootConstants.hlsl
│ │ ├── ProbeCommon.hlsl
│ │ ├── ProbeDataCommon.hlsl
│ │ ├── ProbeIndexing.hlsl
│ │ ├── ProbeOctahedral.hlsl
│ │ ├── ProbeRayCommon.hlsl
│ │ └── validation
│ │ ├── ProbeBlendingDefines.hlsl
│ │ ├── ProbeClassificationDefines.hlsl
│ │ ├── ProbeRelocationDefines.hlsl
│ │ └── ReductionDefines.hlsl
└── src
│ ├── Math.cpp
│ ├── VulkanExtensions.cpp
│ └── ddgi
│ ├── DDGIVolume.cpp
│ └── gfx
│ ├── DDGIVolume_D3D12.cpp
│ └── DDGIVolume_VK.cpp
├── samples
├── CMakeLists.txt
└── test-harness
│ ├── .args
│ ├── CMakeLists.txt
│ ├── Test-Harness-D3D12.nsight-gfxproj
│ ├── Test-Harness-Vulkan.nsight-gfxproj
│ ├── config
│ ├── cornell.ini
│ ├── furnace.ini
│ ├── multi-cornell.ini
│ ├── sponza.ini
│ ├── tunnel.ini
│ └── two-rooms.ini
│ ├── data
│ ├── gltf
│ │ ├── cornell
│ │ │ └── cornell.glb
│ │ ├── furnace
│ │ │ └── furnace.glb
│ │ ├── multi-cornell
│ │ │ └── multi-cornell.glb
│ │ ├── sponza
│ │ │ └── README.md
│ │ ├── tunnel
│ │ │ └── tunnel.glb
│ │ └── two-rooms
│ │ │ └── two-rooms.glb
│ └── textures
│ │ └── blue-noise-rgb-256.png
│ ├── include
│ ├── Benchmark.h
│ ├── Caches.h
│ ├── Common.h
│ ├── Configs.h
│ ├── Direct3D12.h
│ ├── Geometry.h
│ ├── Graphics.h
│ ├── ImageCapture.h
│ ├── Inputs.h
│ ├── Instrumentation.h
│ ├── Scenes.h
│ ├── Shaders.h
│ ├── Textures.h
│ ├── Visualization.h
│ ├── Vulkan.h
│ ├── VulkanExtensions.h
│ ├── Window.h
│ ├── graphics
│ │ ├── Composite.h
│ │ ├── Composite_D3D12.h
│ │ ├── Composite_VK.h
│ │ ├── DDGI.h
│ │ ├── DDGIDefines.h
│ │ ├── DDGIShaderConfig.h
│ │ ├── DDGIVisualizations.h
│ │ ├── DDGIVisualizations_D3D12.h
│ │ ├── DDGIVisualizations_VK.h
│ │ ├── DDGI_D3D12.h
│ │ ├── DDGI_VK.h
│ │ ├── GBuffer.h
│ │ ├── GBuffer_D3D12.h
│ │ ├── GBuffer_VK.h
│ │ ├── PathTracing.h
│ │ ├── PathTracing_D3D12.h
│ │ ├── PathTracing_VK.h
│ │ ├── RTAO.h
│ │ ├── RTAO_D3D12.h
│ │ ├── RTAO_VK.h
│ │ ├── Types.h
│ │ ├── UI.h
│ │ ├── UI_D3D12.h
│ │ └── UI_VK.h
│ └── thirdparty
│ │ ├── d3dx12.h
│ │ ├── directx
│ │ ├── OAIdl.h
│ │ ├── OCIdl.h
│ │ ├── d3d12.h
│ │ ├── d3d12sdklayers.h
│ │ ├── d3dcommon.h
│ │ ├── dxgicommon.h
│ │ ├── dxgiformat.h
│ │ ├── rpc.h
│ │ ├── rpcndr.h
│ │ ├── winadapter.h
│ │ ├── winapifamily.h
│ │ └── wrladapter.h
│ │ ├── directxmath
│ │ ├── DirectXMath.h
│ │ ├── DirectXMathConvert.inl
│ │ ├── DirectXMathMatrix.inl
│ │ ├── DirectXMathMisc.inl
│ │ ├── DirectXMathVector.inl
│ │ ├── DirectXPackedVector.h
│ │ └── DirectXPackedVector.inl
│ │ └── directxtex
│ │ ├── DirectXTex.h
│ │ └── DirectXTex.inl
│ ├── shaders
│ ├── AHS.hlsl
│ ├── CHS.hlsl
│ ├── Composite.hlsl
│ ├── GBufferRGS.hlsl
│ ├── IndirectCS.hlsl
│ ├── Miss.hlsl
│ ├── PathTraceRGS.hlsl
│ ├── RTAOFilterCS.hlsl
│ ├── RTAOTraceRGS.hlsl
│ ├── ddgi
│ │ ├── ProbeTraceRGS.hlsl
│ │ └── visualizations
│ │ │ ├── ProbesCHS.hlsl
│ │ │ ├── ProbesMiss.hlsl
│ │ │ ├── ProbesRGS.hlsl
│ │ │ ├── ProbesUpdateCS.hlsl
│ │ │ └── VolumeTexturesCS.hlsl
│ └── include
│ │ ├── Common.hlsl
│ │ ├── Descriptors.hlsl
│ │ ├── Lighting.hlsl
│ │ ├── Platform.hlsl
│ │ ├── Random.hlsl
│ │ ├── RayTracing.hlsl
│ │ └── nvapi
│ │ ├── nvHLSLExtns.h
│ │ ├── nvHLSLExtnsInternal.h
│ │ └── nvShaderExtnEnums.h
│ └── src
│ ├── Benchmark.cpp
│ ├── Caches.cpp
│ ├── Configs.cpp
│ ├── Direct3D12.cpp
│ ├── Geometry.cpp
│ ├── ImageCapture.cpp
│ ├── Inputs.cpp
│ ├── Instrumentation.cpp
│ ├── Scenes.cpp
│ ├── Shaders.cpp
│ ├── Textures.cpp
│ ├── UI.cpp
│ ├── Vulkan.cpp
│ ├── VulkanExtensions.cpp
│ ├── Window.cpp
│ ├── graphics
│ ├── Composite_D3D12.cpp
│ ├── Composite_VK.cpp
│ ├── DDGI.cpp
│ ├── DDGIVisualizations_D3D12.cpp
│ ├── DDGIVisualizations_VK.cpp
│ ├── DDGI_D3D12.cpp
│ ├── DDGI_VK.cpp
│ ├── GBuffer_D3D12.cpp
│ ├── GBuffer_VK.cpp
│ ├── PathTracing_D3D12.cpp
│ ├── PathTracing_VK.cpp
│ ├── RTAO_D3D12.cpp
│ ├── RTAO_VK.cpp
│ ├── UI_D3D12.cpp
│ └── UI_VK.cpp
│ ├── main.cpp
│ └── thirdparty
│ └── directxtex
│ ├── BC.cpp
│ ├── BC.h
│ ├── BC4BC5.cpp
│ ├── BC6HBC7.cpp
│ ├── BCDirectCompute.cpp
│ ├── BCDirectCompute.h
│ ├── DDS.h
│ ├── DirectXTexCompress.cpp
│ ├── DirectXTexCompressGPU.cpp
│ ├── DirectXTexConvert.cpp
│ ├── DirectXTexDDS.cpp
│ ├── DirectXTexImage.cpp
│ ├── DirectXTexMipmaps.cpp
│ ├── DirectXTexP.h
│ ├── DirectXTexUtil.cpp
│ ├── Shaders
│ ├── BC6HEncode.hlsl
│ ├── BC7Encode.hlsl
│ ├── CompileShaders.cmd
│ └── Compiled
│ │ ├── BC6HEncode_EncodeBlockCS.inc
│ │ ├── BC6HEncode_EncodeBlockCS.pdb
│ │ ├── BC6HEncode_TryModeG10CS.inc
│ │ ├── BC6HEncode_TryModeG10CS.pdb
│ │ ├── BC6HEncode_TryModeLE10CS.inc
│ │ ├── BC6HEncode_TryModeLE10CS.pdb
│ │ ├── BC7Encode_EncodeBlockCS.inc
│ │ ├── BC7Encode_EncodeBlockCS.pdb
│ │ ├── BC7Encode_TryMode02CS.inc
│ │ ├── BC7Encode_TryMode02CS.pdb
│ │ ├── BC7Encode_TryMode137CS.inc
│ │ ├── BC7Encode_TryMode137CS.pdb
│ │ ├── BC7Encode_TryMode456CS.inc
│ │ └── BC7Encode_TryMode456CS.pdb
│ ├── filters.h
│ └── scoped.h
├── thirdparty
└── nvapi
│ ├── NvApiDriverSettings.c
│ ├── NvApiDriverSettings.h
│ ├── amd64
│ └── nvapi64.lib
│ ├── docs
│ ├── NVAPI_Public_SDK_R520.pdf
│ └── NVAPI_SDKs_Samples_and_Tools_License_Agreement(Public).pdf
│ ├── nvHLSLExtns.h
│ ├── nvHLSLExtnsInternal.h
│ ├── nvShaderExtnEnums.h
│ ├── nvapi.h
│ ├── nvapi_lite_common.h
│ ├── nvapi_lite_d3dext.h
│ ├── nvapi_lite_salend.h
│ ├── nvapi_lite_salstart.h
│ ├── nvapi_lite_sli.h
│ ├── nvapi_lite_stereo.h
│ └── nvapi_lite_surround.h
└── ue4-plugin
├── 4.25
├── RTXGI-NvRTX4.25.3.patch
├── RTXGI-NvRTX4.25.4.patch
├── RTXGI-UE4.25.3.patch
└── RTXGI-UE4.25.4.patch
├── 4.26
├── RTXGI-UE4.26.0.patch
├── RTXGI-UE4.26.1.patch
└── RTXGI-UE4.26.2.patch
├── 4.27
└── RTXGI
│ ├── Images
│ ├── bp-category.png
│ ├── bp-component.png
│ ├── direct+rtxgi+texture.png
│ ├── direct+rtxgi.png
│ ├── direct-only.png
│ ├── editor-ddgi-volume.png
│ ├── emissive-surfaces.png
│ ├── emissive-surfaces2.png
│ ├── green-lights.png
│ ├── plugins.png
│ ├── probe-density.png
│ ├── probes.png
│ ├── settings-gilighting.png
│ ├── settings-giprobes.png
│ ├── settings-givolume.png
│ ├── settings-project.png
│ ├── transform-gizmos.png
│ └── volume-actor.png
│ ├── README.md
│ ├── RTXGI.uplugin
│ ├── Resources
│ ├── Icon40.png
│ └── icon128.png
│ ├── Shaders
│ └── Private
│ │ ├── ApplyLightingDeferred.usf
│ │ ├── ProbeUpdateRGS.usf
│ │ ├── ProbeViewRGS.usf
│ │ ├── SDK
│ │ ├── Common.ush
│ │ ├── DDGIVolumeDefines.ush
│ │ ├── DDGIVolumeDescGPU.ush
│ │ └── ddgi
│ │ │ ├── Irradiance.ush
│ │ │ ├── ProbeBlendingCS.usf
│ │ │ ├── ProbeBorderUpdateCS.usf
│ │ │ ├── ProbeCommon.ush
│ │ │ ├── ProbeRelocationCS.usf
│ │ │ └── ProbeStateClassifierCS.usf
│ │ ├── SDKDefines.ush
│ │ ├── UpscaleLighting.usf
│ │ └── VisualizeDDGIProbes.usf
│ └── Source
│ ├── RTXGI
│ ├── Private
│ │ ├── DDGIVolume.cpp
│ │ ├── DDGIVolumeComponent.cpp
│ │ ├── DDGIVolumeDescGPU.h
│ │ ├── DDGIVolumeUpdate.cpp
│ │ ├── DDGIVolumeUpdate.h
│ │ ├── DDGIVolumeVisualize.cpp
│ │ ├── RTXGIPlugin.cpp
│ │ ├── RTXGIPluginSettings.cpp
│ │ └── RTXGIPluginSettings.h
│ ├── Public
│ │ ├── DDGIVolume.h
│ │ ├── DDGIVolumeComponent.h
│ │ └── RTXGIPlugin.h
│ └── RTXGI.Build.cs
│ └── RTXGIEditor
│ ├── Private
│ ├── RTXGIDetails.cpp
│ └── RTXGIEditor.cpp
│ ├── Public
│ ├── RTXGIDetails.h
│ └── RTXGIEditor.h
│ └── RTXGIEditor.Build.cs
└── ChangeLog.md
/.gitignore:
--------------------------------------------------------------------------------
1 | .venv/*
2 | .vscode/settings.json
3 | .vscode/*.log
4 | log.txt
5 | build/*
6 | dxc
7 | d3d
8 | external
9 | samples/test-harness/data/gltf/*
10 | !samples/test-harness/data/gltf/cornell
11 | samples/test-harness/data/gltf/cornell/*.cache
12 | !samples/test-harness/data/gltf/furnace
13 | samples/test-harness/data/gltf/furnace/*.cache
14 | !samples/test-harness/data/gltf/multi-cornell
15 | samples/test-harness/data/gltf/multi-cornell/*.cache
16 | !samples/test-harness/data/gltf/sponza
17 | samples/test-harness/data/gltf/sponza/*.cache
18 | samples/test-harness/data/gltf/sponza/*.jpg
19 | samples/test-harness/data/gltf/sponza/*.png
20 | samples/test-harness/data/gltf/sponza/*.gltf
21 | samples/test-harness/data/gltf/sponza/*.bin
22 | samples/test-harness/data/gltf/sponza/Sponza.cache
23 | !samples/test-harness/data/gltf/tunnel
24 | samples/test-harness/data/gltf/tunnel/*.cache
25 | !samples/test-harness/data/gltf/two-rooms
26 | samples/test-harness/data/gltf/two-rooms/*.cache
27 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "thirdparty/glfw"]
2 | path = thirdparty/glfw
3 | url = https://github.com/glfw/glfw.git
4 | branch = master
5 | [submodule "thirdparty/tinygltf"]
6 | path = thirdparty/tinygltf
7 | url = https://github.com/syoyo/tinygltf.git
8 | [submodule "thirdparty/imgui"]
9 | path = thirdparty/imgui
10 | url = https://github.com/ocornut/imgui.git
11 | branch = master
12 | [submodule "thirdparty/Vulkan-Headers"]
13 | path = thirdparty/Vulkan-Headers
14 | url = https://github.com/KhronosGroup/Vulkan-Headers.git
15 | branch = sdk-1.2.170
16 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "name": "Test Harness",
6 | "type": "cppdbg",
7 | "request": "launch",
8 | "program": "${command:cmake.launchTargetPath}",
9 | "args": [ "../../../samples/test-harness/config/cornell.ini" ],
10 | "stopAtEntry": false,
11 | "cwd": "${workspaceFolder}/build/samples/test-harness",
12 | "environment": [
13 | { "name": "PATH", "value": "$PATH:${command:cmake.launchTargetDirectory}" }
14 | ],
15 | "externalConsole": false,
16 | "MIMode": "gdb",
17 | "miDebuggerPath": "/usr/bin/gdb",
18 | "symbolLoadInfo": {
19 | "loadAll": true,
20 | "exceptionList": ""
21 | },
22 | "setupCommands": [
23 | {
24 | "description": "Enable pretty-printing for gdb",
25 | "text": "-enable-pretty-printing",
26 | "ignoreFailures": true
27 | }
28 | ],
29 | }
30 | ]
31 | }
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | #
4 | # NVIDIA CORPORATION and its licensors retain all intellectual property
5 | # and proprietary rights in and to this software, related documentation
6 | # and any modifications thereto. Any use, reproduction, disclosure or
7 | # distribution of this software and related documentation without an express
8 | # license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | #
10 |
11 | cmake_minimum_required(VERSION 3.10)
12 |
13 | project(RTXGI)
14 |
15 | set(CMAKE_CXX_STANDARD 17)
16 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
17 | set(CMAKE_CXX_EXTENSIONS ON)
18 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin")
19 |
20 | set_property(GLOBAL PROPERTY USE_FOLDERS ON)
21 |
22 | # Helper to download and unzip a package from a URL
23 | # Uses a zero-length file to identify the version of the package
24 | function(CheckAndDownloadPackage NAME VERSION LOCAL_PATH URL)
25 | # Do we already have the correct version?
26 | if(NOT EXISTS ${LOCAL_PATH}/${VERSION}.ver)
27 | # Was there a previous version that we need to delete?
28 | if(EXISTS ${LOCAL_PATH})
29 | message(STATUS "Deleting old " ${NAME})
30 | file(REMOVE_RECURSE ${LOCAL_PATH})
31 | endif()
32 | message(STATUS "Obtaining " ${NAME} " " ${VERSION})
33 | file(DOWNLOAD ${URL} ${LOCAL_PATH}.zip)
34 | message(STATUS "Extracting " ${NAME})
35 | file(ARCHIVE_EXTRACT INPUT ${LOCAL_PATH}.zip DESTINATION ${LOCAL_PATH})
36 | file(REMOVE ${LOCAL_PATH}.zip)
37 | # Create an empty file so we know which version we have
38 | file(WRITE ${LOCAL_PATH}/${VERSION}.ver)
39 | endif()
40 | endfunction()
41 |
42 | # Add Vulkan headers on ARM since there is no official ARM Vulkan SDK
43 | if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
44 | add_subdirectory(thirdparty/Vulkan-Headers)
45 | set(RTXGI_API_VULKAN_SDK "1")
46 | set(Vulkan_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/thirdparty/Vulkan-Headers/include/")
47 | endif()
48 |
49 | # Download D3D Agility SDK and DXC binaries
50 | if(WIN32)
51 | CheckAndDownloadPackage("Agility SDK" "v1.606.3" ${CMAKE_CURRENT_SOURCE_DIR}/external/agilitysdk https://www.nuget.org/api/v2/package/Microsoft.Direct3D.D3D12/1.606.3)
52 | CheckAndDownloadPackage("DXC" "v1.7.2308" ${CMAKE_CURRENT_SOURCE_DIR}/external/dxc https://github.com/microsoft/DirectXShaderCompiler/releases/download/v1.7.2308/dxc_2023_08_14.zip)
53 | elseif(UNIX AND NOT APPLE)
54 | CheckAndDownloadPackage("DXC" "v1.7.2308" ${CMAKE_CURRENT_SOURCE_DIR}/external/dxc https://github.com/microsoft/DirectXShaderCompiler/releases/download/v1.7.2308/linux_dxc_2023_08_14.x86_64.tar.gz)
55 | endif()
56 |
57 | # SDK
58 | add_subdirectory(rtxgi-sdk)
59 |
60 | # Samples
61 | option(RTXGI_BUILD_SAMPLES "Include the RTXGI sample application(s)" ON)
62 | if(RTXGI_BUILD_SAMPLES)
63 | # GLFW3
64 | option(GLFW_BUILD_EXAMPLES "" OFF)
65 | option(GLFW_BUILD_TESTS "" OFF)
66 | option(GLFW_BUILD_DOCS "" OFF)
67 | option(GLFW_INSTALL "" OFF)
68 | add_subdirectory(thirdparty/glfw)
69 | set_target_properties(glfw PROPERTIES FOLDER "Thirdparty/GLFW3")
70 | set_target_properties(update_mappings PROPERTIES FOLDER "Thirdparty/GLFW3")
71 |
72 | # TinyGLTF
73 | option(TINYGLTF_BUILD_LOADER_EXAMPLE "" OFF)
74 | add_subdirectory(thirdparty/tinygltf)
75 | target_compile_definitions(tinygltf PUBLIC _CRT_SECURE_NO_WARNINGS) # suppress the sprintf CRT warnings
76 | set_target_properties(tinygltf PROPERTIES FOLDER "Thirdparty/")
77 |
78 | # Samples
79 | add_subdirectory(samples)
80 |
81 | # Set the default project. If D3D is an option, set it as default.
82 | if(RTXGI_API_D3D12_ENABLE)
83 | set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT TestHarness-D3D12)
84 | elseif(NOT RTXGI_API_D3D12_ENABLE AND RTXGI_API_VULKAN_ENABLE)
85 | set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT TestHarness-VK)
86 | endif()
87 | endif()
88 |
--------------------------------------------------------------------------------
/docs/Algorithms.md:
--------------------------------------------------------------------------------
1 | # RTXGI Algorithms
2 |
3 | ## Dynamic Diffuse Global Illumination (DDGI)
4 |
5 | *Dynamic Diffuse Global Illumination (DDGI)* is a global lighting algorithm that extends pre-computed irradiance probes approaches. Lighting techniques built on pre-computed irradiance probes are commonly used today in real-time rendering (see popular commercial products and engines such as Enlighten, Unity, and Unreal Engine); however, these probe-based solutions are not able to resolve visibility and occlusion of dynamic scene elements at runtime. This causes obvious light and shadow "leaking" artifacts.
6 |
7 | DDGI resolves the leaking problems by using GPU ray tracing, a fast probe update scheme to maintain per-probe irradiance *and* distance data, and a statistics based occlusion test.
8 |
9 | To learn more about DDGI, see these resources:
10 |
11 | - [Scaling Probe-Based Real-Time Dynamic Global Illumination for Production (JCGT Paper)](https://jcgt.org/published/0010/02/01/)
12 | - [Dynamic Diffuse Global Illumination with Ray-Traced Irradiance Fields (JCGT Paper)](https://jcgt.org/published/0008/02/01/)
13 | - [Ray-Traced Irradiance Fields (Presented by NVIDIA) - GDC 2019 Talk](https://www.gdcvault.com/play/1026182/)
14 |
15 | ### Benefits
16 |
17 | - Fully dynamic diffuse global illumination in real-time.
18 | - Color transfer.
19 | - Indirect occlusion.
20 | - Support for surfaces and media typically not included in GBuffers (e.g. transluent surfaces and volumetrics).
21 | - Improved workflow for artists (less probe tweaking), compared to traditional irradiance probes.
22 | - No lightmap UVs. No waiting for lightmap bakes.
23 | - In-editor results in real time.
24 | - Scalable performance.
25 | - Probes can be easily pre-computed and loaded for platforms that do not support GPU ray tracing, creating a single lighting path for all platforms.
26 |
27 | ### Limitations
28 |
29 | - Low frequency global illumination signal. High frequency radiometric and geometric details are not reproduced.
30 | - Irradiance temporally accumulates in probes, so there is an unavoidable minimum latency when lighting changes occur.
31 | - Probe data storage can become memory intensive in large environments.
32 |
33 | ### Additional Notes
34 |
35 | Similar to traditional irradiance probes, DDGI does not solve the complete global illumination problem, and **it is best used for the diffuse irradiance component of the full lighting equation**. As a result of the underlying probe based data structure, the computed diffuse irradiance is inherently low frequency and can not capture fine high frequency details. For this reason, DDGI combines effectively with complimentary rendering techniques such as Ray Traced Ambient Occlusion (RTAO). To demonstrate this, RTAO is implemented and combined with DDGI in the Test Harness sample application.
36 |
37 | 
38 |
--------------------------------------------------------------------------------
/docs/QuickStart.md:
--------------------------------------------------------------------------------
1 | # RTXGI Quick Start
2 |
3 | The fastest way to start learning RTXGI is to clone, build, and run the Test Harness sample application provided alongside the SDK.
4 |
5 | ## Clone the Code and Sample Content
6 |
7 | 1. Clone the repository (with all submodules)
8 |
9 | `git clone --recursive https://github.com/NVIDIAGameWorks/RTXGI.git`
10 |
11 | 2. Install the [Vulkan SDK](https://vulkan.lunarg.com/sdk/home) (optional on Windows)
12 |
13 | 3. Clone the Khronos Sponza GLTF content (optional)
14 |
15 | * Clone https://github.com/KhronosGroup/glTF-Sample-Models to somewhere on your machine (but don't clone it inside of this project).
16 |
17 | * Copy or move the contents of https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/Sponza/glTF into `samples/test-harness/data/gltf/sponza`.
18 |
19 | * See the [Sponza README](../samples/test-harness/data/gltf/sponza/README.md) for more information.
20 |
21 | ## Configure with CMake
22 |
23 | 4. Install CMake. The [CMake GUI](https://cmake.org/download/) is convenient and easy to use.
24 |
25 | 5. Open CMake GUI and fill in the path options.
26 |
27 | * On the *source code* line, fill in the path to where you have cloned this repository on your machine (e.g. `C:/rtxgi`).
28 | * On the *build binaries* line, fill in the path to the repository plus */build* (e.g. `C:/rtxgi/build`).
29 |
30 | 
31 |
32 | 6. Click `Configure`
33 | * If using Visual Studio 2017 on Windows, select `x64` as the platform for the generator in the dropdown.
34 | * If using Visual Studio 2019 or later on Windows, the platform is `x64` by default.
35 | * The configuration process downloads and extracts the DirectX12 Agility SDK and DirectX Shader Compiler to the **external/agilitysdk** and **external/dxc** directories (respectively).
36 |
37 | 7. Click `Generate`
38 | * The generated Visual Studio project is located in `[path-to-repo]/build/RTXGI.sln` (e.g. `C:/rtxgi/build/RTXGI.sln`).
39 |
40 | ## Build and Run
41 |
42 | ### Windows
43 |
44 | 8. Click `Open Project` in CMake to open the generated Visual Studio solution.
45 |
46 | * **Note:** there are separate projects for the D3D12 and Vulkan versions of the SDK and sample application(s). If the Vulkan SDK is not installed, or you disable Vulkan in the CMake options, the `-VK` projects are not generated.
47 |
48 | 
49 |
50 | 9. Build the solution.
51 |
52 | * **Note:** if you want to just build the RTXGI SDK, **uncheck** the `RTXGI_BUILD_SAMPLES` option in CMake, click Generate, and reload the Visual Studio solution. The RTXGI Samples and Thirdparty folders will be removed.
53 |
54 | 10. Set the Startup Project to `TestHarness-D3D12` (or `TestHarness-VK`).
55 |
56 | 11. Run the Test Harness.
57 |
58 | ---
59 |
60 | ### Linux
61 |
62 | 8. Open Visual Studio Code.
63 |
64 | 9. Open the folder (```File->Open Folder```) where you cloned the repository (e.g. `C:rtxgi/`)
65 |
66 | * The VSCode [CMake Tools Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools) is useful if you want to configure, generate, and build all in VSCode.
67 |
68 | 
69 |
70 | 10. Build the default target.
71 |
72 | 11. Select `Run->Start without Debugging`
73 |
74 | * This uses the launch arguments in `[path-to-repo]/.vscode/launch.json`
75 |
76 | ## Enjoy
77 |
78 | The Cornell Box scene is loaded by default and you should see the below result:
79 |
80 | 
--------------------------------------------------------------------------------
/docs/images/cmake.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/cmake.jpg
--------------------------------------------------------------------------------
/docs/images/ddgivolume-classification-01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/ddgivolume-classification-01.jpg
--------------------------------------------------------------------------------
/docs/images/ddgivolume-classification-02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/ddgivolume-classification-02.jpg
--------------------------------------------------------------------------------
/docs/images/ddgivolume-fixedRays.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/ddgivolume-fixedRays.gif
--------------------------------------------------------------------------------
/docs/images/ddgivolume-movement-isv.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/ddgivolume-movement-isv.gif
--------------------------------------------------------------------------------
/docs/images/ddgivolume-nsight-scrubber.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/ddgivolume-nsight-scrubber.jpg
--------------------------------------------------------------------------------
/docs/images/ddgivolume-octahedral-border.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/ddgivolume-octahedral-border.png
--------------------------------------------------------------------------------
/docs/images/ddgivolume-octahedral-param.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/ddgivolume-octahedral-param.jpg
--------------------------------------------------------------------------------
/docs/images/ddgivolume-relocation-off.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/ddgivolume-relocation-off.jpg
--------------------------------------------------------------------------------
/docs/images/ddgivolume-relocation-on.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/ddgivolume-relocation-on.jpg
--------------------------------------------------------------------------------
/docs/images/ddgivolume-textures-atlases.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/ddgivolume-textures-atlases.jpg
--------------------------------------------------------------------------------
/docs/images/ddgivolume-textures-probedata.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/ddgivolume-textures-probedata.jpg
--------------------------------------------------------------------------------
/docs/images/ddgivolume-textures-probevariability-avg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/ddgivolume-textures-probevariability-avg.jpg
--------------------------------------------------------------------------------
/docs/images/ddgivolume-textures-probevariability.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/ddgivolume-textures-probevariability.jpg
--------------------------------------------------------------------------------
/docs/images/ddgivolume-textures-ray-data-slices.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/ddgivolume-textures-ray-data-slices.jpg
--------------------------------------------------------------------------------
/docs/images/ddgivolume-textures-raydata.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/ddgivolume-textures-raydata.jpg
--------------------------------------------------------------------------------
/docs/images/integration-ddgi-ddgivolume.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/integration-ddgi-ddgivolume.jpg
--------------------------------------------------------------------------------
/docs/images/pbrt-irradiance-from-radiance.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/images/rtxgi-cornell.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/rtxgi-cornell.jpg
--------------------------------------------------------------------------------
/docs/images/rtxgi-ddgi-algorithm.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/rtxgi-ddgi-algorithm.jpg
--------------------------------------------------------------------------------
/docs/images/rtxgi-sponza.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/rtxgi-sponza.jpg
--------------------------------------------------------------------------------
/docs/images/vs17.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/vs17.jpg
--------------------------------------------------------------------------------
/docs/images/vscode.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/images/vscode.jpg
--------------------------------------------------------------------------------
/docs/nvidia.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/docs/nvidia.jpg
--------------------------------------------------------------------------------
/rtxgi-sdk/FindSDKs.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | #
4 | # NVIDIA CORPORATION and its licensors retain all intellectual property
5 | # and proprietary rights in and to this software, related documentation
6 | # and any modifications thereto. Any use, reproduction, disclosure or
7 | # distribution of this software and related documentation without an express
8 | # license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | #
10 |
11 | # If on Windows, locate the Win10 SDK path if it is not already provided
12 | if(WIN32 AND NOT RTXGI_WIN10_SDK)
13 | # Search for a suitable Win10 SDK
14 | get_filename_component(kit10_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" REALPATH)
15 | file(GLOB RTXGI_WIN10SDK_VERSIONS RELATIVE ${kit10_dir}/Include ${kit10_dir}/Include/10.*) # enumerate pre-release and not yet known release versions
16 | list(APPEND RTXGI_WIN10SDK_VERSIONS "10.0.17763.0") # enumerate well known release versions
17 | list(REMOVE_DUPLICATES RTXGI_WIN10SDK_VERSIONS)
18 | list(SORT RTXGI_WIN10SDK_VERSIONS) # sort from low to high
19 | list(REVERSE RTXGI_WIN10SDK_VERSIONS) # reverse to start from high
20 |
21 | foreach(RTXGI_WIN10_SDK_VER ${RTXGI_WIN10SDK_VERSIONS})
22 | if(RTXGI_WIN10_SDK_VER VERSION_LESS "10.0.17763.0")
23 | continue()
24 | endif()
25 | set(RTXGI_API_D3D12_DXIL_PATH "${kit10_dir}/bin/${RTXGI_WIN10_SDK_VER}/x64" CACHE FILEPATH "" FORCE)
26 | message(STATUS "Found Suitable Windows 10 SDK: ${RTXGI_WIN10_SDK_VER}")
27 | break()
28 | endforeach()
29 |
30 | if(NOT RTXGI_API_D3D12_DXIL_PATH)
31 | message(WARNING "Failed to locate a suitable version of the Windows 10 SDK (10.0.17763 or greater).")
32 | endif()
33 | endif()
34 |
35 | # If on Windows or x86 Linux, locate the Vulkan SDK path if it is not already provided
36 | if(NOT RTXGI_API_VULKAN_SDK AND NOT (${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64"))
37 | # Search for a suitable Vulkan SDK
38 | find_package(Vulkan "1.2.170")
39 | if(Vulkan_FOUND)
40 | string(REPLACE "Include" "" VK_SDK ${Vulkan_INCLUDE_DIR})
41 | set(RTXGI_API_VULKAN_SDK "1")
42 | message(STATUS "Found a suitable version of the Vulkan SDK: ${VK_SDK}")
43 | else()
44 | set(RTXGI_API_VULKAN_SDK "0")
45 | endif()
46 | endif()
47 |
48 | if(NOT RTXGI_API_VULKAN_SDK AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
49 | set(RTXGI_API_VULKAN_SDK "1")
50 | endif()
51 |
--------------------------------------------------------------------------------
/rtxgi-sdk/include/rtxgi/Defines.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #ifndef RTXGI_DEFINES_H
12 | #define RTXGI_DEFINES_H
13 |
14 | // Define RTXGI_GFX_NAME_OBJECTS before including DDGIVolume.h to enable debug names
15 | // for graphics objects for use with debugging tools (e.g. NVIDIA Nsight Graphics).
16 | // Exposed in CMake as RTXGI_GFX_NAME_OBJECTS
17 | //#define RTXGI_GFX_NAME_OBJECTS
18 |
19 | // Default performance marker colors for use with debugging tools (e.g. NVIDIA Nsight Graphics).
20 | #define RTXGI_PERF_MARKER_RED 204, 28, 41
21 | #define RTXGI_PERF_MARKER_GREEN 105, 148, 79
22 | #define RTXGI_PERF_MARKER_BLUE 65, 126, 211
23 | #define RTXGI_PERF_MARKER_ORANGE 217, 122, 46
24 | #define RTXGI_PERF_MARKER_YELLOW 217, 207, 46
25 | #define RTXGI_PERF_MARKER_PURPLE 152, 78, 163
26 | #define RTXGI_PERF_MARKER_BROWN 166, 86, 40
27 | #define RTXGI_PERF_MARKER_GREY 190, 190, 190
28 |
29 | // Coordinate system defines
30 | #define RTXGI_COORDINATE_SYSTEM_LEFT 0
31 | #define RTXGI_COORDINATE_SYSTEM_LEFT_Z_UP 1
32 | #define RTXGI_COORDINATE_SYSTEM_RIGHT 2
33 | #define RTXGI_COORDINATE_SYSTEM_RIGHT_Z_UP 3
34 |
35 | // Define RTXGI_COORDINATE_SYSTEM before including DDGIVolume.h and before compiling
36 | // SDK HLSL shaders to use another coordinate system. Default is right handed, y-up.
37 | // Exposed in CMake as RTXGI_COORDINATE_SYSTEM
38 | #ifndef RTXGI_COORDINATE_SYSTEM
39 | #error RTXGI_COORDINATE_SYSTEM is not defined!
40 | #endif
41 |
42 | #endif // RTXGI_DEFINES_H
43 |
--------------------------------------------------------------------------------
/rtxgi-sdk/include/rtxgi/VulkanExtensions.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Common.h"
14 |
15 | #if _WIN32
16 | #define VK_USE_PLATFORM_WIN32_KHR
17 | #elif __linux__
18 | #define VK_USE_PLATFORM_XLIB_KHR
19 | #endif
20 | #include
21 |
22 | namespace rtxgi
23 | {
24 | namespace vulkan
25 | {
26 | RTXGI_API void LoadExtensions(VkDevice device);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/rtxgi-sdk/include/rtxgi/ddgi/DDGIRootConstants.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #ifndef RTXGI_DDGI_ROOT_CONSTANTS_H
12 | #define RTXGI_DDGI_ROOT_CONSTANTS_H
13 |
14 | #ifndef HLSL
15 | #include "../Types.h"
16 | using namespace rtxgi;
17 | #endif
18 |
19 | struct DDGIRootConstants
20 | {
21 | uint volumeIndex;
22 | uint volumeConstantsIndex;
23 | uint volumeResourceIndicesIndex;
24 | // Split uint3 into three uints to prevent internal padding
25 | // while keeping these values at the end of the struct
26 | uint reductionInputSizeX;
27 | uint reductionInputSizeY;
28 | uint reductionInputSizeZ;
29 |
30 | #ifndef HLSL
31 | uint32_t data[6] = {};
32 | static uint32_t GetNum32BitValues() { return 6; }
33 | static uint32_t GetSizeInBytes() { return GetNum32BitValues() * 4; }
34 | static uint32_t GetAlignedNum32BitValues() { return 8; }
35 | static uint32_t GetAlignedSizeInBytes() { return GetAlignedNum32BitValues() * 4; }
36 | uint32_t* GetData()
37 | {
38 | data[0] = volumeIndex;
39 | data[1] = volumeConstantsIndex;
40 | data[2] = volumeResourceIndicesIndex;
41 | data[3] = reductionInputSizeX;
42 | data[4] = reductionInputSizeY;
43 | data[5] = reductionInputSizeZ;
44 | //data[6/7] = 0; // empty, alignment padding
45 |
46 | return data;
47 | }
48 | #endif
49 | };
50 |
51 | #endif // RTXGI_DDGI_ROOT_CONSTANTS_H
52 |
--------------------------------------------------------------------------------
/rtxgi-sdk/shaders/Platform.hlsl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #ifndef RTXGI_PLATFORM_HLSL
12 | #define RTXGI_PLATFORM_HLSL
13 |
14 | #ifdef __spirv__
15 | #define RTXGI_VK_BINDING(x, y) [[vk::binding(x, y)]]
16 | #define RTXGI_VK_PUSH_CONST [[vk::push_constant]]
17 | #else
18 | #define RTXGI_VK_BINDING(x, y)
19 | #define RTXGI_VK_PUSH_CONST
20 | #endif
21 |
22 | #endif //RTXGI_PLATFORM_HLSL
23 |
--------------------------------------------------------------------------------
/rtxgi-sdk/shaders/ddgi/include/Common.hlsl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #ifndef RTXGI_DDGI_COMMON_HLSL
12 | #define RTXGI_DDGI_COMMON_HLSL
13 |
14 | #include "../../Common.hlsl"
15 | #include "../../Platform.hlsl"
16 | #include "../../../include/rtxgi/Defines.h"
17 | #include "../../../include/rtxgi/ddgi/DDGIRootConstants.h"
18 | #include "../../../include/rtxgi/ddgi/DDGIVolumeDescGPU.h"
19 |
20 | //------------------------------------------------------------------------
21 | // Defines
22 | //------------------------------------------------------------------------
23 |
24 | // Bindless resource implementation type
25 | #define RTXGI_BINDLESS_TYPE_RESOURCE_ARRAYS 0
26 | #define RTXGI_BINDLESS_TYPE_DESCRIPTOR_HEAP 1
27 |
28 | // Texture formats (matches EDDGIVolumeTextureFormat)
29 | #define RTXGI_DDGI_VOLUME_TEXTURE_FORMAT_U32 0
30 | #define RTXGI_DDGI_VOLUME_TEXTURE_FORMAT_F16 1
31 | #define RTXGI_DDGI_VOLUME_TEXTURE_FORMAT_F16x2 2
32 | #define RTXGI_DDGI_VOLUME_TEXTURE_FORMAT_F16x4 3
33 | #define RTXGI_DDGI_VOLUME_TEXTURE_FORMAT_F32 4
34 | #define RTXGI_DDGI_VOLUME_TEXTURE_FORMAT_F32x2 5
35 | #define RTXGI_DDGI_VOLUME_TEXTURE_FORMAT_F32x4 6
36 |
37 | // The number of fixed rays that are used by probe relocation and classification.
38 | // These rays directions are always the same to produce temporally stable results.
39 | #define RTXGI_DDGI_NUM_FIXED_RAYS 32
40 |
41 | // Probe classification states
42 | #define RTXGI_DDGI_PROBE_STATE_ACTIVE 0 // probe shoots rays and may be sampled by a front facing surface or another probe (recursive irradiance)
43 | #define RTXGI_DDGI_PROBE_STATE_INACTIVE 1 // probe doesn't need to shoot rays, it isn't near a front facing surface
44 |
45 | // Volume movement types
46 | #define RTXGI_DDGI_VOLUME_MOVEMENT_TYPE_DEFAULT 0
47 | #define RTXGI_DDGI_VOLUME_MOVEMENT_TYPE_SCROLLING 1
48 |
49 | //------------------------------------------------------------------------
50 | // Helpers
51 | //------------------------------------------------------------------------
52 |
53 | bool IsVolumeMovementScrolling(DDGIVolumeDescGPU volume)
54 | {
55 | return (volume.movementType == RTXGI_DDGI_VOLUME_MOVEMENT_TYPE_SCROLLING);
56 | }
57 |
58 | #endif // RTXGI_DDGI_COMMON_HLSL
59 |
--------------------------------------------------------------------------------
/rtxgi-sdk/shaders/ddgi/include/ProbeDataCommon.hlsl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #ifndef RTXGI_DDGI_PROBE_DATA_COMMON_HLSL
12 | #define RTXGI_DDGI_PROBE_DATA_COMMON_HLSL
13 |
14 | #include "Common.hlsl"
15 |
16 | //------------------------------------------------------------------------
17 | // Probe Data Texture Write Helpers
18 | //------------------------------------------------------------------------
19 |
20 | /**
21 | * Normalizes the world-space offset and writes it to the probe data texture.
22 | * Probe Relocation limits this range to [0.f, 0.45f).
23 | */
24 | void DDGIStoreProbeDataOffset(RWTexture2DArray probeData, uint3 coords, float3 wsOffset, DDGIVolumeDescGPU volume)
25 | {
26 | probeData[coords].xyz = wsOffset / volume.probeSpacing;
27 | }
28 |
29 | //------------------------------------------------------------------------
30 | // Probe Data Texture Read Helpers
31 | //------------------------------------------------------------------------
32 |
33 | /**
34 | * Reads the probe's position offset (from a Texture2DArray) and converts it to a world-space offset.
35 | */
36 | float3 DDGILoadProbeDataOffset(Texture2DArray probeData, uint3 coords, DDGIVolumeDescGPU volume)
37 | {
38 | return probeData.Load(int4(coords, 0)).xyz * volume.probeSpacing;
39 | }
40 |
41 | /**
42 | * Reads the probe's position offset (from a RWTexture2DArray) and converts it to a world-space offset.
43 | */
44 | float3 DDGILoadProbeDataOffset(RWTexture2DArray probeData, uint3 coords, DDGIVolumeDescGPU volume)
45 | {
46 | return probeData[coords].xyz * volume.probeSpacing;
47 | }
48 |
49 | #endif // RTXGI_DDGI_PROBE_DATA_COMMON_HLSL
50 |
--------------------------------------------------------------------------------
/rtxgi-sdk/shaders/ddgi/include/ProbeOctahedral.hlsl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #ifndef RTXGI_DDGI_PROBE_OCTAHEDRAL_HLSL
12 | #define RTXGI_DDGI_PROBE_OCTAHEDRAL_HLSL
13 |
14 | #include "Common.hlsl"
15 |
16 | //------------------------------------------------------------------------
17 | // Probe Octahedral Indexing
18 | //------------------------------------------------------------------------
19 |
20 | /**
21 | * Computes normalized octahedral coordinates for the given texel coordinates.
22 | * Maps the top left texel to (-1,-1).
23 | * Used by DDGIProbeBlendingCS() in ProbeBlending.hlsl.
24 | */
25 | float2 DDGIGetNormalizedOctahedralCoordinates(int2 texCoords, int numTexels)
26 | {
27 | // Map 2D texture coordinates to a normalized octahedral space
28 | float2 octahedralTexelCoord = float2(texCoords.x % numTexels, texCoords.y % numTexels);
29 |
30 | // Move to the center of a texel
31 | octahedralTexelCoord.xy += 0.5f;
32 |
33 | // Normalize
34 | octahedralTexelCoord.xy /= float(numTexels);
35 |
36 | // Shift to [-1, 1);
37 | octahedralTexelCoord *= 2.f;
38 | octahedralTexelCoord -= float2(1.f, 1.f);
39 |
40 | return octahedralTexelCoord;
41 | }
42 |
43 | /**
44 | * Computes the normalized octahedral direction that corresponds to the
45 | * given normalized coordinates on the [-1, 1] square.
46 | * The opposite of DDGIGetOctahedralCoordinates().
47 | * Used by DDGIProbeBlendingCS() in ProbeBlending.hlsl.
48 | */
49 | float3 DDGIGetOctahedralDirection(float2 coords)
50 | {
51 | float3 direction = float3(coords.x, coords.y, 1.f - abs(coords.x) - abs(coords.y));
52 | if (direction.z < 0.f)
53 | {
54 | direction.xy = (1.f - abs(direction.yx)) * RTXGISignNotZero(direction.xy);
55 | }
56 | return normalize(direction);
57 | }
58 |
59 | /**
60 | * Computes the octant coordinates in the normalized [-1, 1] square, for the given a unit direction vector.
61 | * The opposite of DDGIGetOctahedralDirection().
62 | * Used by GetDDGIVolumeIrradiance() in Irradiance.hlsl.
63 | */
64 | float2 DDGIGetOctahedralCoordinates(float3 direction)
65 | {
66 | float l1norm = abs(direction.x) + abs(direction.y) + abs(direction.z);
67 | float2 uv = direction.xy * (1.f / l1norm);
68 | if (direction.z < 0.f)
69 | {
70 | uv = (1.f - abs(uv.yx)) * RTXGISignNotZero(uv.xy);
71 | }
72 | return uv;
73 | }
74 |
75 | #endif // RTXGI_DDGI_PROBE_OCTAHEDRAL_HLSL
76 |
--------------------------------------------------------------------------------
/rtxgi-sdk/src/VulkanExtensions.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #include "rtxgi/VulkanExtensions.h"
12 |
13 | // WARNING: This way of handling extensions works assuming one and only one device exists; do not call across multiple device objects
14 |
15 | //----------------------------------------------------------------------------------------------------------
16 | // Debug Util Extensions
17 | //----------------------------------------------------------------------------------------------------------
18 |
19 | PFN_vkSetDebugUtilsObjectNameEXT gvkSetDebugUtilsObjectNameEXT;
20 | PFN_vkCmdBeginDebugUtilsLabelEXT gvkCmdBeginDebugUtilsLabelEXT;
21 | PFN_vkCmdEndDebugUtilsLabelEXT gvkCmdEndDebugUtilsLabelEXT;
22 |
23 | VKAPI_ATTR VkResult VKAPI_CALL vkSetDebugUtilsObjectNameEXT(VkDevice device, const VkDebugUtilsObjectNameInfoEXT* pNameInfo)
24 | {
25 | return gvkSetDebugUtilsObjectNameEXT(device, pNameInfo);
26 | }
27 |
28 | VKAPI_ATTR void VKAPI_CALL vkCmdBeginDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT* pLabelInfo)
29 | {
30 | return gvkCmdBeginDebugUtilsLabelEXT(commandBuffer, pLabelInfo);
31 | }
32 |
33 | VKAPI_ATTR void VKAPI_CALL vkCmdEndDebugUtilsLabelEXT(VkCommandBuffer commandBuffer)
34 | {
35 | return gvkCmdEndDebugUtilsLabelEXT(commandBuffer);
36 | }
37 |
38 | //----------------------------------------------------------------------------------------------------------
39 | // Public Functions
40 | //----------------------------------------------------------------------------------------------------------
41 |
42 | #define LOAD_DEVICE_PROC(NAME) g##NAME = (PFN_##NAME)vkGetDeviceProcAddr(device, #NAME);
43 |
44 | namespace rtxgi
45 | {
46 | namespace vulkan
47 | {
48 | void LoadExtensions(VkDevice device)
49 | {
50 | LOAD_DEVICE_PROC(vkSetDebugUtilsObjectNameEXT)
51 | LOAD_DEVICE_PROC(vkCmdBeginDebugUtilsLabelEXT)
52 | LOAD_DEVICE_PROC(vkCmdEndDebugUtilsLabelEXT)
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/samples/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | #
4 | # NVIDIA CORPORATION and its licensors retain all intellectual property
5 | # and proprietary rights in and to this software, related documentation
6 | # and any modifications thereto. Any use, reproduction, disclosure or
7 | # distribution of this software and related documentation without an express
8 | # license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | #
10 |
11 | cmake_minimum_required(VERSION 3.10)
12 |
13 | project(RTXGI-Samples)
14 |
15 | set(CMAKE_CXX_STANDARD 17)
16 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
17 | set(CMAKE_CXX_EXTENSIONS ON)
18 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../bin")
19 |
20 | add_subdirectory(test-harness)
21 |
--------------------------------------------------------------------------------
/samples/test-harness/.args:
--------------------------------------------------------------------------------
1 | {
2 | "FileVersion": 2,
3 | "Items": [
4 | {
5 | "Command": "Scene Configs",
6 | "Items": [
7 | {
8 | "Command": "../../../samples/test-harness/config/cornell.ini",
9 | "DefaultChecked": true
10 | },
11 | {
12 | "Command": "../../../samples/test-harness/config/furnace.ini"
13 | },
14 | {
15 | "Command": "../../../samples/test-harness/config/multi-cornell.ini"
16 | },
17 | {
18 | "Command": "../../../samples/test-harness/config/sponza.ini"
19 | },
20 | {
21 | "Command": "../../../samples/test-harness/config/tunnel.ini"
22 | },
23 | {
24 | "Command": "../../../samples/test-harness/config/two-rooms.ini"
25 | }
26 | ]
27 | }
28 | ]
29 | }
--------------------------------------------------------------------------------
/samples/test-harness/config/cornell.ini:
--------------------------------------------------------------------------------
1 | # Note: all positions and directions are specified in the right hand, y-up coordinate system.
2 | # The Test Harness converts these positions and directions to the target coordinate system (set through CMake)
3 |
4 | # application
5 | app.width=1920
6 | app.height=1080
7 | app.vsync=1
8 | app.fullscreen=0
9 | app.renderMode=1
10 | app.showUI=1
11 | app.root=../../../samples/test-harness/
12 | app.rtxgiSDK=../../../rtxgi-sdk/
13 | app.title=RTXGI Test Harness
14 |
15 | # shader compilation
16 | shaders.warningsAsErrors=1
17 | shaders.disableOptimizations=0
18 | shaders.disableValidation=0
19 | shaders.shaderSymbols=1
20 | shaders.lifetimeMarkers=1
21 |
22 | # scene
23 | scene.name=Cornell-Box
24 | scene.path=data/gltf/cornell/
25 | scene.file=cornell.glb
26 | scene.screenshotPath=cornell
27 | scene.skyColor=0.0 0.0 0.0
28 | scene.skyIntensity=1.0
29 |
30 | # scene lights
31 | scene.lights.0.name=Ceiling Light
32 | scene.lights.0.type=2
33 | scene.lights.0.position=0.0 1.9 0.0
34 | scene.lights.0.color=1.0 1.0 1.0
35 | scene.lights.0.power=0.0
36 | scene.lights.0.radius=4.0
37 |
38 | scene.lights.1.name=Sun
39 | scene.lights.1.type=0
40 | scene.lights.1.direction=0.6 -0.435 -0.816
41 | scene.lights.1.color=1.0 1.0 1.0
42 | scene.lights.1.power=1.0
43 |
44 | scene.lights.2.name=Spot Light 1
45 | scene.lights.2.type=1
46 | scene.lights.2.position=0.0 1.0 0.5
47 | scene.lights.2.direction=0.6 -0.435 -0.816
48 | scene.lights.2.color=1.0 1.0 1.0
49 | scene.lights.2.power=0.0
50 | scene.lights.2.radius=4.0
51 | scene.lights.2.umbraAngle=1.0
52 | scene.lights.2.penumbraAngle=50.0
53 |
54 | # scene cameras
55 | scene.cameras.0.name=Default Camera
56 | scene.cameras.0.fov=45
57 | scene.cameras.0.aspect=1.77777778
58 | scene.cameras.0.yaw=0
59 | scene.cameras.0.pitch=0
60 | scene.cameras.0.position=0.1 1.0 4.0
61 |
62 | scene.cameras.1.name=Camera 2
63 | scene.cameras.1.fov=45
64 | scene.cameras.1.aspect=1.77777778
65 | scene.cameras.1.yaw=19
66 | scene.cameras.1.pitch=0.33
67 | scene.cameras.1.position=-0.5 1.0 4.0
68 |
69 | # input
70 | input.movementSpeed=2.f
71 | input.rotationSpeed=2.f
72 | input.invertPan=1
73 |
74 | # path tracer
75 | pt.rayNormalBias=0.0001
76 | pt.rayViewBias=0.0001
77 | pt.numBounces=20
78 | pt.samplesPerPixel=1
79 | pt.antialiasing=1
80 |
81 | # ddgi volumes
82 | ddgi.volume.0.name=Cornell-Box
83 | ddgi.volume.0.probeRelocation.enabled=1
84 | ddgi.volume.0.probeRelocation.minFrontfaceDistance=0.1
85 | ddgi.volume.0.probeClassification.enabled=1
86 | ddgi.volume.0.probeVariability.enabled=0
87 | ddgi.volume.0.probeVariability.threshold=0.03
88 | ddgi.volume.0.infiniteScrolling.enabled=1
89 | ddgi.volume.0.textures.rayData.format=5 # EDDGIVolumeTextureFormat::F32x2
90 | ddgi.volume.0.textures.irradiance.format=0 # EDDGIVolumeTextureFormat::U32
91 | ddgi.volume.0.textures.distance.format=2 # EDDGIVolumeTextureFormat::F16x2
92 | ddgi.volume.0.textures.data.format=3 # EDDGIVolumeTextureFormat::F16x4
93 | ddgi.volume.0.textures.variability.format=1 # EDDGIVolumeTextureFormat::F16
94 | ddgi.volume.0.origin=0.0 1.0 0.0
95 | ddgi.volume.0.probeCounts=9 9 9
96 | ddgi.volume.0.probeSpacing=0.3 0.3 0.3
97 | ddgi.volume.0.probeNumRays=256
98 | ddgi.volume.0.probeNumIrradianceTexels=8
99 | ddgi.volume.0.probeNumDistanceTexels=16
100 | ddgi.volume.0.probeHysteresis=0.97
101 | ddgi.volume.0.probeNormalBias=0.02
102 | ddgi.volume.0.probeViewBias=0.1
103 | ddgi.volume.0.probeMaxRayDistance=10
104 | ddgi.volume.0.probeIrradianceThreshold=0.2
105 | ddgi.volume.0.probeBrightnessThreshold=1.0
106 | ddgi.volume.0.vis.probeVisType=0
107 | ddgi.volume.0.vis.probeRadius=0.1
108 | ddgi.volume.0.vis.probeDistanceDivisor=3
109 | ddgi.volume.0.vis.showProbes=1
110 | ddgi.volume.0.vis.texture.irradianceScale=2
111 | ddgi.volume.0.vis.texture.distanceScale=1
112 | ddgi.volume.0.vis.texture.probeDataScale=10
113 | ddgi.volume.0.vis.texture.rayDataScale=0.56
114 | ddgi.volume.0.vis.texture.probeVariabilityScale=2.667
115 |
116 | # ray traced ambient occlusion
117 | rtao.enable=1
118 | rtao.rayLength=0.07
119 | rtao.rayNormalBias=0.01
120 | rtao.rayViewBias=0.01
121 | rtao.powerLog=-1.00
122 | rtao.filterDepthSigma=0.3
123 | rtao.filterDistanceSigma=10
124 |
125 | # post process
126 | pp.enable=1
127 | pp.exposure.enable=1
128 | pp.exposure.fstops=1.0
129 | pp.tonemap.enable=1
130 | pp.dither.enable=1
131 | pp.gamma.enable=1
132 |
--------------------------------------------------------------------------------
/samples/test-harness/config/furnace.ini:
--------------------------------------------------------------------------------
1 | # Note: all positions and directions are specified in the right hand, y-up coordinate system.
2 | # The Test Harness converts these positions and directions to the target coordinate system (set through CMake)
3 |
4 | # application
5 | app.width=1920
6 | app.height=1080
7 | app.vsync=1
8 | app.fullscreen=0
9 | app.renderMode=1
10 | app.showUI=1
11 | app.root=../../../samples/test-harness/
12 | app.rtxgiSDK=../../../rtxgi-sdk/
13 | app.title=RTXGI Test Harness
14 |
15 | # shader compilation
16 | shaders.warningsAsErrors=1
17 | shaders.disableOptimizations=0
18 | shaders.disableValidation=0
19 | shaders.shaderSymbols=0
20 | shaders.lifetimeMarkers=0
21 |
22 | # scene
23 | scene.name=Furnace
24 | scene.path=data/gltf/furnace/
25 | scene.file=furnace.glb
26 | scene.screenshotPath=furnace
27 | scene.skyColor=1.0 1.0 1.0
28 | scene.skyIntensity=1.0
29 |
30 | # scene lights
31 | # no lights
32 |
33 | # scene cameras
34 | scene.cameras.0.name=Default Camera
35 | scene.cameras.0.fov=45
36 | scene.cameras.0.aspect=1.77777778
37 | scene.cameras.0.yaw=0
38 | scene.cameras.0.pitch=0
39 | scene.cameras.0.position=0.0 1.f 4.f
40 |
41 | # input
42 | input.movementSpeed=6.f
43 | input.rotationSpeed=3.f
44 | input.invertPan=1
45 |
46 | # path tracer
47 | pt.rayNormalBias=0.0001
48 | pt.rayViewBias=0.0001
49 | pt.numBounces=20
50 | pt.samplesPerPixel=1
51 | pt.antialiasing=1
52 |
53 | # ddgi volumes
54 | ddgi.volume.0.name=Scene Volume
55 | ddgi.volume.0.probeRelocation.enabled=0
56 | ddgi.volume.0.probeRelocation.minFrontfaceDistance=0.1
57 | ddgi.volume.0.probeClassification.enabled=0
58 | ddgi.volume.0.probeVariability.enabled=0
59 | ddgi.volume.0.probeVariability.threshold=0.01
60 | ddgi.volume.0.infiniteScrolling.enabled=0
61 | ddgi.volume.0.textures.rayData.format=5 # EDDGIVolumeTextureFormat::F32x2
62 | ddgi.volume.0.textures.irradiance.format=0 # EDDGIVolumeTextureFormat::U32
63 | ddgi.volume.0.textures.distance.format=2 # EDDGIVolumeTextureFormat::F16x2
64 | ddgi.volume.0.textures.data.format=3 # EDDGIVolumeTextureFormat::F16x4
65 | ddgi.volume.0.textures.variability.format=1 # EDDGIVolumeTextureFormat::F16
66 | ddgi.volume.0.origin=0.0 0.5 0.0
67 | ddgi.volume.0.probeCounts=8 3 8
68 | ddgi.volume.0.probeSpacing=2 1 2
69 | ddgi.volume.0.probeNumRays=256
70 | ddgi.volume.0.probeNumIrradianceTexels=8
71 | ddgi.volume.0.probeNumDistanceTexels=16
72 | ddgi.volume.0.probeHysteresis=0.97
73 | ddgi.volume.0.probeNormalBias=0.2
74 | ddgi.volume.0.probeViewBias=0.1
75 | ddgi.volume.0.probeMaxRayDistance=10
76 | ddgi.volume.0.probeIrradianceThreshold=0.2
77 | ddgi.volume.0.probeBrightnessThreshold=1.0
78 | ddgi.volume.0.vis.probeVisType=0
79 | ddgi.volume.0.vis.probeRadius=0.2
80 | ddgi.volume.0.vis.probeDistanceDivisor=30
81 | ddgi.volume.0.vis.showProbes=1
82 | ddgi.volume.0.vis.texture.irradianceScale=2.0
83 | ddgi.volume.0.vis.texture.distanceScale=1.0
84 | ddgi.volume.0.vis.texture.probeDataScale=16
85 | ddgi.volume.0.vis.texture.rayDataScale=0.5
86 | ddgi.volume.0.vis.texture.probeVariabilityScale=2.667
87 |
88 | # ray traced ambient occlusion
89 | rtao.enable=1
90 | rtao.rayLength=0.07
91 | rtao.rayNormalBias=0.01
92 | rtao.rayViewBias=0.01
93 | rtao.powerLog=-1.5
94 | rtao.filterDepthSigma=0.25
95 | rtao.filterDistanceSigma=0.25
96 |
97 | # post process
98 | pp.enable=1
99 | pp.exposure.enable=1
100 | pp.exposure.fstops=1.0
101 | pp.tonemap.enable=1
102 | pp.dither.enable=1
103 | pp.gamma.enable=1
104 |
--------------------------------------------------------------------------------
/samples/test-harness/config/sponza.ini:
--------------------------------------------------------------------------------
1 | # Note: all positions and directions are specified in the right hand, y-up coordinate system.
2 | # The Test Harness converts these positions and directions to the target coordinate system (set through CMake)
3 |
4 | # application
5 | app.width=1920
6 | app.height=1080
7 | app.vsync=0
8 | app.fullscreen=0
9 | app.renderMode=1
10 | app.showUI=1
11 | app.root=../../../samples/test-harness/
12 | app.rtxgiSDK=../../../rtxgi-sdk/
13 | app.title=RTXGI Test Harness
14 |
15 | # shader compilation
16 | shaders.warningsAsErrors=1
17 | shaders.disableOptimizations=0
18 | shaders.disableValidation=0
19 | shaders.shaderSymbols=1
20 | shaders.lifetimeMarkers=1
21 |
22 | # scene
23 | scene.name=Sponza
24 | scene.path=data/gltf/sponza/
25 | scene.file=Sponza.gltf
26 | scene.screenshotPath=sponza
27 | scene.skyColor=1.0 1.0 1.0
28 | scene.skyIntensity=0.1
29 |
30 | # scene lights
31 | scene.lights.0.name=Sun
32 | scene.lights.0.type=0
33 | scene.lights.0.direction=0.0 -1.0 0.3
34 | scene.lights.0.color=1.0 1.0 1.0
35 | scene.lights.0.power=3.14
36 |
37 | # scene cameras
38 | scene.cameras.0.name=Upper Floor
39 | scene.cameras.0.fov=68
40 | scene.cameras.0.aspect=1.77777778
41 | scene.cameras.0.yaw=295.23
42 | scene.cameras.0.pitch=13.22
43 | scene.cameras.0.position=7.46 5.07 0.92
44 |
45 | scene.cameras.1.name=Lower Floor
46 | scene.cameras.1.fov=68
47 | scene.cameras.1.aspect=1.77777778
48 | scene.cameras.1.yaw=287.48
49 | scene.cameras.1.pitch=-10.01
50 | scene.cameras.1.position=8.74 1.21 0.41
51 |
52 | # input
53 | input.movementSpeed=5.f
54 | input.rotationSpeed=3.f
55 | input.invertPan=1
56 |
57 | # path tracer
58 | pt.rayViewBias=0.0001
59 | pt.rayNormalBias=0.008
60 | pt.numBounces=10
61 | pt.samplesPerPixel=1
62 | pt.antialiasing=1
63 |
64 | # ddgi volumes
65 | ddgi.volume.0.name=Scene-Volume
66 | ddgi.volume.0.probeRelocation.enabled=1
67 | ddgi.volume.0.probeRelocation.minFrontfaceDistance=0.3 # should be at least as large as probeViewBias!
68 | ddgi.volume.0.probeClassification.enabled=1
69 | ddgi.volume.0.probeVariability.enabled=1
70 | ddgi.volume.0.probeVariability.threshold=0.4
71 | ddgi.volume.0.infiniteScrolling.enabled=0
72 | ddgi.volume.0.textures.rayData.format=5 # EDDGIVolumeTextureFormat::F32x2
73 | ddgi.volume.0.textures.irradiance.format=0 # EDDGIVolumeTextureFormat::U32
74 | ddgi.volume.0.textures.distance.format=2 # EDDGIVolumeTextureFormat::F16x2
75 | ddgi.volume.0.textures.data.format=3 # EDDGIVolumeTextureFormat::F16x4
76 | ddgi.volume.0.textures.variability.format=1 # EDDGIVolumeTextureFormat::F16
77 | ddgi.volume.0.origin=-0.4 5.4 -0.25
78 | ddgi.volume.0.probeCounts=22 22 22
79 | ddgi.volume.0.probeSpacing=1.02 0.5 0.45
80 | ddgi.volume.0.probeNumRays=256
81 | ddgi.volume.0.probeNumIrradianceTexels=8
82 | ddgi.volume.0.probeNumDistanceTexels=16
83 | ddgi.volume.0.probeHysteresis=0.97
84 | ddgi.volume.0.probeNormalBias=0.1
85 | ddgi.volume.0.probeViewBias=0.3
86 | ddgi.volume.0.probeMaxRayDistance=10000
87 | ddgi.volume.0.probeIrradianceThreshold=0.2
88 | ddgi.volume.0.probeBrightnessThreshold=1.0
89 | ddgi.volume.0.vis.probeVisType=1
90 | ddgi.volume.0.vis.probeRadius=0.1
91 | ddgi.volume.0.vis.probeDistanceDivisor=200
92 | ddgi.volume.0.vis.showProbes=1
93 | ddgi.volume.0.vis.texture.irradianceScale=0.36
94 | ddgi.volume.0.vis.texture.distanceScale=0.18
95 | ddgi.volume.0.vis.texture.probeDataScale=2.88
96 | ddgi.volume.0.vis.texture.rayDataScale=0.247
97 | ddgi.volume.0.vis.texture.probeVariabilityScale=0.479
98 |
99 | # ray traced ambient occlusion
100 | rtao.enable=1
101 | rtao.rayLength=0.25
102 | rtao.rayNormalBias=0.001
103 | rtao.rayViewBias=0.001
104 | rtao.powerLog=5.0
105 | rtao.filterDistanceSigma=3.0
106 | rtao.filterDepthSigma=0.1
107 |
108 | # post process
109 | pp.enable=1
110 | pp.exposure.enable=1
111 | pp.exposure.fstops=1.0
112 | pp.tonemap.enable=1
113 | pp.dither.enable=1
114 | pp.gamma.enable=1
115 |
--------------------------------------------------------------------------------
/samples/test-harness/config/tunnel.ini:
--------------------------------------------------------------------------------
1 | # Note: all positions and directions are specified in the right hand, y-up coordinate system.
2 | # The Test Harness converts these positions and directions to the target coordinate system (set through CMake)
3 |
4 | # application
5 | app.width=1920
6 | app.height=1080
7 | app.vsync=1
8 | app.fullscreen=0
9 | app.renderMode=1
10 | app.showUI=1
11 | app.root=../../../samples/test-harness/
12 | app.rtxgiSDK=../../../rtxgi-sdk/
13 | app.title=RTXGI Test Harness
14 |
15 | # shader compilation
16 | shaders.warningsAsErrors=1
17 | shaders.disableOptimizations=0
18 | shaders.disableValidation=0
19 | shaders.shaderSymbols=0
20 | shaders.lifetimeMarkers=0
21 |
22 | # scene
23 | scene.name=Tunnel
24 | scene.path=data/gltf/tunnel/
25 | scene.file=tunnel.glb
26 | scene.screenshotPath=tunnel
27 | scene.skyColor=0.0 0.0 0.0
28 | scene.skyIntensity=1.0
29 |
30 | # scene lights
31 | scene.lights.0.name=Sun
32 | scene.lights.0.type=0
33 | scene.lights.0.direction=1.0 -1.0 -0.7
34 | scene.lights.0.color=1.0 1.0 1.0
35 | scene.lights.0.power=2.2
36 |
37 | # scene cameras
38 | scene.cameras.0.name=Default Camera
39 | scene.cameras.0.fov=45
40 | scene.cameras.0.aspect=1.77777778
41 | scene.cameras.0.yaw=75.67
42 | scene.cameras.0.pitch=-0.25
43 | scene.cameras.0.position=55.78 8.10 5.08
44 |
45 | # input
46 | input.movementSpeed=80.f
47 | input.rotationSpeed=2.f
48 | input.invertPan=1
49 |
50 | # path tracer
51 | pt.rayNormalBias=0.0001
52 | pt.rayViewBias=0.0001
53 | pt.numBounces=5
54 | pt.samplesPerPixel=1
55 | pt.antialiasing=1
56 |
57 | # ddgi volumes
58 | ddgi.volume.0.name=Infinite Scrolling Volume
59 | ddgi.volume.0.probeRelocation.enabled=1
60 | ddgi.volume.0.probeRelocation.minFrontfaceDistance=2.2
61 | ddgi.volume.0.probeClassification.enabled=1
62 | ddgi.volume.0.probeVariability.enabled=1
63 | ddgi.volume.0.probeVariability.threshold=0.02
64 | ddgi.volume.0.infiniteScrolling.enabled=1
65 | ddgi.volume.0.textures.rayData.format=6 # EDDGIVolumeTextureFormat::F32x4
66 | ddgi.volume.0.textures.irradiance.format=6 # EDDGIVolumeTextureFormat::F32x4
67 | ddgi.volume.0.textures.distance.format=2 # EDDGIVolumeTextureFormat::F16x2
68 | ddgi.volume.0.textures.data.format=3 # EDDGIVolumeTextureFormat::F16x4
69 | ddgi.volume.0.textures.variability.format=1 # EDDGIVolumeTextureFormat::F16
70 | ddgi.volume.0.origin=128.129 11.62 -13.673
71 | ddgi.volume.0.probeCounts=24 9 12
72 | ddgi.volume.0.probeSpacing=5 2.5 5
73 | ddgi.volume.0.probeNumRays=768
74 | ddgi.volume.0.probeNumIrradianceTexels=8
75 | ddgi.volume.0.probeNumDistanceTexels=16
76 | ddgi.volume.0.probeHysteresis=0.97
77 | ddgi.volume.0.probeNormalBias=0.75
78 | ddgi.volume.0.probeViewBias=2.0
79 | ddgi.volume.0.probeMaxRayDistance=1000
80 | ddgi.volume.0.probeIrradianceThreshold=0.2
81 | ddgi.volume.0.probeBrightnessThreshold=1.0
82 | ddgi.volume.0.vis.probeVisType=0
83 | ddgi.volume.0.vis.probeRadius=1.0
84 | ddgi.volume.0.vis.probeDistanceDivisor=3
85 | ddgi.volume.0.vis.showProbes=1
86 | ddgi.volume.0.vis.texture.irradianceScale=0.8
87 | ddgi.volume.0.vis.texture.distanceScale=0.4
88 | ddgi.volume.0.vis.texture.probeDataScale=6.4
89 | ddgi.volume.0.vis.texture.rayDataScale=0.2
90 | ddgi.volume.0.vis.texture.probeVariabilityScale=1.066
91 |
92 | # ray traced ambient occlusion
93 | rtao.enable=1
94 | rtao.rayLength=1.0
95 | rtao.rayNormalBias=0.01
96 | rtao.rayViewBias=0.01
97 | rtao.powerLog=-2.15
98 | rtao.filterDepthSigma=0.3
99 | rtao.filterDistanceSigma=10
100 |
101 | # post process
102 | pp.enable=1
103 | pp.exposure.enable=1
104 | pp.exposure.fstops=1.0
105 | pp.tonemap.enable=1
106 | pp.dither.enable=1
107 | pp.gamma.enable=1
108 |
--------------------------------------------------------------------------------
/samples/test-harness/config/two-rooms.ini:
--------------------------------------------------------------------------------
1 | # Note: all positions and directions are specified in the right hand, y-up coordinate system.
2 | # The Test Harness converts these positions and directions to the target coordinate system (set through CMake)
3 |
4 | # application
5 | app.width=1920
6 | app.height=1080
7 | app.vsync=1
8 | app.fullscreen=0
9 | app.renderMode=1
10 | app.showUI=1
11 | app.root=../../../samples/test-harness/
12 | app.rtxgiSDK=../../../rtxgi-sdk/
13 | app.title=RTXGI Test Harness
14 |
15 | # shader compilation
16 | shaders.warningsAsErrors=1
17 | shaders.disableOptimizations=0
18 | shaders.disableValidation=0
19 | shaders.shaderSymbols=0
20 | shaders.lifetimeMarkers=0
21 |
22 | # scene
23 | scene.name=Two-Rooms
24 | scene.path=data/gltf/two-rooms/
25 | scene.file=two-rooms.glb
26 | scene.screenshotPath=two-rooms
27 | scene.skyColor=0 0 0
28 | scene.skyIntensity=1.0
29 |
30 | # scene lights
31 | scene.lights.0.name=Sun
32 | scene.lights.0.type=0
33 | scene.lights.0.color=1.0 1.0 1.0
34 | scene.lights.0.power=2.25
35 | scene.lights.0.direction=-0.95 -0.21 -0.21
36 |
37 | # scene cameras
38 | scene.cameras.0.name=Open Room
39 | scene.cameras.0.fov=45
40 | scene.cameras.0.aspect=1.77777778
41 | scene.cameras.0.yaw=114.80
42 | scene.cameras.0.pitch=7.31
43 | scene.cameras.0.position=-93.44 32.41 11.56
44 |
45 | scene.cameras.1.name=Closed Room
46 | scene.cameras.1.fov=45
47 | scene.cameras.1.aspect=1.77777778
48 | scene.cameras.1.yaw=97.93
49 | scene.cameras.1.pitch=8.31
50 | scene.cameras.1.position=-42.60 36.41 -53.41
51 |
52 | scene.cameras.2.name=Outside
53 | scene.cameras.2.fov=45
54 | scene.cameras.2.aspect=1.77777778
55 | scene.cameras.2.yaw=-64.57
56 | scene.cameras.2.pitch=13.31
57 | scene.cameras.2.position=324.19 96.37 104.09
58 |
59 | # input
60 | input.movementSpeed=200.f
61 | input.rotationSpeed=3.f
62 | input.invertPan=1
63 |
64 | # path tracer
65 | pt.rayViewBias=0.04
66 | pt.rayNormalBias=0.1
67 | pt.numBounces=20
68 | pt.samplesPerPixel=1
69 | pt.antialiasing=1
70 |
71 | # ddgi volumes
72 | ddgi.volume.0.name=Rooms Volume
73 | ddgi.volume.0.probeRelocation.enabled=1
74 | ddgi.volume.0.probeRelocation.minFrontfaceDistance=0.1
75 | ddgi.volume.0.probeClassification.enabled=1
76 | ddgi.volume.0.probeVariability.enabled=1
77 | ddgi.volume.0.probeVariability.threshold=0.03
78 | ddgi.volume.0.infiniteScrolling.enabled=1
79 | ddgi.volume.0.textures.rayData.format=5 # EDDGIVolumeTextureFormat::F32x2
80 | ddgi.volume.0.textures.irradiance.format=0 # EDDGIVolumeTextureFormat::U32
81 | ddgi.volume.0.textures.distance.format=2 # EDDGIVolumeTextureFormat::F16x2
82 | ddgi.volume.0.textures.data.format=3 # EDDGIVolumeTextureFormat::F16x4
83 | ddgi.volume.0.textures.variability.format=1 # EDDGIVolumeTextureFormat::F16
84 | ddgi.volume.0.origin=0.0 24.0 0.0
85 | ddgi.volume.0.probeCounts=32 6 32
86 | ddgi.volume.0.probeSpacing=11 11 11
87 | ddgi.volume.0.probeNumRays=256
88 | ddgi.volume.0.probeNumIrradianceTexels=8
89 | ddgi.volume.0.probeNumDistanceTexels=16
90 | ddgi.volume.0.probeHysteresis=0.97
91 | ddgi.volume.0.probeNormalBias=1.0
92 | ddgi.volume.0.probeViewBias=6.0
93 | ddgi.volume.0.probeMaxRayDistance=10000
94 | ddgi.volume.0.probeIrradianceThreshold=0.2
95 | ddgi.volume.0.probeBrightnessThreshold=0.22
96 | ddgi.volume.0.vis.probeVisType=1
97 | ddgi.volume.0.vis.probeRadius=2.0
98 | ddgi.volume.0.vis.probeDistanceDivisor=30
99 | ddgi.volume.0.vis.showProbes=1
100 | ddgi.volume.0.vis.texture.irradianceScale=0.7
101 | ddgi.volume.0.vis.texture.distanceScale=0.35
102 | ddgi.volume.0.vis.texture.probeDataScale=3
103 | ddgi.volume.0.vis.texture.rayDataScale=0.49
104 | ddgi.volume.0.vis.texture.probeVariabilityScale=0.933
105 |
106 | # ray traced ambient occlusion
107 | rtao.enable=1
108 | rtao.rayLength=2.0
109 | rtao.rayNormalBias=0.0001
110 | rtao.rayViewBias=0.0001
111 | rtao.powerLog=-1.5
112 | rtao.filterDistanceSigma=2.0
113 | rtao.filterDepthSigma=2.0
114 |
115 | # post process
116 | pp.enable=1
117 | pp.exposure.enable=1
118 | pp.exposure.fstops=1.0
119 | pp.tonemap.enable=1
120 | pp.dither.enable=1
121 | pp.gamma.enable=1
122 |
--------------------------------------------------------------------------------
/samples/test-harness/data/gltf/cornell/cornell.glb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/samples/test-harness/data/gltf/cornell/cornell.glb
--------------------------------------------------------------------------------
/samples/test-harness/data/gltf/furnace/furnace.glb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/samples/test-harness/data/gltf/furnace/furnace.glb
--------------------------------------------------------------------------------
/samples/test-harness/data/gltf/multi-cornell/multi-cornell.glb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/samples/test-harness/data/gltf/multi-cornell/multi-cornell.glb
--------------------------------------------------------------------------------
/samples/test-harness/data/gltf/sponza/README.md:
--------------------------------------------------------------------------------
1 | # Using Sponza in the RTXGI Test Harness
2 |
3 | To get the Sponza rendering with RTXGI in the Test Harness, follow these steps:
4 |
5 | 1. Clone https://github.com/KhronosGroup/glTF-Sample-Models to somewhere on your machine (but don't clone it inside of this project).
6 | 2. Copy or move the contents of https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/Sponza/glTF into ```this directory```.
7 | 3. Change the Test Harness project's launch arguments to use the Sponza configuration file (```samples/test-harness/config/sponza.ini```)
8 | * If using Visual Studio, modify the Test Harness project's ```Command Arguments```:
9 |
10 | ```Project->Properties->Debugging->CommandArguments: ../../../samples/test-harness/config/sponza.ini```
11 |
12 | * If using Visual Studio Code, modify the ```samples/test-harness/launch.json``` file's ```args``` field:
13 |
14 | ```"args": [ "../../test-harness/config/sponza.ini" ]```
15 |
16 | 4. Run the Test Harness.
17 |
18 | ## Important Note
19 | On the first run (only), the test harness loads all scene textures, compresses them to BC7 format, generates mipmaps, and writes all scene data to a binary cache file (```Sponza.cache``` in this case).
20 |
21 | The texture processing steps use the [DirectXTex library](https://github.com/microsoft/DirectXTex). If on Windows, the library performs compression with the GPU and D3D11. On Linux, compression is performed entirely on the CPU and is quite slow as a result. It is recommended to generate scene cache files on Windows if possible.
--------------------------------------------------------------------------------
/samples/test-harness/data/gltf/tunnel/tunnel.glb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/samples/test-harness/data/gltf/tunnel/tunnel.glb
--------------------------------------------------------------------------------
/samples/test-harness/data/gltf/two-rooms/two-rooms.glb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/samples/test-harness/data/gltf/two-rooms/two-rooms.glb
--------------------------------------------------------------------------------
/samples/test-harness/data/textures/blue-noise-rgb-256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/samples/test-harness/data/textures/blue-noise-rgb-256.png
--------------------------------------------------------------------------------
/samples/test-harness/include/Benchmark.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Instrumentation.h"
14 | #include "Configs.h"
15 | #include "Graphics.h"
16 |
17 | #include
18 |
19 | namespace Benchmark
20 | {
21 | const static uint32_t NumBenchmarkFrames = 1024;
22 |
23 | struct BenchmarkRun
24 | {
25 | uint32_t numFramesBenched = 0;
26 | std::stringstream cpuTimingCsv;
27 | std::stringstream gpuTimingCsv;
28 | };
29 | void StartBenchmark(BenchmarkRun& benchmarkRun, Instrumentation::Performance& perf, Configs::Config& config, Graphics::Globals& gfx);
30 | bool UpdateBenchmark(BenchmarkRun& benchmarkRun, Instrumentation::Performance& perf, Configs::Config& config, Graphics::Globals& gfx, std::ofstream& log);
31 | }
32 |
--------------------------------------------------------------------------------
/samples/test-harness/include/Caches.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Scenes.h"
14 |
15 | namespace Caches
16 | {
17 | bool Serialize(const std::string& filepath, Scenes::Scene& scene, std::ofstream& log);
18 | bool Deserialize(const std::string& filepath, Scenes::Scene& scene, std::ofstream& log);
19 | }
20 |
--------------------------------------------------------------------------------
/samples/test-harness/include/Common.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #if defined(_WIN32) || defined(WIN32)
14 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used items from Windows headers
15 | #define NOMINMAX // Exclude Windows defines of min and max
16 | #include
17 | #include
18 | #endif
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 |
26 | #include
27 |
28 | #if defined(_WIN32) || defined(WIN32)
29 | #include // for IUnknown interface that IDxCBlob extends
30 | #elif __linux__
31 | #include "thirdparty/directx/winadapter.h" // Windows adapter for Linux
32 | #endif
33 |
34 | #include // Removes sal.h include since this is covered by winadapter.h on Linux
35 |
36 | #ifdef API_VULKAN
37 | #define GLFW_INCLUDE_VULKAN
38 | #endif
39 | #include
40 |
41 | #if defined(API_D3D12) && defined(_WIN32) || defined(WIN32)
42 | #define GLFW_EXPOSE_NATIVE_WIN32
43 | #include
44 | #endif
45 |
46 | #if _DEBUG
47 | #define _CRTDBG_MAP_ALLOC
48 | #include
49 | #if defined(_WIN32) || defined(WIN32)
50 | #include
51 | #elif __linux__
52 | // TODO: memory leak checking on UNIX
53 | #endif
54 | #endif
55 |
56 | enum class ERenderMode
57 | {
58 | PATH_TRACE = 0,
59 | DDGI,
60 | Count
61 | };
62 |
63 | enum class ELightType
64 | {
65 | DIRECTIONAL,
66 | SPOT,
67 | POINT,
68 | COUNT
69 | };
70 |
71 | // Macros
72 | #define SAFE_RELEASE(x) { if (x) { x->Release(); x = 0; } }
73 | #define SAFE_DELETE(x) { if(x) delete x; x = NULL; }
74 | #define SAFE_DELETE_ARRAY(x) { if(x) delete[] x; x = NULL; }
75 | #define ALIGN(_alignment, _val) (((_val + _alignment - 1) / _alignment) * _alignment)
76 | #define CHECK(status, message, log) if(!status) { log << "\nFailed to " << message; std::flush(log); return false; }
77 |
78 | inline static uint32_t DivRoundUp(uint32_t x, uint32_t y)
79 | {
80 | if (x % y) return 1 + x / y;
81 | else return x / y;
82 | }
83 |
84 | // Defines
85 | #define COORDINATE_SYSTEM_LEFT 0
86 | #define COORDINATE_SYSTEM_LEFT_Z_UP 1
87 | #define COORDINATE_SYSTEM_RIGHT 2
88 | #define COORDINATE_SYSTEM_RIGHT_Z_UP 3
89 | // #define COORDINATE_SYSTEM COORDINATE_SYSTEM_RIGHT // set by CMake
90 |
91 | inline const char* GetCoordinateSystemName(uint32_t coordinateSystem)
92 | {
93 | if(coordinateSystem == 0) return "Left Hand, Y-Up";
94 | else if(coordinateSystem == 1) return "Left Hand, Z-Up";
95 | else if(coordinateSystem == 2) return "Right Hand, Y-Up";
96 | else if(coordinateSystem == 3) return "Right Hand, Z-Up";
97 | else return "Unknown";
98 | }
99 |
100 | #if defined(_WIN32) || defined(WIN32)
101 | #define GPU_COMPRESSION
102 | #endif
103 |
--------------------------------------------------------------------------------
/samples/test-harness/include/Geometry.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 | #pragma once
11 |
12 | #include "Scenes.h"
13 |
14 | namespace Geometry
15 | {
16 | void CreateSphere(uint32_t latitudes, uint32_t longitudes, Scenes::Mesh& mesh);
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/samples/test-harness/include/Graphics.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Common.h"
14 | #include "Shaders.h"
15 | #include "Scenes.h"
16 | #include "Instrumentation.h"
17 |
18 | const int MAX_FRAMES_IN_FLIGHT = 2;
19 | const int MAX_TLAS = 2;
20 | const int MAX_TEXTURES = 300;
21 | const int MAX_DDGIVOLUMES = 6;
22 | const int MAX_TIMESTAMPS = 200;
23 |
24 | #define RTXGI_BINDLESS_TYPE_RESOURCE_ARRAYS 0
25 | #define RTXGI_BINDLESS_TYPE_DESCRIPTOR_HEAP 1
26 |
27 | #define GFX_PERF_INSTRUMENTATION
28 |
29 | #ifdef GFX_PERF_MARKERS
30 | #define GFX_PERF_MARKER_RED 204, 28, 41
31 | #define GFX_PERF_MARKER_GREEN 105, 148, 79
32 | #define GFX_PERF_MARKER_BLUE 65, 126, 211
33 | #define GFX_PERF_MARKER_ORANGE 217, 122, 46
34 | #define GFX_PERF_MARKER_YELLOW 217, 207, 46
35 | #define GFX_PERF_MARKER_PURPLE 152, 78, 163
36 | #define GFX_PERF_MARKER_BROWN 166, 86, 40
37 | #define GFX_PERF_MARKER_GREY 190, 190, 190
38 | #endif
39 |
40 | #if (defined(_WIN32) || defined(WIN32)) && defined(API_D3D12)
41 | #include "Direct3D12.h"
42 | #endif
43 |
44 | #if defined(API_VULKAN)
45 | #include "Vulkan.h"
46 | #endif
47 |
48 | namespace Graphics
49 | {
50 | bool CreateDevice(Globals& gfx, Configs::Config& config);
51 | bool Initialize(const Configs::Config& config, Scenes::Scene& scene, Globals& gfx, GlobalResources& resources, std::ofstream& log);
52 | bool PostInitialize(Globals& gfx, std::ofstream& log);
53 | void Update(Globals& gfx, GlobalResources& gfxResources, const Configs::Config& config, Scenes::Scene& scene);
54 | bool ResizeBegin(Globals& gfx, GlobalResources& resources, int width, int height, std::ofstream& log);
55 | bool ResizeEnd(Globals& gfx);
56 | bool ToggleFullscreen(Globals& gfx);
57 | bool ResetCmdList(Globals& gfx);
58 | bool SubmitCmdList(Globals& gfx);
59 | bool Present(Globals& gfx);
60 | bool WaitForGPU(Globals& gfx);
61 | bool WaitForPrevGPUFrame(Globals& gfx);
62 | bool MoveToNextFrame(Globals& gfx);
63 | void Cleanup(Globals& gfx, GlobalResources& gfxResources);
64 |
65 | #ifdef GFX_PERF_INSTRUMENTATION
66 | void BeginFrame(Globals& gfx, GlobalResources& gfxResources, Instrumentation::Performance& performance);
67 | void EndFrame(Globals& gfx, GlobalResources& gfxResources, Instrumentation::Performance& performance);
68 | void ResolveTimestamps(Globals& gfx, GlobalResources& gfxResources, Instrumentation::Performance& performance);
69 | bool UpdateTimestamps(Globals& gfx, GlobalResources& gfxResources, Instrumentation::Performance& performance);
70 | #endif
71 |
72 | bool WriteBackBufferToDisk(Globals& gfx, std::string directory);
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/samples/test-harness/include/ImageCapture.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include
14 | #include
15 |
16 | #if defined(_WIN32) || defined(WIN32)
17 | #include
18 | #include
19 | #include
20 | #endif
21 |
22 | namespace ImageCapture
23 | {
24 | const static uint32_t NumChannels = 4;
25 | bool CapturePng(std::string file, uint32_t width, uint32_t height, const unsigned char* data);
26 |
27 | #if defined(_WIN32) || defined(WIN32)
28 | IWICImagingFactory2* CreateWICImagingFactory();
29 | HRESULT ConvertTextureResource(const D3D12_RESOURCE_DESC desc, UINT64 imageSize, UINT64 dstRowPitch, unsigned char* pMappedMemory, std::vector& converted);
30 | #endif
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/samples/test-harness/include/Inputs.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Common.h"
14 | #include "Configs.h"
15 | #include "Scenes.h"
16 |
17 | namespace Inputs
18 | {
19 | enum class EInputEvent
20 | {
21 | NONE = 0,
22 | QUIT,
23 | RELOAD,
24 | SCREENSHOT,
25 | SAVE_IMAGES,
26 | CAMERA_MOVEMENT,
27 | FULLSCREEN_CHANGE,
28 | RUN_BENCHMARK,
29 | COUNT
30 | };
31 |
32 | struct Input
33 | {
34 | EInputEvent event = EInputEvent::NONE;
35 | DirectX::XMINT2 mousePos = { INT_MAX, INT_MAX };
36 | DirectX::XMINT2 prevMousePos = { INT_MAX, INT_MAX };
37 | bool mouseLeftBtnDown = false;
38 | bool mouseRightBtnDown = false;
39 | };
40 |
41 | bool Initialize(GLFWwindow* window, Input& input, Configs::Config& config, Scenes::Scene& scene);
42 | void PollInputs(GLFWwindow* window);
43 | }
44 |
--------------------------------------------------------------------------------
/samples/test-harness/include/Shaders.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Common.h"
14 | #include "Configs.h"
15 |
16 | #include
17 |
18 | namespace Shaders
19 | {
20 | struct ShaderCompiler
21 | {
22 | #if _WIN32
23 | HINSTANCE dll = nullptr;
24 | #elif __linux__
25 | void* dll = nullptr;
26 | #endif
27 | IDxcUtils* utils = nullptr;
28 | IDxcCompiler3* compiler = nullptr;
29 | IDxcIncludeHandler* includes = nullptr;
30 |
31 | DxcCreateInstanceProc DxcCreateInstance = nullptr;
32 | Configs::Shaders config = {};
33 |
34 | std::string root = "";
35 | std::string rtxgi = "";
36 | };
37 |
38 | struct ShaderProgram
39 | {
40 | std::wstring filepath = L"";
41 | std::wstring targetProfile = L"lib_6_6";
42 | std::wstring entryPoint = L"";
43 | std::wstring exportName = L"";
44 | std::wstring includePath = L"";
45 | std::vector arguments;
46 | std::vector defineStrs;
47 | std::vector defines;
48 |
49 | IDxcBlob* bytecode = nullptr;
50 | IDxcBlobWide* shaderName = nullptr;
51 |
52 | void Release()
53 | {
54 | for (size_t defineIndex = 0; defineIndex < defineStrs.size(); defineIndex++)
55 | {
56 | SAFE_DELETE(defineStrs[defineIndex]);
57 | }
58 | defineStrs.clear();
59 | defines.clear();
60 | arguments.clear();
61 | SAFE_RELEASE(bytecode);
62 | SAFE_RELEASE(shaderName);
63 | }
64 | };
65 |
66 | struct ShaderPipeline
67 | {
68 | ShaderProgram vs;
69 | ShaderProgram ps;
70 | uint32_t numStages() const { return 2; };
71 |
72 | void Release()
73 | {
74 | vs.Release();
75 | ps.Release();
76 | }
77 | };
78 |
79 | struct ShaderRTHitGroup
80 | {
81 | ShaderProgram chs;
82 | ShaderProgram ahs;
83 | ShaderProgram is;
84 | LPCWSTR exportName = L"";
85 |
86 | bool hasCHS() const { return (chs.bytecode != nullptr); }
87 | bool hasAHS() const { return (ahs.bytecode != nullptr); }
88 | bool hasIS() const { return (is.bytecode != nullptr); }
89 | uint32_t numStages() const { return (hasCHS() + hasAHS() + hasIS()); }
90 | uint32_t numSubobjects() const { return (1 + numStages()); }
91 |
92 | void Release()
93 | {
94 | chs.Release();
95 | ahs.Release();
96 | is.Release();
97 | }
98 | };
99 |
100 | struct ShaderRTPipeline
101 | {
102 | uint32_t payloadSizeInBytes = 0;
103 |
104 | ShaderProgram rgs;
105 | ShaderProgram miss;
106 | std::vector hitGroups;
107 |
108 | void Release()
109 | {
110 | rgs.Release();
111 | miss.Release();
112 | for (uint32_t hitGroupIndex = 0; hitGroupIndex < static_cast(hitGroups.size()); hitGroupIndex++)
113 | {
114 | hitGroups[hitGroupIndex].Release();
115 | }
116 | hitGroups.clear();
117 | }
118 | };
119 |
120 | bool Initialize(const Configs::Config& config, ShaderCompiler& compiler);
121 | void AddDefine(ShaderProgram& shader, std::wstring name, std::wstring value);
122 | bool Compile(ShaderCompiler& compiler, ShaderProgram& shader, bool warningsAsErrors = true);
123 | void Cleanup(ShaderCompiler& compiler);
124 | }
125 |
--------------------------------------------------------------------------------
/samples/test-harness/include/Textures.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Common.h"
14 |
15 | namespace Textures
16 | {
17 | enum class ETextureType
18 | {
19 | ENGINE = 0,
20 | SCENE,
21 | };
22 |
23 | enum class ETextureFormat
24 | {
25 | UNCOMPRESSED = 0,
26 | BC7,
27 | };
28 |
29 | struct Texture
30 | {
31 | std::string name = "";
32 | std::string filepath = "";
33 |
34 | ETextureType type = ETextureType::SCENE;
35 | ETextureFormat format = ETextureFormat::UNCOMPRESSED;
36 |
37 | uint32_t width = 0;
38 | uint32_t height = 0;
39 | uint32_t stride = 0;
40 | uint32_t mips = 0;
41 |
42 | uint64_t texelBytes = 0; // the number of bytes (aligned, all mips)
43 | uint8_t* texels = nullptr;
44 |
45 | bool cached = false;
46 |
47 | void SetName(std::string n)
48 | {
49 | if (strcmp(name.c_str(), "") == 0) { name = n; }
50 | }
51 | };
52 |
53 | #if defined(GPU_COMPRESSION)
54 | bool Initialize();
55 | void Cleanup();
56 | #endif
57 |
58 | bool Load(Texture& texture);
59 | void Unload(Texture& texture);
60 | uint32_t GetBC7TextureSizeInBytes(uint32_t width, uint32_t height);
61 | #if defined(__x86_64__) || defined(_M_X64)
62 | bool Compress(Texture& texture, bool quick = false);
63 | bool MipmapAndCompress(Texture& texture, bool quick = false);
64 | #endif
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/samples/test-harness/include/Visualization.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Graphics.h"
14 |
15 | namespace Graphics
16 | {
17 | namespace Vis
18 | {
19 | namespace DDGI
20 | {
21 | struct Resources
22 | {
23 | // TLAS instances
24 | // ProbeVis TLAS / BLAS
25 | // Shaders
26 |
27 | // Scene Ray Tracing Acceleration Structures
28 | AccelerationStructure blas;
29 | AccelerationStructure tlas;
30 |
31 | // Procedural Geometry
32 | ID3D12Resource* sphereVB = nullptr;
33 | ID3D12Resource* sphereIB = nullptr;
34 | D3D12_VERTEX_BUFFER_VIEW sphereVBView;
35 | D3D12_INDEX_BUFFER_VIEW sphereIBView;
36 |
37 | // Shader Table
38 | ID3D12Resource* shaderTable = nullptr;
39 | UINT shaderTableRecordSize = 0;
40 |
41 | // A global root signature for bindless resource access
42 | ID3D12RootSignature* rootSignature = nullptr;
43 |
44 |
45 | };
46 |
47 | void Initialize(GfxGlobals& gfx, Resources& resources, Shaders::ShaderCompiler& shaderCompiler);
48 |
49 | // TODO: need config options and target buffer
50 | void RenderBuffers(GfxGlobals& gfx, Resources& resources, size_t volumeIndex = 0);
51 |
52 | // TODO: need a camera and target buffer
53 | void RenderProbes(GfxGlobals& gfx, Resources &resources, size_t volumeIndex = 0);
54 |
55 | void Cleanup(Resources& resources);
56 |
57 | enum class DescriptorHeapOffsets
58 | {
59 | // Constant Buffer Views
60 | CBV_CAMERAS = 0, // 0: 1 CBV for the cameras constant buffer
61 | CBV_DDGIVOLUMES = CBV_CAMERAS + 1, // 1: 1 CBV for the DDGIVolumes constant buffer
62 |
63 | // Unordered Access Views
64 | UAV_GBUFFER = CBV_DDGIVOLUMES + 1, // 2: 2 UAV for the GBuffer A, B RWTextures
65 | UAV_DDGIVOLUME = UAV_GBUFFER + 2, // 4: 8 UAV, 2 UAV per DDGIVolume (Radiance and OffsetStates)
66 | UAV_TLAS_INST = UAV_DDGIVOLUME + (2 * MAX_DDGIVOLUMES), // 12: 2 UAV for the TLAS Instances
67 |
68 | // Shader Resource Views
69 | SRV_PROBEVIS_BVH = UAV_TLAS_INST + 1, // 13: 1 SRV for the ProbeVis BVH
70 | SRV_DDGIVOLUME = SRV_PROBEVIS_BVH + 1, // 14: 8 SRV, 2 SRV per DDGIVolume (Irradiance and Distance)
71 | SRV_INDICES = SRV_DDGIVOLUME + (2 * MAX_DDGIVOLUMES), // 23: 1 SRV for the Sphere Index Buffer
72 | SRV_VERTICES = SRV_INDICES + 1, // 24: 1 SRV for the Sphere Vertex Buffer
73 | };
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/samples/test-harness/include/VulkanExtensions.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #if _WIN32
14 | #define VK_USE_PLATFORM_WIN32_KHR
15 | #elif __linux__
16 | #define VK_USE_PLATFORM_XLIB_KHR
17 | #endif
18 | #include
19 |
20 | void LoadDeviceExtensions(VkDevice device);
21 | void LoadInstanceExtensions(VkInstance instance);
22 |
--------------------------------------------------------------------------------
/samples/test-harness/include/Window.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Common.h"
14 | #include "Configs.h"
15 |
16 | namespace Windows
17 | {
18 | enum class EWindowEvent
19 | {
20 | NONE = 0,
21 | RESIZE,
22 | QUIT,
23 | COUNT
24 | };
25 |
26 | bool Create(Configs::Config& config, GLFWwindow*& window);
27 | bool Close(GLFWwindow*& window);
28 |
29 | const EWindowEvent GetWindowEvent();
30 | void ResetWindowEvent();
31 | }
32 |
--------------------------------------------------------------------------------
/samples/test-harness/include/graphics/Composite.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Graphics.h"
14 |
15 | #ifdef GFX_PERF_INSTRUMENTATION
16 | #include "Instrumentation.h"
17 | #endif
18 |
19 | #if defined(API_D3D12)
20 | #include "Composite_D3D12.h"
21 | #elif defined(API_VULKAN)
22 | #include "Composite_VK.h"
23 | #endif
24 |
25 | namespace Graphics
26 | {
27 | namespace Composite
28 | {
29 | bool Initialize(Globals& globals, GlobalResources& gfxResources, Resources& resources, Instrumentation::Performance& perf, std::ofstream& log);
30 | bool Reload(Globals& globals, GlobalResources& gfxResources, Resources& resources, std::ofstream& log);
31 | bool Resize(Globals& globals, GlobalResources& gfxResources, Resources& resources, std::ofstream& log);
32 | void Update(Globals& globals, GlobalResources& gfxResources, Resources& resources, const Configs::Config& config);
33 | void Execute(Globals& globals, GlobalResources& gfxResources, Resources& resources);
34 | void Cleanup(Globals& globals, Resources& resources);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/samples/test-harness/include/graphics/Composite_D3D12.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Graphics.h"
14 |
15 | namespace Graphics
16 | {
17 | namespace D3D12
18 | {
19 | namespace Composite
20 | {
21 | struct Resources
22 | {
23 | Shaders::ShaderPipeline shaders;
24 | ID3D12PipelineState* pso = nullptr;
25 |
26 | Instrumentation::Stat* cpuStat = nullptr;
27 | Instrumentation::Stat* gpuStat = nullptr;
28 | };
29 | }
30 | }
31 |
32 | namespace Composite
33 | {
34 | using Resources = Graphics::D3D12::Composite::Resources;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/samples/test-harness/include/graphics/Composite_VK.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Graphics.h"
14 |
15 | namespace Graphics
16 | {
17 | namespace Vulkan
18 | {
19 | namespace Composite
20 | {
21 | struct Resources
22 | {
23 | Shaders::ShaderPipeline shaders;
24 | ShaderModules modules;
25 |
26 | VkDescriptorSet descriptorSet = nullptr;
27 | VkPipeline pipeline = nullptr;
28 |
29 | Instrumentation::Stat* cpuStat = nullptr;
30 | Instrumentation::Stat* gpuStat = nullptr;
31 | };
32 | }
33 | }
34 |
35 | namespace Composite
36 | {
37 | using Resources = Graphics::Vulkan::Composite::Resources;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/samples/test-harness/include/graphics/DDGI.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Graphics.h"
14 | #include "DDGIDefines.h"
15 |
16 | #ifdef GFX_PERF_INSTRUMENTATION
17 | #include "Instrumentation.h"
18 | #endif
19 |
20 | #if defined(API_D3D12)
21 | #include "DDGI_D3D12.h"
22 | #elif defined(API_VULKAN)
23 | #include "DDGI_VK.h"
24 | #endif
25 |
26 | namespace Graphics
27 | {
28 | namespace DDGI
29 | {
30 | bool Initialize(Globals& globals, GlobalResources& gfxResources, Resources& resources, const Configs::Config& config, Instrumentation::Performance& perf, std::ofstream& log);
31 | bool Reload(Globals& globals, GlobalResources& gfxResources, Resources& resources, const Configs::Config& config, std::ofstream& log);
32 | bool Resize(Globals& globals, GlobalResources& gfxResources, Resources& resources, std::ofstream& log);
33 | void Update(Globals& globals, GlobalResources& gfxResources, Resources& resources, Configs::Config& config);
34 | void Execute(Globals& globals, GlobalResources& gfxResources, Resources& resources);
35 | void Cleanup(Globals& globals, Resources& resources);
36 |
37 | void AddCommonShaderDefines(Shaders::ShaderProgram& shader, const DDGIVolumeDesc& volumeDesc, bool spirv);
38 | bool CompileDDGIVolumeShaders(Globals& vk, const DDGIVolumeDesc& volumeDesc, std::vector& volumeShaders, bool spirv, std::ofstream& log);
39 |
40 | bool WriteVolumesToDisk(Globals& globals, GlobalResources& gfxResources, Resources& resources, std::string directory);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/samples/test-harness/include/graphics/DDGIDefines.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | // Shader defines
12 | #define RTXGI_DDGI_SHADER_REFLECTION 0 // shader reflection
13 | #define RTXGI_DDGI_DEBUG_PROBE_INDEXING 0 // blending probe index visualization
14 |
15 | // Resource binding mode
16 | #ifndef RTXGI_DDGI_BINDLESS_RESOURCES
17 | #error RTXGI_DDGI_BINDLESS_RESOURCES is not defined!
18 | #endif
19 |
20 | // Blending shared memory mode
21 | #ifndef RTXGI_DDGI_BLEND_SHARED_MEMORY
22 | #error RTXGI_DDGI_BLEND_SHARED_MEMORY is not defined!
23 | #endif
24 |
25 | // Debug visualization modes
26 | #ifndef RTXGI_DDGI_DEBUG_OCTAHEDRAL_INDEXING
27 | #error RTXGI_DDGI_DEBUG_OCTAHEDRAL_INDEXING is not defined!
28 | #endif
29 |
30 | #ifndef RTXGI_DDGI_DEBUG_OCTAHEDRAL_INDEXING
31 | #error RTXGI_DDGI_DEBUG_BORDER_COPY_INDEXING is not defined!
32 | #endif
33 |
--------------------------------------------------------------------------------
/samples/test-harness/include/graphics/DDGIVisualizations.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Graphics.h"
14 | #include "DDGIDefines.h"
15 |
16 | #ifdef GFX_PERF_INSTRUMENTATION
17 | #include "Instrumentation.h"
18 | #endif
19 |
20 | #if defined(API_D3D12)
21 | #include "DDGI_D3D12.h"
22 | #include "DDGIVisualizations_D3D12.h"
23 | #elif defined(API_VULKAN)
24 | #include "DDGI_VK.h"
25 | #include "DDGIVisualizations_VK.h"
26 | #endif
27 |
28 | namespace Graphics
29 | {
30 | namespace DDGI
31 | {
32 | namespace Visualizations
33 | {
34 | enum VIS_SHOW_FLAGS
35 | {
36 | VIS_FLAG_SHOW_NONE = 0,
37 | VIS_FLAG_SHOW_PROBES = 0x2,
38 | VIS_FLAG_SHOW_TEXTURES = 0x4
39 | };
40 |
41 | bool Initialize(Globals& globals, GlobalResources& gfxResources, DDGI::Resources& ddgiResources, Resources& resources, Instrumentation::Performance& perf, Configs::Config& config, std::ofstream& log);
42 | bool Reload(Globals& globals, GlobalResources& gfxResources, DDGI::Resources& ddgiResources, Resources& resources, Configs::Config& config, std::ofstream& log);
43 | bool Resize(Globals& globals, GlobalResources& gfxResources, Resources& resources, std::ofstream& log);
44 | void Update(Globals& globals, GlobalResources& gfxResources, Resources& resources, const Configs::Config& config);
45 | void Execute(Globals& globals, GlobalResources& gfxResources, Resources& resources);
46 | void Cleanup(Globals& globals, Resources& resources);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/samples/test-harness/include/graphics/DDGI_D3D12.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Graphics.h"
14 | #include
15 |
16 | namespace Graphics
17 | {
18 | namespace D3D12
19 | {
20 | namespace DDGI
21 | {
22 | struct Resources
23 | {
24 | // Textures
25 | ID3D12Resource* output = nullptr;
26 |
27 | // Shaders
28 | Shaders::ShaderRTPipeline rtShaders;
29 | Shaders::ShaderProgram indirectCS;
30 |
31 | // Ray Tracing
32 | ID3D12Resource* shaderTable = nullptr;
33 | ID3D12Resource* shaderTableUpload = nullptr;
34 |
35 | // Pipeline State Objects
36 | ID3D12StateObject* rtpso = nullptr;
37 | ID3D12StateObjectProperties* rtpsoInfo = nullptr;
38 | ID3D12PipelineState* indirectPSO = nullptr;
39 |
40 | // Shader Table
41 | UINT shaderTableSize = 0;
42 | UINT shaderTableRecordSize = 0;
43 | UINT shaderTableMissTableSize = 0;
44 | UINT shaderTableHitGroupTableSize = 0;
45 |
46 | D3D12_GPU_VIRTUAL_ADDRESS shaderTableRGSStartAddress = 0;
47 | D3D12_GPU_VIRTUAL_ADDRESS shaderTableMissTableStartAddress = 0;
48 | D3D12_GPU_VIRTUAL_ADDRESS shaderTableHitGroupTableStartAddress = 0;
49 |
50 | // DDGI
51 | std::vector volumeDescs;
52 | std::vector volumes;
53 | std::vector selectedVolumes;
54 |
55 | ID3D12DescriptorHeap* rtvDescriptorHeap = nullptr;
56 |
57 | ID3D12Resource* volumeResourceIndicesSTB = nullptr;
58 | ID3D12Resource* volumeResourceIndicesSTBUpload = nullptr;
59 | UINT volumeResourceIndicesSTBSizeInBytes = 0;
60 |
61 | ID3D12Resource* volumeConstantsSTB = nullptr;
62 | ID3D12Resource* volumeConstantsSTBUpload = nullptr;
63 | UINT volumeConstantsSTBSizeInBytes = 0;
64 |
65 | // Variability Tracking
66 | std::vector numVolumeVariabilitySamples;
67 |
68 | // Performance Stats
69 | Instrumentation::Stat* cpuStat = nullptr;
70 | Instrumentation::Stat* gpuStat = nullptr;
71 |
72 | Instrumentation::Stat* classifyStat = nullptr;
73 | Instrumentation::Stat* rtStat = nullptr;
74 | Instrumentation::Stat* blendStat = nullptr;
75 | Instrumentation::Stat* relocateStat = nullptr;
76 | Instrumentation::Stat* lightingStat = nullptr;
77 | Instrumentation::Stat* variabilityStat = nullptr;
78 |
79 | bool enabled = false;
80 | };
81 | }
82 | }
83 |
84 | namespace DDGI
85 | {
86 | using Resources = Graphics::D3D12::DDGI::Resources;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/samples/test-harness/include/graphics/GBuffer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Graphics.h"
14 |
15 | #ifdef GFX_PERF_INSTRUMENTATION
16 | #include "Instrumentation.h"
17 | #endif
18 |
19 | #if defined(API_D3D12)
20 | #include "GBuffer_D3D12.h"
21 | #elif defined(API_VULKAN)
22 | #include "GBuffer_VK.h"
23 | #endif
24 |
25 | namespace Graphics
26 | {
27 | namespace GBuffer
28 | {
29 | bool Initialize(Globals& globals, GlobalResources& gfxResources, Resources& resources, Instrumentation::Performance& perf, std::ofstream& log);
30 | bool Reload(Globals& globals, GlobalResources& gfxResources, Resources& resources, std::ofstream& log);
31 | bool Resize(Globals& globals, GlobalResources& gfxResources, Resources& resources, std::ofstream& log);
32 | void Update(Globals& globals, GlobalResources& gfxResources, Resources& resources, const Configs::Config& config);
33 | void Execute(Globals& globals, GlobalResources& gfxResources, Resources& resources);
34 | bool WriteGBufferToDisk(Globals& globals, GlobalResources& gfxResources, std::string directory);
35 | void Cleanup(Globals& globals, Resources& resources);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/samples/test-harness/include/graphics/GBuffer_D3D12.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Graphics.h"
14 |
15 | namespace Graphics
16 | {
17 | namespace D3D12
18 | {
19 | namespace GBuffer
20 | {
21 | struct Resources
22 | {
23 | ID3D12Resource* shaderTable = nullptr;
24 | ID3D12Resource* shaderTableUpload = nullptr;
25 | Shaders::ShaderRTPipeline shaders;
26 |
27 | ID3D12StateObject* rtpso = nullptr;
28 | ID3D12StateObjectProperties* rtpsoInfo = nullptr;
29 |
30 | uint32_t shaderTableSize = 0;
31 | uint32_t shaderTableRecordSize = 0;
32 | uint32_t shaderTableMissTableSize = 0;
33 | uint32_t shaderTableHitGroupTableSize = 0;
34 |
35 | D3D12_GPU_VIRTUAL_ADDRESS shaderTableRGSStartAddress = 0;
36 | D3D12_GPU_VIRTUAL_ADDRESS shaderTableMissTableStartAddress = 0;
37 | D3D12_GPU_VIRTUAL_ADDRESS shaderTableHitGroupTableStartAddress = 0;
38 |
39 | Instrumentation::Stat* cpuStat = nullptr;
40 | Instrumentation::Stat* gpuStat = nullptr;
41 | };
42 | }
43 | }
44 |
45 | namespace GBuffer
46 | {
47 | using Resources = Graphics::D3D12::GBuffer::Resources;
48 | }
49 | }
50 |
51 |
52 |
--------------------------------------------------------------------------------
/samples/test-harness/include/graphics/GBuffer_VK.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Graphics.h"
14 |
15 | namespace Graphics
16 | {
17 | namespace Vulkan
18 | {
19 | namespace GBuffer
20 | {
21 | struct Resources
22 | {
23 | VkBuffer shaderTable = nullptr;
24 | VkBuffer shaderTableUpload = nullptr;
25 | VkDeviceMemory shaderTableMemory = nullptr;
26 | VkDeviceMemory shaderTableUploadMemory = nullptr;
27 |
28 | Shaders::ShaderRTPipeline shaders;
29 | RTShaderModules modules;
30 | VkDescriptorSet descriptorSet = nullptr;
31 | VkPipeline pipeline = nullptr;
32 |
33 | uint32_t shaderTableSize = 0;
34 | uint32_t shaderTableRecordSize = 0;
35 | uint32_t shaderTableMissTableSize = 0;
36 | uint32_t shaderTableHitGroupTableSize = 0;
37 |
38 | VkDeviceAddress shaderTableRGSStartAddress = 0;
39 | VkDeviceAddress shaderTableMissTableStartAddress = 0;
40 | VkDeviceAddress shaderTableHitGroupTableStartAddress = 0;
41 |
42 | Instrumentation::Stat* cpuStat = nullptr;
43 | Instrumentation::Stat* gpuStat = nullptr;
44 | };
45 | }
46 | }
47 |
48 | namespace GBuffer
49 | {
50 | using Resources = Graphics::Vulkan::GBuffer::Resources;
51 | }
52 | }
53 |
54 |
55 |
--------------------------------------------------------------------------------
/samples/test-harness/include/graphics/PathTracing.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Graphics.h"
14 |
15 | #ifdef GFX_PERF_INSTRUMENTATION
16 | #include "Instrumentation.h"
17 | #endif
18 |
19 | #if defined(API_D3D12)
20 | #include "PathTracing_D3D12.h"
21 | #elif defined(API_VULKAN)
22 | #include "PathTracing_VK.h"
23 | #endif
24 |
25 | namespace Graphics
26 | {
27 | namespace PathTracing
28 | {
29 | bool Initialize(Globals& globals, GlobalResources& gfxResources, Resources& resources, Instrumentation::Performance& perf, std::ofstream& log);
30 | bool Reload(Globals& globals, GlobalResources& gfxResources, Resources& resources, std::ofstream& log);
31 | bool Resize(Globals& globals, GlobalResources& gfxResources, Resources& resources, std::ofstream& log);
32 | void Update(Globals& globals, GlobalResources& gfxResources, Resources& resources, const Configs::Config& config);
33 | void Execute(Globals& globals, GlobalResources& gfxResources, Resources& resources);
34 | void Cleanup(Globals& globals, Resources& resources);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/samples/test-harness/include/graphics/PathTracing_D3D12.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Graphics.h"
14 |
15 | namespace Graphics
16 | {
17 | namespace D3D12
18 | {
19 | namespace PathTracing
20 | {
21 | struct Resources
22 | {
23 | ID3D12Resource* PTOutput = nullptr;
24 | ID3D12Resource* PTAccumulation = nullptr;
25 |
26 | ID3D12Resource* shaderTable = nullptr;
27 | ID3D12Resource* shaderTableUpload = nullptr;
28 | Shaders::ShaderRTPipeline shaders;
29 |
30 | ID3D12StateObject* rtpso = nullptr;
31 | ID3D12StateObjectProperties* rtpsoInfo = nullptr;
32 |
33 | uint32_t shaderTableSize = 0;
34 | uint32_t shaderTableRecordSize = 0;
35 | uint32_t shaderTableMissTableSize = 0;
36 | uint32_t shaderTableHitGroupTableSize = 0;
37 |
38 | D3D12_GPU_VIRTUAL_ADDRESS shaderTableRGSStartAddress = 0;
39 | D3D12_GPU_VIRTUAL_ADDRESS shaderTableMissTableStartAddress = 0;
40 | D3D12_GPU_VIRTUAL_ADDRESS shaderTableHitGroupTableStartAddress = 0;
41 |
42 | Instrumentation::Stat* cpuStat = nullptr;
43 | Instrumentation::Stat* gpuStat = nullptr;
44 | };
45 | }
46 | }
47 |
48 | namespace PathTracing
49 | {
50 | using Resources = Graphics::D3D12::PathTracing::Resources;
51 | }
52 | }
53 |
54 |
55 |
--------------------------------------------------------------------------------
/samples/test-harness/include/graphics/PathTracing_VK.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Graphics.h"
14 |
15 | namespace Graphics
16 | {
17 | namespace Vulkan
18 | {
19 | namespace PathTracing
20 | {
21 | struct Resources
22 | {
23 | VkImage PTOutput = nullptr;
24 | VkDeviceMemory PTOutputMemory = nullptr;
25 | VkImageView PTOutputView = nullptr;
26 |
27 | VkImage PTAccumulation = nullptr;
28 | VkDeviceMemory PTAccumulationMemory = nullptr;
29 | VkImageView PTAccumulationView = nullptr;
30 |
31 | VkBuffer shaderTable = nullptr;
32 | VkBuffer shaderTableUpload = nullptr;
33 | VkDeviceMemory shaderTableMemory = nullptr;
34 | VkDeviceMemory shaderTableUploadMemory = nullptr;
35 |
36 | Shaders::ShaderRTPipeline shaders;
37 | RTShaderModules modules;
38 | VkDescriptorSet descriptorSet = nullptr;
39 | VkPipeline pipeline = nullptr;
40 |
41 | uint32_t shaderTableSize = 0;
42 | uint32_t shaderTableRecordSize = 0;
43 | uint32_t shaderTableMissTableSize = 0;
44 | uint32_t shaderTableHitGroupTableSize = 0;
45 |
46 | VkDeviceAddress shaderTableRGSStartAddress = 0;
47 | VkDeviceAddress shaderTableMissTableStartAddress = 0;
48 | VkDeviceAddress shaderTableHitGroupTableStartAddress = 0;
49 |
50 | Instrumentation::Stat* cpuStat = nullptr;
51 | Instrumentation::Stat* gpuStat = nullptr;
52 | };
53 | }
54 | }
55 |
56 | namespace PathTracing
57 | {
58 | using Resources = Graphics::Vulkan::PathTracing::Resources;
59 | }
60 | }
61 |
62 |
63 |
--------------------------------------------------------------------------------
/samples/test-harness/include/graphics/RTAO.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Graphics.h"
14 |
15 | #ifdef GFX_PERF_INSTRUMENTATION
16 | #include "Instrumentation.h"
17 | #endif
18 |
19 | #if defined(API_D3D12)
20 | #include "RTAO_D3D12.h"
21 | #elif defined(API_VULKAN)
22 | #include "RTAO_VK.h"
23 | #endif
24 |
25 | namespace Graphics
26 | {
27 | namespace RTAO
28 | {
29 | bool Initialize(Globals& globals, GlobalResources& gfxResources, Resources& resources, Instrumentation::Performance& perf, std::ofstream& log);
30 | bool Reload(Globals& globals, GlobalResources& gfxResources, Resources& resources, std::ofstream& log);
31 | bool Resize(Globals& globals, GlobalResources& gfxResources, Resources& resources, std::ofstream& log);
32 | void Update(Globals& globals, GlobalResources& gfxResources, Resources& resources, const Configs::Config& config);
33 | void Execute(Globals& globals, GlobalResources& gfxResources, Resources& resources);
34 | void Cleanup(Globals& globals, Resources& resources);
35 | bool WriteRTAOBuffersToDisk(Globals& globals, GlobalResources& gfxResources, Resources& resources, std::string directory);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/samples/test-harness/include/graphics/RTAO_D3D12.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Graphics.h"
14 |
15 | namespace Graphics
16 | {
17 | namespace D3D12
18 | {
19 | namespace RTAO
20 | {
21 | struct Resources
22 | {
23 | ID3D12Resource* RTAOOutput = nullptr;
24 | ID3D12Resource* RTAORaw = nullptr;
25 |
26 | ID3D12Resource* shaderTable = nullptr;
27 | ID3D12Resource* shaderTableUpload = nullptr;
28 | Shaders::ShaderRTPipeline rtShaders;
29 | Shaders::ShaderProgram filterCS;
30 |
31 | ID3D12StateObject* rtpso = nullptr;
32 | ID3D12StateObjectProperties* rtpsoInfo = nullptr;
33 | ID3D12PipelineState* filterPSO = nullptr;
34 |
35 | uint32_t shaderTableSize = 0;
36 | uint32_t shaderTableRecordSize = 0;
37 | uint32_t shaderTableMissTableSize = 0;
38 | uint32_t shaderTableHitGroupTableSize = 0;
39 |
40 | D3D12_GPU_VIRTUAL_ADDRESS shaderTableRGSStartAddress = 0;
41 | D3D12_GPU_VIRTUAL_ADDRESS shaderTableMissTableStartAddress = 0;
42 | D3D12_GPU_VIRTUAL_ADDRESS shaderTableHitGroupTableStartAddress = 0;
43 |
44 | Instrumentation::Stat* cpuStat = nullptr;
45 | Instrumentation::Stat* gpuStat = nullptr;
46 |
47 | bool enabled = false;
48 | };
49 | }
50 | }
51 |
52 | namespace RTAO
53 | {
54 | using Resources = Graphics::D3D12::RTAO::Resources;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/samples/test-harness/include/graphics/RTAO_VK.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Graphics.h"
14 |
15 | namespace Graphics
16 | {
17 | namespace Vulkan
18 | {
19 | namespace RTAO
20 | {
21 | struct Resources
22 | {
23 | VkImage RTAOOutput = nullptr;
24 | VkDeviceMemory RTAOOutputMemory = nullptr;
25 | VkImageView RTAOOutputView = nullptr;
26 |
27 | VkImage RTAORaw = nullptr;
28 | VkDeviceMemory RTAORawMemory = nullptr;
29 | VkImageView RTAORawView = nullptr;
30 |
31 | VkBuffer shaderTable = nullptr;
32 | VkBuffer shaderTableUpload = nullptr;
33 | VkDeviceMemory shaderTableMemory = nullptr;
34 | VkDeviceMemory shaderTableUploadMemory = nullptr;
35 |
36 | Shaders::ShaderRTPipeline rtShaders;
37 | Shaders::ShaderProgram filterCS;
38 | RTShaderModules rtShaderModules;
39 | VkShaderModule filterCSModule = nullptr;
40 |
41 | VkDescriptorSet descriptorSet = nullptr;
42 | VkPipeline rtPipeline = nullptr;
43 | VkPipeline filterPipeline = nullptr;
44 |
45 | uint32_t shaderTableSize = 0;
46 | uint32_t shaderTableRecordSize = 0;
47 | uint32_t shaderTableMissTableSize = 0;
48 | uint32_t shaderTableHitGroupTableSize = 0;
49 |
50 | VkDeviceAddress shaderTableRGSStartAddress = 0;
51 | VkDeviceAddress shaderTableMissTableStartAddress = 0;
52 | VkDeviceAddress shaderTableHitGroupTableStartAddress = 0;
53 |
54 | Instrumentation::Stat* cpuStat = nullptr;
55 | Instrumentation::Stat* gpuStat = nullptr;
56 |
57 | bool enabled = false;
58 | };
59 | }
60 | }
61 |
62 | namespace RTAO
63 | {
64 | using Resources = Graphics::Vulkan::RTAO::Resources;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/samples/test-harness/include/graphics/UI.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Common.h"
14 | #include "DDGI.h"
15 | #include "Graphics.h"
16 | #include "Inputs.h"
17 | #include "Instrumentation.h"
18 | #include "Scenes.h"
19 |
20 | #if defined(API_D3D12)
21 | #include "UI_D3D12.h"
22 | #elif defined(API_VULKAN)
23 | #include "UI_VK.h"
24 | #endif
25 |
26 | namespace Graphics
27 | {
28 | namespace UI
29 | {
30 | extern bool s_initialized;
31 |
32 | bool Initialize(Graphics::Globals& gfx, Graphics::GlobalResources& gfxResources, Resources& resources, Instrumentation::Performance& perf, std::ofstream& log);
33 | void Update(Graphics::Globals& gfx, Resources& resources, Configs::Config& config, Inputs::Input& input, Scenes::Scene& scene, std::vector& volumes, const Instrumentation::Performance& performance);
34 | bool MessageBox(std::string message);
35 | bool MessageRetryBox(std::string message);
36 | bool CapturedMouse();
37 | bool CapturedKeyboard();
38 | void Execute(Graphics::Globals& gfx, Graphics::GlobalResources& gfxResources, Resources& resources, const Configs::Config& config);
39 | void Cleanup();
40 |
41 | void CreateDebugWindow(Graphics::Globals& gfx, Configs::Config& config, Inputs::Input& input, Scenes::Scene& scene, std::vector& volumes);
42 | void CreatePerfWindow(Graphics::Globals& gfx, const Configs::Config& config, const Instrumentation::Performance& performance);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/samples/test-harness/include/graphics/UI_D3D12.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Graphics.h"
14 |
15 | namespace Graphics
16 | {
17 | namespace D3D12
18 | {
19 | namespace UI
20 | {
21 | struct Resources
22 | {
23 | Instrumentation::Stat* cpuStat = nullptr;
24 | Instrumentation::Stat* gpuStat = nullptr;
25 | };
26 | }
27 | }
28 |
29 | namespace UI
30 | {
31 | using Resources = Graphics::D3D12::UI::Resources;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/samples/test-harness/include/graphics/UI_VK.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "Graphics.h"
14 |
15 | namespace Graphics
16 | {
17 | namespace Vulkan
18 | {
19 | namespace UI
20 | {
21 | struct Resources
22 | {
23 | Instrumentation::Stat* cpuStat = nullptr;
24 | Instrumentation::Stat* gpuStat = nullptr;
25 | };
26 | }
27 | }
28 |
29 | namespace UI
30 | {
31 | using Resources = Graphics::Vulkan::UI::Resources;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/samples/test-harness/include/thirdparty/directx/OAIdl.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | // Stub header to satisfy d3d12.h include
5 | #pragma once
--------------------------------------------------------------------------------
/samples/test-harness/include/thirdparty/directx/OCIdl.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | // Stub header to satisfy d3d12.h include
5 | #pragma once
--------------------------------------------------------------------------------
/samples/test-harness/include/thirdparty/directx/dxgicommon.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) Microsoft Corporation.
3 | // Licensed under the MIT license
4 | //
5 |
6 | #ifndef __dxgicommon_h__
7 | #define __dxgicommon_h__
8 |
9 |
10 | typedef struct DXGI_RATIONAL
11 | {
12 | UINT Numerator;
13 | UINT Denominator;
14 | } DXGI_RATIONAL;
15 |
16 | // The following values are used with DXGI_SAMPLE_DESC::Quality:
17 | #define DXGI_STANDARD_MULTISAMPLE_QUALITY_PATTERN 0xffffffff
18 | #define DXGI_CENTER_MULTISAMPLE_QUALITY_PATTERN 0xfffffffe
19 |
20 | typedef struct DXGI_SAMPLE_DESC
21 | {
22 | UINT Count;
23 | UINT Quality;
24 | } DXGI_SAMPLE_DESC;
25 |
26 | typedef enum DXGI_COLOR_SPACE_TYPE
27 | {
28 | DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709 = 0,
29 | DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709 = 1,
30 | DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P709 = 2,
31 | DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P2020 = 3,
32 | DXGI_COLOR_SPACE_RESERVED = 4,
33 | DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601 = 5,
34 | DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601 = 6,
35 | DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P601 = 7,
36 | DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709 = 8,
37 | DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P709 = 9,
38 | DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020 = 10,
39 | DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020 = 11,
40 | DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020 = 12,
41 | DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_LEFT_P2020 = 13,
42 | DXGI_COLOR_SPACE_RGB_STUDIO_G2084_NONE_P2020 = 14,
43 | DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_TOPLEFT_P2020 = 15,
44 | DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_TOPLEFT_P2020 = 16,
45 | DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P2020 = 17,
46 | DXGI_COLOR_SPACE_YCBCR_STUDIO_GHLG_TOPLEFT_P2020 = 18,
47 | DXGI_COLOR_SPACE_YCBCR_FULL_GHLG_TOPLEFT_P2020 = 19,
48 | DXGI_COLOR_SPACE_RGB_STUDIO_G24_NONE_P709 = 20,
49 | DXGI_COLOR_SPACE_RGB_STUDIO_G24_NONE_P2020 = 21,
50 | DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_LEFT_P709 = 22,
51 | DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_LEFT_P2020 = 23,
52 | DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_TOPLEFT_P2020 = 24,
53 | DXGI_COLOR_SPACE_CUSTOM = 0xFFFFFFFF
54 | } DXGI_COLOR_SPACE_TYPE;
55 |
56 | #endif // __dxgicommon_h__
57 |
58 |
--------------------------------------------------------------------------------
/samples/test-harness/include/thirdparty/directx/rpc.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | // Stub header to satisfy d3d12.h include
5 | #pragma once
--------------------------------------------------------------------------------
/samples/test-harness/include/thirdparty/directx/rpcndr.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | // Stub header to satisfy d3d12.h include
5 | #pragma once
6 | #define __RPCNDR_H_VERSION__
--------------------------------------------------------------------------------
/samples/test-harness/include/thirdparty/directx/winapifamily.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | // Stub header to satisfy d3d12.h include. Unconditionally light up all APIs.
5 | #pragma once
6 | #define WINAPI_FAMILY_PARTITION(Partitions) 1
--------------------------------------------------------------------------------
/samples/test-harness/shaders/GBufferRGS.hlsl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #include "include/Common.hlsl"
12 | #include "include/Descriptors.hlsl"
13 | #include "include/Lighting.hlsl"
14 | #include "include/RayTracing.hlsl"
15 |
16 | // ---[ Ray Generation Shader ]---
17 |
18 | [shader("raygeneration")]
19 | void RayGen()
20 | {
21 | uint2 LaunchIndex = DispatchRaysIndex().xy;
22 | uint2 LaunchDimensions = DispatchRaysDimensions().xy;
23 |
24 | // Get the lights
25 | StructuredBuffer Lights = GetLights();
26 |
27 | // Get the (bindless) resources
28 | RWTexture2D GBufferA = GetRWTex2D(GBUFFERA_INDEX);
29 | RWTexture2D GBufferB = GetRWTex2D(GBUFFERB_INDEX);
30 | RWTexture2D GBufferC = GetRWTex2D(GBUFFERC_INDEX);
31 | RWTexture2D GBufferD = GetRWTex2D(GBUFFERD_INDEX);
32 | RaytracingAccelerationStructure SceneTLAS = GetAccelerationStructure(SCENE_TLAS_INDEX);
33 |
34 | // Setup the primary ray
35 | RayDesc ray = (RayDesc)0;
36 | ray.Origin = GetCamera().position;
37 | ray.TMin = 0.f;
38 | ray.TMax = 1e27f;
39 |
40 | // Pixel coordinates, remapped to [-1, 1] with y-direction flipped to match world-space
41 | // Camera basis, adjusted for the aspect ratio and vertical field of view
42 | float px = (((float)LaunchIndex.x + 0.5f) / (float)LaunchDimensions.x) * 2.f - 1.f;
43 | float py = (((float)LaunchIndex.y + 0.5f) / (float)LaunchDimensions.y) * -2.f + 1.f;
44 | float3 right = GetCamera().aspect * GetCamera().tanHalfFovY * GetCamera().right;
45 | float3 up = GetCamera().tanHalfFovY * GetCamera().up;
46 |
47 | // Compute the primary ray direction
48 | ray.Direction = (px * right) + (py * up) + GetCamera().forward;
49 |
50 | // Primary Ray Trace
51 | PackedPayload packedPayload = (PackedPayload)0;
52 | packedPayload.hitT = (float)LaunchIndex.x;
53 | packedPayload.worldPosition = float3((float)LaunchIndex.y, (float2)LaunchDimensions);
54 | TraceRay(
55 | SceneTLAS,
56 | RAY_FLAG_CULL_BACK_FACING_TRIANGLES,
57 | 0xFF,
58 | 0,
59 | 0,
60 | 0,
61 | ray,
62 | packedPayload);
63 |
64 | // Ray Miss, early out.
65 | if (packedPayload.hitT < 0.f)
66 | {
67 | // Convert albedo to sRGB before storing
68 | GBufferA[LaunchIndex] = float4(LinearToSRGB(GetGlobalConst(app, skyRadiance)), COMPOSITE_FLAG_POSTPROCESS_PIXEL);
69 | GBufferB[LaunchIndex].w = -1.f;
70 |
71 | // Optional clear writes. Not necessary for final image, but
72 | // useful for image comparisons during regression testing.
73 | GBufferB[LaunchIndex] = float4(0.f, 0.f, 0.f, -1.f);
74 | GBufferC[LaunchIndex] = float4(0.f, 0.f, 0.f, 0.f);
75 | GBufferD[LaunchIndex] = float4(0.f, 0.f, 0.f, 0.f);
76 |
77 | return;
78 | }
79 |
80 | // Unpack the payload
81 | Payload payload = UnpackPayload(packedPayload);
82 |
83 | // Compute direct diffuse lighting
84 | float3 diffuse = DirectDiffuseLighting(payload, GetGlobalConst(pt, rayNormalBias), GetGlobalConst(pt, rayViewBias), SceneTLAS, Lights);
85 |
86 | // Convert albedo to sRGB before storing
87 | payload.albedo = LinearToSRGB(payload.albedo);
88 |
89 | // Write the GBuffer
90 | GBufferA[LaunchIndex] = float4(payload.albedo, COMPOSITE_FLAG_LIGHT_PIXEL);
91 | GBufferB[LaunchIndex] = float4(payload.worldPosition, payload.hitT);
92 | GBufferC[LaunchIndex] = float4(payload.normal, 1.f);
93 | GBufferD[LaunchIndex] = float4(diffuse, 1.f);
94 | }
95 |
--------------------------------------------------------------------------------
/samples/test-harness/shaders/Miss.hlsl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #include "include/Descriptors.hlsl"
12 | #include "include/RayTracing.hlsl"
13 |
14 | // ---[ Miss Shader ]---
15 |
16 | [shader("miss")]
17 | void Miss(inout PackedPayload packedPayload)
18 | {
19 | packedPayload.hitT = -1.f;
20 | }
21 |
--------------------------------------------------------------------------------
/samples/test-harness/shaders/RTAOTraceRGS.hlsl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #include "include/Common.hlsl"
12 | #include "include/Descriptors.hlsl"
13 | #include "include/RayTracing.hlsl"
14 |
15 | /**
16 | * Computes a low discrepancy spherically distributed direction on the unit sphere,
17 | * for the given index in a set of samples. Each direction is unique in
18 | * the set, but the set of directions is always the same.
19 | */
20 | float3 SphericalFibonacci(float index, float numSamples)
21 | {
22 | const float b = (sqrt(5.f) * 0.5f + 0.5f) - 1.f;
23 | float phi = TWO_PI * frac(index * b);
24 | float cosTheta = 1.f - (2.f * index + 1.f) * (1.f / numSamples);
25 | float sinTheta = sqrt(saturate(1.f - (cosTheta * cosTheta)));
26 |
27 | return float3((cos(phi) * sinTheta), (sin(phi) * sinTheta), cosTheta);
28 | }
29 |
30 | /**
31 | * Trace a ray to determine occlusion.
32 | */
33 | float GetOcclusion(int2 screenPos, float3 worldPos, float3 normal)
34 | {
35 | static const float c_numAngles = 10.f;
36 |
37 | // Get the (bindless) resources
38 | Texture2D BlueNoise = GetTex2D(BLUE_NOISE_INDEX);
39 | RaytracingAccelerationStructure SceneTLAS = GetAccelerationStructure(SCENE_TLAS_INDEX);
40 |
41 | // Load a value from the noise texture
42 | float blueNoiseValue = BlueNoise.Load(int3(screenPos.xy, 0) % 256).r;
43 | float3 blueNoiseUnitVector = SphericalFibonacci(clamp(blueNoiseValue * c_numAngles, 0, c_numAngles - 1), c_numAngles);
44 |
45 | // Use the noise vector to perturb the normal, creating a new direction
46 | float3 rayDirection = normalize(normal + blueNoiseUnitVector);
47 |
48 | // Setup the ray
49 | RayDesc ray;
50 | ray.Origin = worldPos + (normal * GetGlobalConst(rtao, rayNormalBias)); // TODO: not using viewBias!
51 | ray.Direction = rayDirection;
52 | ray.TMin = 0.f;
53 | ray.TMax = GetGlobalConst(rtao, rayLength);
54 |
55 | // Trace a visibility ray
56 | PackedPayload packedPayload = (PackedPayload)0;
57 | TraceRay(
58 | SceneTLAS,
59 | RAY_FLAG_CULL_BACK_FACING_TRIANGLES,
60 | 0xFF,
61 | 0,
62 | 0,
63 | 0,
64 | ray,
65 | packedPayload);
66 |
67 | // Put the linear hit distance ratio through a pow() to convert it to an occlusion value
68 | return (packedPayload.hitT < 0.f) ? 1.f : pow(saturate(packedPayload.hitT / GetGlobalConst(rtao, rayLength)), GetGlobalConst(rtao, power));
69 | }
70 |
71 | // ---[ Ray Generation Shader ]---
72 |
73 | [shader("raygeneration")]
74 | void RayGen()
75 | {
76 | int2 LaunchIndex = int2(DispatchRaysIndex().xy);
77 |
78 | // Get the (bindless) resources
79 | RWTexture2D GBufferA = GetRWTex2D(GBUFFERA_INDEX);
80 | RWTexture2D GBufferB = GetRWTex2D(GBUFFERB_INDEX);
81 | RWTexture2D GBufferC = GetRWTex2D(GBUFFERC_INDEX);
82 | RWTexture2D GBufferD = GetRWTex2D(GBUFFERD_INDEX);
83 | RWTexture2D RTAORaw = GetRWTex2D(RTAO_RAW_INDEX);
84 |
85 | // Early exit for pixels without a primary ray intersection
86 | if (GBufferA.Load(LaunchIndex).w < COMPOSITE_FLAG_LIGHT_PIXEL)
87 | {
88 | GBufferD[LaunchIndex].a = 1.f; // No occlusion
89 | return;
90 | }
91 |
92 | // Load the world position and normal from the GBuffer
93 | float3 worldPos = GBufferB.Load(LaunchIndex).xyz;
94 | float3 normal = GBufferC.Load(LaunchIndex).xyz;
95 |
96 | // Store the occlusion
97 | RTAORaw[LaunchIndex] = GetOcclusion(LaunchIndex, worldPos, normal);
98 | }
99 |
--------------------------------------------------------------------------------
/samples/test-harness/shaders/ddgi/visualizations/ProbesCHS.hlsl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #include "../../../include/graphics/Types.h"
12 |
13 | [shader("closesthit")]
14 | void CHS(inout ProbeVisualizationPayload payload, BuiltInTriangleIntersectionAttributes attrib)
15 | {
16 | payload.hitT = RayTCurrent();
17 | payload.instanceIndex = (int)InstanceIndex();
18 | payload.volumeIndex = (InstanceID() >> 16);
19 | payload.instanceOffset = (InstanceID() & 0xFFFF);
20 | payload.worldPosition = WorldRayOrigin() + (WorldRayDirection() * payload.hitT);
21 | }
22 |
--------------------------------------------------------------------------------
/samples/test-harness/shaders/ddgi/visualizations/ProbesMiss.hlsl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #include "../../../include/graphics/Types.h"
12 |
13 | // ---[ Miss Shader ]---
14 |
15 | [shader("miss")]
16 | void Miss(inout ProbeVisualizationPayload payload)
17 | {
18 | payload.hitT = -1.f;
19 | }
20 |
--------------------------------------------------------------------------------
/samples/test-harness/shaders/ddgi/visualizations/ProbesUpdateCS.hlsl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #include "../../include/Descriptors.hlsl"
12 |
13 | #include "../../../../../rtxgi-sdk/shaders/ddgi/include/ProbeCommon.hlsl"
14 | #include "../../../../../rtxgi-sdk/shaders/ddgi/include/DDGIRootConstants.hlsl"
15 |
16 | [numthreads(32, 1, 1)]
17 | void CS(uint3 DispatchThreadID : SV_DispatchThreadID)
18 | {
19 | // Get the DDGIVolume index from root/push constants
20 | uint volumeIndex = GetDDGIVolumeIndex();
21 |
22 | // Get the DDGIVolume structured buffers
23 | StructuredBuffer DDGIVolumes = GetDDGIVolumeConstants(GetDDGIVolumeConstantsIndex());
24 | StructuredBuffer DDGIVolumeBindless = GetDDGIVolumeResourceIndices(GetDDGIVolumeResourceIndicesIndex());
25 |
26 | // Load and unpack the DDGIVolume's constants
27 | DDGIVolumeDescGPU volume = UnpackDDGIVolumeDescGPU(DDGIVolumes[volumeIndex]);
28 |
29 | // Get the number of probes
30 | uint numProbes = (volume.probeCounts.x * volume.probeCounts.y * volume.probeCounts.z);
31 |
32 | // Early out: processed all probes, a probe doesn't exist for this thread
33 | if(DispatchThreadID.x >= numProbes) return;
34 |
35 | // Get the DDGIVolume's bindless resource indices
36 | DDGIVolumeResourceIndices resourceIndices = DDGIVolumeBindless[volumeIndex];
37 |
38 | // Get the probe data texture array
39 | Texture2DArray ProbeData = GetTex2DArray(resourceIndices.probeDataSRVIndex);
40 |
41 | // Get the probe's grid coordinates
42 | float3 probeCoords = DDGIGetProbeCoords(DispatchThreadID.x, volume);
43 |
44 | // Get the probe's world position from the probe index
45 | float3 probeWorldPosition = DDGIGetProbeWorldPosition(probeCoords, volume, ProbeData);
46 |
47 | // Get the probe radius
48 | float probeRadius = GetGlobalConst(ddgivis, probeRadius);
49 |
50 | // Get the instance offset (where one volume's probes end and another begin)
51 | uint instanceOffset = GetGlobalConst(ddgivis, instanceOffset);
52 |
53 | // Get the TLAS Instances structured buffer
54 | RWStructuredBuffer RWInstances = GetDDGIProbeVisTLASInstances();
55 |
56 | // Set the probe's transform
57 | RWInstances[(instanceOffset + DispatchThreadID.x)].transform = float3x4(
58 | probeRadius, 0.f, 0.f, probeWorldPosition.x,
59 | 0.f, probeRadius, 0.f, probeWorldPosition.y,
60 | 0.f, 0.f, probeRadius, probeWorldPosition.z);
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/samples/test-harness/shaders/include/Common.hlsl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #ifndef COMMON_HLSL
12 | #define COMMON_HLSL
13 |
14 | static const float PI = 3.1415926535897932f;
15 | static const float TWO_PI = 6.2831853071795864f;
16 |
17 | static const float COMPOSITE_FLAG_IGNORE_PIXEL = 0.2f;
18 | static const float COMPOSITE_FLAG_POSTPROCESS_PIXEL = 0.5f;
19 | static const float COMPOSITE_FLAG_LIGHT_PIXEL = 0.8f;
20 |
21 | #define RTXGI_DDGI_VISUALIZE_PROBE_IRRADIANCE 0
22 | #define RTXGI_DDGI_VISUALIZE_PROBE_DISTANCE 1
23 |
24 | float3 LessThan(float3 f, float value)
25 | {
26 | return float3(
27 | (f.x < value) ? 1.f : 0.f,
28 | (f.y < value) ? 1.f : 0.f,
29 | (f.z < value) ? 1.f : 0.f);
30 | }
31 |
32 | float3 LinearToSRGB(float3 rgb)
33 | {
34 | rgb = clamp(rgb, 0.f, 1.f);
35 | return lerp(
36 | pow(rgb * 1.055f, 1.f / 2.4f) - 0.055f,
37 | rgb * 12.92f,
38 | LessThan(rgb, 0.0031308f)
39 | );
40 | }
41 |
42 | float3 SRGBToLinear(float3 rgb)
43 | {
44 | rgb = clamp(rgb, 0.f, 1.f);
45 | return lerp(
46 | pow((rgb + 0.055f) / 1.055f, 2.4f),
47 | rgb / 12.92f,
48 | LessThan(rgb, 0.04045f)
49 | );
50 | }
51 |
52 | // ACES tone mapping curve fit to go from HDR to LDR
53 | //https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/
54 | float3 ACESFilm(float3 x)
55 | {
56 | float a = 2.51f;
57 | float b = 0.03f;
58 | float c = 2.43f;
59 | float d = 0.59f;
60 | float e = 0.14f;
61 | return saturate((x*(a*x + b)) / (x*(c*x + d) + e));
62 | }
63 |
64 | #endif // COMMON_HLSL
65 |
--------------------------------------------------------------------------------
/samples/test-harness/shaders/include/Platform.hlsl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #ifndef PLATFORM_HLSL
12 | #define PLATFORM_HLSL
13 |
14 | #if GFX_NVAPI
15 | #define NV_SHADER_EXTN_SLOT u999999
16 | #define NV_SHADER_EXTN_REGISTER_SPACE space999999
17 | #define NV_HITOBJECT_USE_MACRO_API
18 | #include "nvapi/nvHLSLExtns.h"
19 | #endif
20 |
21 | #ifdef __spirv__
22 | #define VK_BINDING(x, y) [[vk::binding(x, y)]]
23 | #define VK_PUSH_CONST [[vk::push_constant]]
24 | #else
25 | #define VK_BINDING(x, y)
26 | #define VK_PUSH_CONST
27 | #endif
28 |
29 | #endif //PLATFORM_HLSL
30 |
--------------------------------------------------------------------------------
/samples/test-harness/shaders/include/Random.hlsl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #ifndef RANDOM_HLSL
12 | #define RANDOM_HLSL
13 |
14 | #include "../../../../rtxgi-sdk/shaders/Common.hlsl"
15 |
16 | // ---[ Random Number Generation ]---
17 |
18 | /*
19 | * From Nathan Reed's blog at:
20 | * http://www.reedbeta.com/blog/quick-and-easy-gpu-random-numbers-in-d3d11/
21 | */
22 |
23 | uint WangHash(uint seed)
24 | {
25 | seed = (seed ^ 61) ^ (seed >> 16);
26 | seed *= 9;
27 | seed = seed ^ (seed >> 4);
28 | seed *= 0x27d4eb2d;
29 | seed = seed ^ (seed >> 15);
30 | return seed;
31 | }
32 |
33 | uint Xorshift(uint seed)
34 | {
35 | // Xorshift algorithm from George Marsaglia's paper
36 | seed ^= (seed << 13);
37 | seed ^= (seed >> 17);
38 | seed ^= (seed << 5);
39 | return seed;
40 | }
41 |
42 | float GetRandomNumber(inout uint seed)
43 | {
44 | seed = WangHash(seed);
45 | return float(Xorshift(seed)) * (1.f / 4294967296.f);
46 | }
47 |
48 | /**
49 | * Generate three components of low discrepancy blue noise.
50 | */
51 | float3 GetLowDiscrepancyBlueNoise(int2 screenPosition, uint frameNumber, float noiseScale, Texture2D blueNoise)
52 | {
53 | static const float goldenRatioConjugate = 0.61803398875f;
54 |
55 | // Load random value from a blue noise texture
56 | float3 rnd = blueNoise.Load(int3(screenPosition % 256, 0)).rgb;
57 |
58 | // Generate a low discrepancy sequence
59 | rnd = frac(rnd + goldenRatioConjugate * ((frameNumber - 1) % 16));
60 |
61 | // Scale the noise magnitude to [0, noiseScale]
62 | return (rnd * noiseScale);
63 | }
64 |
65 | /**
66 | * Generate three components of white noise.
67 | */
68 | float3 GetWhiteNoise(uint2 screenPosition, uint screenWidth, uint frameNumber, float noiseScale)
69 | {
70 | // Generate a unique seed on screen position and time
71 | uint seed = ((screenPosition.y * screenWidth) + screenPosition.x) * frameNumber;
72 |
73 | // Generate uniformly distributed random values in the range [0, 1]
74 | float3 rnd;
75 | rnd.x = GetRandomNumber(seed);
76 | rnd.y = GetRandomNumber(seed);
77 | rnd.z = GetRandomNumber(seed);
78 |
79 | // Shift the random value into the range [-1, 1]
80 | rnd = mad(rnd, 2.f, -1.f);
81 |
82 | // Scale the noise magnitude to [-noiseScale, noiseScale]
83 | return (rnd * noiseScale);
84 | }
85 |
86 | /**
87 | * Compute a uniformly distributed random direction on the hemisphere about the given (normal) direction.
88 | */
89 | float3 GetRandomDirectionOnHemisphere(float3 direction, inout uint seed)
90 | {
91 | float3 p;
92 | do
93 | {
94 | p.x = GetRandomNumber(seed) * 2.f - 1.f;
95 | p.y = GetRandomNumber(seed) * 2.f - 1.f;
96 | p.z = GetRandomNumber(seed) * 2.f - 1.f;
97 |
98 | // Only accept unit length directions to stay inside
99 | // the unit sphere and be uniformly distributed
100 | } while (length(p) > 1.f);
101 |
102 | // Direction is on the opposite hemisphere, flip and use it
103 | if (dot(direction, p) < 0.f) p *= -1.f;
104 | return normalize(p);
105 | }
106 |
107 | /**
108 | * Compute a cosine distributed random direction on the hemisphere about the given (normal) direction.
109 | */
110 | float3 GetRandomCosineDirectionOnHemisphere(float3 direction, inout uint seed)
111 | {
112 | // Choose random points on the unit sphere offset along the surface normal
113 | // to produce a cosine distribution of random directions.
114 | float a = GetRandomNumber(seed) * RTXGI_2PI;
115 | float z = GetRandomNumber(seed) * 2.f - 1.f;
116 | float r = sqrt(1.f - z * z);
117 |
118 | float3 p = float3(r * cos(a), r * sin(a), z) + direction;
119 | return normalize(p);
120 | }
121 |
122 | #endif // RANDOM_HLSL
123 |
--------------------------------------------------------------------------------
/samples/test-harness/shaders/include/nvapi/nvHLSLExtns.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/samples/test-harness/shaders/include/nvapi/nvHLSLExtns.h
--------------------------------------------------------------------------------
/samples/test-harness/shaders/include/nvapi/nvHLSLExtnsInternal.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/samples/test-harness/shaders/include/nvapi/nvHLSLExtnsInternal.h
--------------------------------------------------------------------------------
/samples/test-harness/shaders/include/nvapi/nvShaderExtnEnums.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/samples/test-harness/shaders/include/nvapi/nvShaderExtnEnums.h
--------------------------------------------------------------------------------
/samples/test-harness/src/Instrumentation.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #include "Instrumentation.h"
12 |
13 | #if __linux__
14 | #include
15 | #endif
16 |
17 | namespace Instrumentation
18 | {
19 | //----------------------------------------------------------------------------------------------------------
20 | // Private Functions
21 | //----------------------------------------------------------------------------------------------------------
22 |
23 | int64_t GetPerfCounter()
24 | {
25 | #if defined(_WIN32) || defined(WIN32)
26 | LARGE_INTEGER value;
27 | QueryPerformanceCounter(&value);
28 | return value.QuadPart;
29 | #elif __linux__
30 | timespec ts;
31 | int result = -1;
32 | while(result < 0)
33 | {
34 | result = clock_gettime(CLOCK_REALTIME, &ts);
35 | }
36 | return (ts.tv_sec * 1.0e9) + ts.tv_nsec;
37 | #endif
38 | }
39 |
40 | #if defined(_WIN32) || defined(WIN32)
41 | int64_t GetPerfCounterFrequency()
42 | {
43 | LARGE_INTEGER value;
44 | QueryPerformanceFrequency(&value);
45 | return value.QuadPart;
46 | }
47 |
48 | static int64_t frequency = GetPerfCounterFrequency();
49 | #endif
50 |
51 | /**
52 | * Get the number of milliseconds between the timer's start and the current time.
53 | */
54 | void GetElapsed(Stat* s)
55 | {
56 | #if defined(_WIN32) || defined(WIN32)
57 | // Frequency is ticks per second, so elapsed ticks / frequency = seconds
58 | uint64_t seconds = (GetPerfCounter() - s->timestamp);
59 | s->elapsed += (static_cast(seconds) / static_cast(frequency)) * 1000;
60 | #elif __linux__
61 | // GetPerfCounter times are in nanoseconds on Linux
62 | s->elapsed += (GetPerfCounter() - s->timestamp) * 0.000001;
63 | #endif
64 | }
65 |
66 | //----------------------------------------------------------------------------------------------------------
67 | // Public Functions
68 | //----------------------------------------------------------------------------------------------------------
69 |
70 | uint32_t Stat::frameGPUQueryCount = 0;
71 |
72 | int32_t Stat::GetGPUQueryBeginIndex()
73 | {
74 | gpuQueryStartIndex = (Stat::frameGPUQueryCount * 2);
75 | Stat::frameGPUQueryCount++;
76 | return gpuQueryStartIndex;
77 | }
78 |
79 | int32_t Stat::GetGPUQueryEndIndex()
80 | {
81 | gpuQueryEndIndex = gpuQueryStartIndex + 1;
82 | return gpuQueryEndIndex;
83 | }
84 |
85 | void Stat::ResetGPUQueryIndices()
86 | {
87 | gpuQueryStartIndex = gpuQueryEndIndex = -1;
88 | }
89 |
90 | void Begin(Stat* s)
91 | {
92 | s->elapsed = 0;
93 | s->timestamp = GetPerfCounter();
94 | }
95 |
96 | void End(Stat* s)
97 | {
98 | GetElapsed(s);
99 | }
100 |
101 | void Resolve(Stat* s)
102 | {
103 | s->total += s->elapsed;
104 | if (static_cast(s->samples.size()) >= s->sampleSize)
105 | {
106 | s->total -= s->samples.front();
107 | s->samples.pop();
108 | }
109 | s->samples.push(s->elapsed);
110 | s->average = std::max(s->total / s->samples.size(), (double)0);
111 | }
112 |
113 | void EndAndResolve(Stat* s)
114 | {
115 | End(s);
116 | Resolve(s);
117 | }
118 |
119 | std::ostream& operator<<(std::ostream& os, Stat* stat)
120 | {
121 | if(stat) os << stat->elapsed;
122 | return os;
123 | }
124 |
125 | std::ostream& operator<<(std::ostream& os, std::vector& stats)
126 | {
127 | for (size_t index = 0; index < stats.size(); index++)
128 | {
129 | os << stats[index] << ",";
130 | }
131 | os << std::endl;
132 | return os;
133 | }
134 |
135 | }
136 |
--------------------------------------------------------------------------------
/samples/test-harness/src/Window.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #include "Window.h"
12 |
13 | #include
14 |
15 | using namespace DirectX;
16 |
17 | namespace Windows
18 | {
19 | static EWindowEvent state = EWindowEvent::NONE;
20 | const EWindowEvent GetWindowEvent() { return state; }
21 | void ResetWindowEvent() { state = EWindowEvent::NONE; }
22 |
23 | //----------------------------------------------------------------------------------------------------------
24 | // Event Handlers
25 | //----------------------------------------------------------------------------------------------------------
26 |
27 | /**
28 | * Handle frame buffer resize events.
29 | */
30 | void onFramebufferResize(GLFWwindow* window, int width, int height)
31 | {
32 | state = EWindowEvent::RESIZE;
33 | }
34 |
35 | /**
36 | * Create a window.
37 | */
38 | bool Create(Configs::Config& config, GLFWwindow*& window)
39 | {
40 | config.app.title.append(", ");
41 | config.app.title.append(config.scene.name);
42 | #if defined(API_D3D12)
43 | config.app.title.append(" (D3D12)");
44 | #elif defined(API_VULKAN)
45 | config.app.title.append(" (Vulkan)");
46 | #endif
47 |
48 | glfwInit();
49 | glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); // don't need an OpenGL context with D3D12/Vulkan
50 | glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
51 |
52 | // Create the window with GLFW
53 | window = glfwCreateWindow(config.app.width, config.app.height, config.app.title.c_str(), nullptr, nullptr);
54 | if (!window) return false;
55 |
56 | // Add a GLFW hook to handle resize events
57 | glfwSetFramebufferSizeCallback(window, onFramebufferResize);
58 |
59 | // Load the nvidia logo and set it as the window icon
60 | GLFWimage icon;
61 | icon.pixels = stbi_load("nvidia.jpg", (int*)&(icon.width), (int*)&icon.height, nullptr, STBI_rgb_alpha);
62 | if (icon.pixels) glfwSetWindowIcon(window, 1, &icon);
63 | delete[] icon.pixels;
64 | icon.pixels = nullptr;
65 |
66 | return true;
67 | }
68 |
69 | /**
70 | * Close and destroy a window.
71 | */
72 | bool Close(GLFWwindow*& window)
73 | {
74 | glfwDestroyWindow(window);
75 | glfwTerminate();
76 | return true;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/samples/test-harness/src/thirdparty/directxtex/BCDirectCompute.h:
--------------------------------------------------------------------------------
1 | //-------------------------------------------------------------------------------------
2 | // BCDirectCompute.h
3 | //
4 | // Direct3D 11 Compute Shader BC Compressor
5 | //
6 | // Copyright (c) Microsoft Corporation.
7 | // Licensed under the MIT License.
8 | //-------------------------------------------------------------------------------------
9 |
10 | #pragma once
11 |
12 | namespace DirectX
13 | {
14 |
15 | class GPUCompressBC
16 | {
17 | public:
18 | GPUCompressBC() noexcept;
19 |
20 | HRESULT Initialize(_In_ ID3D11Device* pDevice);
21 |
22 | HRESULT Prepare(size_t width, size_t height, uint32_t flags, DXGI_FORMAT format, float alphaWeight);
23 |
24 | HRESULT Compress(const Image& srcImage, const Image& destImage);
25 |
26 | DXGI_FORMAT GetSourceFormat() const noexcept { return m_srcformat; }
27 |
28 | private:
29 | DXGI_FORMAT m_bcformat;
30 | DXGI_FORMAT m_srcformat;
31 | float m_alphaWeight;
32 | bool m_bc7_mode02;
33 | bool m_bc7_mode137;
34 | size_t m_width;
35 | size_t m_height;
36 |
37 | Microsoft::WRL::ComPtr m_device;
38 | Microsoft::WRL::ComPtr m_context;
39 |
40 | Microsoft::WRL::ComPtr m_err1;
41 | Microsoft::WRL::ComPtr m_err1UAV;
42 | Microsoft::WRL::ComPtr m_err1SRV;
43 |
44 | Microsoft::WRL::ComPtr m_err2;
45 | Microsoft::WRL::ComPtr m_err2UAV;
46 | Microsoft::WRL::ComPtr m_err2SRV;
47 |
48 | Microsoft::WRL::ComPtr m_output;
49 | Microsoft::WRL::ComPtr m_outputCPU;
50 | Microsoft::WRL::ComPtr m_outputUAV;
51 | Microsoft::WRL::ComPtr m_constBuffer;
52 |
53 | // Compute shader library
54 | Microsoft::WRL::ComPtr m_BC6H_tryModeG10CS;
55 | Microsoft::WRL::ComPtr m_BC6H_tryModeLE10CS;
56 | Microsoft::WRL::ComPtr m_BC6H_encodeBlockCS;
57 |
58 | Microsoft::WRL::ComPtr m_BC7_tryMode456CS;
59 | Microsoft::WRL::ComPtr m_BC7_tryMode137CS;
60 | Microsoft::WRL::ComPtr m_BC7_tryMode02CS;
61 | Microsoft::WRL::ComPtr m_BC7_encodeBlockCS;
62 | };
63 |
64 | } // namespace
65 |
--------------------------------------------------------------------------------
/samples/test-harness/src/thirdparty/directxtex/Shaders/CompileShaders.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | rem Copyright (c) Microsoft Corporation.
3 | rem Licensed under the MIT License.
4 |
5 | setlocal
6 | set error=0
7 |
8 | set FXCOPTS=/nologo /WX /Ges /Zi /Zpc /Qstrip_reflect /Qstrip_debug
9 |
10 | set PCFXC="%WindowsSdkVerBinPath%x86\fxc.exe"
11 | if exist %PCFXC% goto continue
12 | set PCFXC="%WindowsSdkBinPath%%WindowsSDKVersion%\x86\fxc.exe"
13 | if exist %PCFXC% goto continue
14 | set PCFXC="%WindowsSdkDir%bin\%WindowsSDKVersion%\x86\fxc.exe"
15 | if exist %PCFXC% goto continue
16 |
17 | set PCFXC=fxc.exe
18 |
19 | :continue
20 | @if not exist Compiled mkdir Compiled
21 | call :CompileShader BC7Encode TryMode456CS
22 | call :CompileShader BC7Encode TryMode137CS
23 | call :CompileShader BC7Encode TryMode02CS
24 | call :CompileShader BC7Encode EncodeBlockCS
25 |
26 | call :CompileShader BC6HEncode TryModeG10CS
27 | call :CompileShader BC6HEncode TryModeLE10CS
28 | call :CompileShader BC6HEncode EncodeBlockCS
29 |
30 | echo.
31 |
32 | if %error% == 0 (
33 | echo Shaders compiled ok
34 | ) else (
35 | echo There were shader compilation errors!
36 | )
37 |
38 | endlocal
39 | exit /b
40 |
41 | :CompileShader
42 | set fxc=%PCFXC% %1.hlsl %FXCOPTS% /Tcs_4_0 /E%2 /FhCompiled\%1_%2.inc /FdCompiled\%1_%2.pdb /Vn%1_%2
43 | echo.
44 | echo %fxc%
45 | %fxc% || set error=1
46 | exit /b
47 |
--------------------------------------------------------------------------------
/samples/test-harness/src/thirdparty/directxtex/Shaders/Compiled/BC6HEncode_EncodeBlockCS.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/samples/test-harness/src/thirdparty/directxtex/Shaders/Compiled/BC6HEncode_EncodeBlockCS.pdb
--------------------------------------------------------------------------------
/samples/test-harness/src/thirdparty/directxtex/Shaders/Compiled/BC6HEncode_TryModeG10CS.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/samples/test-harness/src/thirdparty/directxtex/Shaders/Compiled/BC6HEncode_TryModeG10CS.pdb
--------------------------------------------------------------------------------
/samples/test-harness/src/thirdparty/directxtex/Shaders/Compiled/BC6HEncode_TryModeLE10CS.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/samples/test-harness/src/thirdparty/directxtex/Shaders/Compiled/BC6HEncode_TryModeLE10CS.pdb
--------------------------------------------------------------------------------
/samples/test-harness/src/thirdparty/directxtex/Shaders/Compiled/BC7Encode_EncodeBlockCS.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/samples/test-harness/src/thirdparty/directxtex/Shaders/Compiled/BC7Encode_EncodeBlockCS.pdb
--------------------------------------------------------------------------------
/samples/test-harness/src/thirdparty/directxtex/Shaders/Compiled/BC7Encode_TryMode02CS.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/samples/test-harness/src/thirdparty/directxtex/Shaders/Compiled/BC7Encode_TryMode02CS.pdb
--------------------------------------------------------------------------------
/samples/test-harness/src/thirdparty/directxtex/Shaders/Compiled/BC7Encode_TryMode137CS.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/samples/test-harness/src/thirdparty/directxtex/Shaders/Compiled/BC7Encode_TryMode137CS.pdb
--------------------------------------------------------------------------------
/samples/test-harness/src/thirdparty/directxtex/Shaders/Compiled/BC7Encode_TryMode456CS.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/samples/test-harness/src/thirdparty/directxtex/Shaders/Compiled/BC7Encode_TryMode456CS.pdb
--------------------------------------------------------------------------------
/samples/test-harness/src/thirdparty/directxtex/scoped.h:
--------------------------------------------------------------------------------
1 | //-------------------------------------------------------------------------------------
2 | // scoped.h
3 | //
4 | // Utility header with helper classes for exception-safe handling of resources
5 | //
6 | // Copyright (c) Microsoft Corporation.
7 | // Licensed under the MIT License.
8 | //-------------------------------------------------------------------------------------
9 |
10 | #pragma once
11 |
12 | #include
13 | #include
14 | #include
15 | #include
16 |
17 | #ifndef WIN32
18 | #include
19 |
20 | struct aligned_deleter { void operator()(void* p) noexcept { free(p); } };
21 |
22 | using ScopedAlignedArrayFloat = std::unique_ptr;
23 |
24 | inline ScopedAlignedArrayFloat make_AlignedArrayFloat(uint64_t count)
25 | {
26 | uint64_t size = sizeof(float) * count;
27 | size = (size + 15u) & ~0xF;
28 | if (size > static_cast(UINT32_MAX))
29 | return nullptr;
30 |
31 | auto ptr = aligned_alloc(16, static_cast(size) );
32 | return ScopedAlignedArrayFloat(static_cast(ptr));
33 | }
34 |
35 | using ScopedAlignedArrayXMVECTOR = std::unique_ptr;
36 |
37 | inline ScopedAlignedArrayXMVECTOR make_AlignedArrayXMVECTOR(uint64_t count)
38 | {
39 | uint64_t size = sizeof(DirectX::XMVECTOR) * count;
40 | if (size > static_cast(UINT32_MAX))
41 | return nullptr;
42 | auto ptr = aligned_alloc(16, static_cast(size));
43 | return ScopedAlignedArrayXMVECTOR(static_cast(ptr));
44 | }
45 |
46 | #else // WIN32
47 | //---------------------------------------------------------------------------------
48 | #include
49 |
50 | struct aligned_deleter { void operator()(void* p) noexcept { _aligned_free(p); } };
51 |
52 | using ScopedAlignedArrayFloat = std::unique_ptr;
53 |
54 | inline ScopedAlignedArrayFloat make_AlignedArrayFloat(uint64_t count)
55 | {
56 | uint64_t size = sizeof(float) * count;
57 | if (size > static_cast(UINT32_MAX))
58 | return nullptr;
59 | auto ptr = _aligned_malloc(static_cast(size), 16);
60 | return ScopedAlignedArrayFloat(static_cast(ptr));
61 | }
62 |
63 | using ScopedAlignedArrayXMVECTOR = std::unique_ptr;
64 |
65 | inline ScopedAlignedArrayXMVECTOR make_AlignedArrayXMVECTOR(uint64_t count)
66 | {
67 | uint64_t size = sizeof(DirectX::XMVECTOR) * count;
68 | if (size > static_cast(UINT32_MAX))
69 | return nullptr;
70 | auto ptr = _aligned_malloc(static_cast(size), 16);
71 | return ScopedAlignedArrayXMVECTOR(static_cast(ptr));
72 | }
73 |
74 | //---------------------------------------------------------------------------------
75 | struct handle_closer { void operator()(HANDLE h) noexcept { assert(h != INVALID_HANDLE_VALUE); if (h) CloseHandle(h); } };
76 |
77 | using ScopedHandle = std::unique_ptr;
78 |
79 | inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; }
80 |
81 | //---------------------------------------------------------------------------------
82 | struct find_closer { void operator()(HANDLE h) noexcept { assert(h != INVALID_HANDLE_VALUE); if (h) FindClose(h); } };
83 |
84 | using ScopedFindHandle = std::unique_ptr;
85 |
86 | //---------------------------------------------------------------------------------
87 | class auto_delete_file
88 | {
89 | public:
90 | auto_delete_file(HANDLE hFile) noexcept : m_handle(hFile) {}
91 |
92 | auto_delete_file(const auto_delete_file&) = delete;
93 | auto_delete_file& operator=(const auto_delete_file&) = delete;
94 |
95 | ~auto_delete_file()
96 | {
97 | if (m_handle)
98 | {
99 | FILE_DISPOSITION_INFO info = {};
100 | info.DeleteFile = TRUE;
101 | (void)SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info));
102 | }
103 | }
104 |
105 | void clear() noexcept { m_handle = nullptr; }
106 |
107 | private:
108 | HANDLE m_handle;
109 | };
110 |
111 | #endif // WIN32
112 |
--------------------------------------------------------------------------------
/thirdparty/nvapi/amd64/nvapi64.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/thirdparty/nvapi/amd64/nvapi64.lib
--------------------------------------------------------------------------------
/thirdparty/nvapi/docs/NVAPI_Public_SDK_R520.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/thirdparty/nvapi/docs/NVAPI_Public_SDK_R520.pdf
--------------------------------------------------------------------------------
/thirdparty/nvapi/docs/NVAPI_SDKs_Samples_and_Tools_License_Agreement(Public).pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/thirdparty/nvapi/docs/NVAPI_SDKs_Samples_and_Tools_License_Agreement(Public).pdf
--------------------------------------------------------------------------------
/thirdparty/nvapi/nvHLSLExtns.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/thirdparty/nvapi/nvHLSLExtns.h
--------------------------------------------------------------------------------
/thirdparty/nvapi/nvHLSLExtnsInternal.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/thirdparty/nvapi/nvHLSLExtnsInternal.h
--------------------------------------------------------------------------------
/thirdparty/nvapi/nvShaderExtnEnums.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/thirdparty/nvapi/nvShaderExtnEnums.h
--------------------------------------------------------------------------------
/thirdparty/nvapi/nvapi_lite_common.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/thirdparty/nvapi/nvapi_lite_common.h
--------------------------------------------------------------------------------
/thirdparty/nvapi/nvapi_lite_d3dext.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/thirdparty/nvapi/nvapi_lite_d3dext.h
--------------------------------------------------------------------------------
/thirdparty/nvapi/nvapi_lite_salend.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/thirdparty/nvapi/nvapi_lite_salend.h
--------------------------------------------------------------------------------
/thirdparty/nvapi/nvapi_lite_salstart.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/thirdparty/nvapi/nvapi_lite_salstart.h
--------------------------------------------------------------------------------
/thirdparty/nvapi/nvapi_lite_sli.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/thirdparty/nvapi/nvapi_lite_sli.h
--------------------------------------------------------------------------------
/thirdparty/nvapi/nvapi_lite_stereo.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/thirdparty/nvapi/nvapi_lite_stereo.h
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Images/bp-category.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Images/bp-category.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Images/bp-component.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Images/bp-component.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Images/direct+rtxgi+texture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Images/direct+rtxgi+texture.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Images/direct+rtxgi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Images/direct+rtxgi.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Images/direct-only.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Images/direct-only.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Images/editor-ddgi-volume.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Images/editor-ddgi-volume.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Images/emissive-surfaces.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Images/emissive-surfaces.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Images/emissive-surfaces2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Images/emissive-surfaces2.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Images/green-lights.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Images/green-lights.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Images/plugins.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Images/plugins.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Images/probe-density.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Images/probe-density.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Images/probes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Images/probes.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Images/settings-gilighting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Images/settings-gilighting.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Images/settings-giprobes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Images/settings-giprobes.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Images/settings-givolume.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Images/settings-givolume.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Images/settings-project.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Images/settings-project.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Images/transform-gizmos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Images/transform-gizmos.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Images/volume-actor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Images/volume-actor.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/RTXGI.uplugin:
--------------------------------------------------------------------------------
1 | {
2 | "FileVersion": 3,
3 | "Version": 1,
4 | "VersionName": "1.1.40",
5 | "FriendlyName": "NVIDIA RTX Global Illumination",
6 | "Description": "Real-Time Ray Traced Global Illumination",
7 | "Category": "Rendering",
8 | "CreatedBy": "NVIDIA",
9 | "CreatedByURL": "http://developer.nvidia.com/rtxgi",
10 | "DocsURL": "",
11 | "MarketplaceURL": "",
12 | "SupportURL": "mailto:rtxgi-support-service@nvidia.com",
13 | "EnabledByDefault": false,
14 | "CanContainContent": true,
15 | "IsBetaVersion": false,
16 | "Installed": false,
17 | "Modules": [
18 | {
19 | "Name": "RTXGI",
20 | "Type": "Runtime",
21 | "LoadingPhase": "PostConfigInit",
22 | "WhitelistPlatforms": [
23 | "Win64"
24 | ]
25 | },
26 | {
27 | "Name": "RTXGIEditor",
28 | "Type": "Editor",
29 | "LoadingPhase": "PostEngineInit",
30 | "WhitelistPlatforms": [
31 | "Win64"
32 | ]
33 | }
34 | ]
35 | }
36 |
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Resources/Icon40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Resources/Icon40.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Resources/icon128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIAGameWorks/RTXGI-DDGI/f33e496ca31b3f0eec1c4e2cbaa8bb620e337fa6/ue4-plugin/4.27/RTXGI/Resources/icon128.png
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Shaders/Private/SDK/Common.ush:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #ifndef RTXGI_COMMON_HLSL
12 | #define RTXGI_COMMON_HLSL
13 |
14 | static const float RTXGI_PI = 3.1415926535897932f;
15 | static const float RTXGI_2PI = 6.2831853071795864f;
16 |
17 | //------------------------------------------------------------------------
18 | // Math Helpers
19 | //------------------------------------------------------------------------
20 |
21 | /**
22 | * Finds the smallest component of the vector.
23 | */
24 | float RTXGIMinComponent(float3 a)
25 | {
26 | return min(a.x, min(a.y, a.z));
27 | }
28 |
29 | /**
30 | * Finds the largest component of the vector.
31 | */
32 | float RTXGIMaxComponent(float3 a)
33 | {
34 | return max(a.x, max(a.y, a.z));
35 | }
36 |
37 | /**
38 | * Returns either -1 or 1 based on the sign of the input value.
39 | * If the input is zero, 1 is returned.
40 | */
41 | float RTXGISignNotZero(float v)
42 | {
43 | return (v >= 0.f) ? 1.f : -1.f;
44 | }
45 |
46 | /**
47 | * 2-component version of RTXGISignNotZero.
48 | */
49 | float2 RTXGISignNotZero(float2 v)
50 | {
51 | return float2(RTXGISignNotZero(v.x), RTXGISignNotZero(v.y));
52 | }
53 |
54 | /**
55 | * Return the given float value as an unsigned integer within the given numerical scale.
56 | */
57 | uint RTXGIFloatToUint(float v, float scale)
58 | {
59 | return (uint)floor(v * scale + 0.5f);
60 | }
61 |
62 | /**
63 | * Pack a float3 into a 32-bit unsigned integer.
64 | * All channels use 10 bits and 2 bits are unused.
65 | * Compliment of RTXGIUintToFloat3().
66 | */
67 | uint RTXGIFloat3ToUint(float3 input)
68 | {
69 | return (RTXGIFloatToUint(input.r, 1023.f)) | (RTXGIFloatToUint(input.g, 1023.f) << 10) | (RTXGIFloatToUint(input.b, 1023.f) << 20);
70 | }
71 |
72 | /**
73 | * Unpack a packed 32-bit unsigned integer to a float3.
74 | * Compliment of RTXGIFloat3ToUint().
75 | */
76 | float3 RTXGIUintToFloat3(uint input)
77 | {
78 | float3 unpacked;
79 | unpacked.x = (float)(input & 0x000003FF) / 1023.f;
80 | unpacked.y = (float)((input >> 10) & 0x000003FF) / 1023.f;
81 | unpacked.z = (float)((input >> 20) & 0x000003FF) / 1023.f;
82 | return unpacked;
83 | }
84 |
85 | /**
86 | * Rotate vector v with quaternion q.
87 | */
88 | float3 RTXGIQuaternionRotate(float3 v, float4 q)
89 | {
90 | float3 b = q.xyz;
91 | float b2 = dot(b, b);
92 | return (v * (q.w * q.w - b2) + b * (dot(v, b) * 2.f) + cross(b, v) * (q.w * 2.f));
93 | }
94 |
95 | /**
96 | * Quaternion conjugate.
97 | * For unit quaternions, conjugate equals inverse.
98 | * Use this to create a quaternion that rotates in the opposite direction.
99 | */
100 | float4 RTXGIQuaternionConjugate(float4 q)
101 | {
102 | return float4(-q.xyz, q.w);
103 | }
104 |
105 | #endif // RTXGI_COMMON_HLSL
106 |
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Shaders/Private/SDK/DDGIVolumeDescGPU.ush:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #ifndef RTXGI_DDGI_VOLUME_DESC_GPU_H
12 | #define RTXGI_DDGI_VOLUME_DESC_GPU_H
13 |
14 | /**
15 | * DDGIVolumeDescGPU
16 | * The condensed DDGIVolume descriptor for use on the GPU.
17 | */
18 | struct DDGIVolumeDescGPU
19 | {
20 | float3 origin;
21 | int numRaysPerProbe;
22 | float4 rotation;
23 | float3 probeGridSpacing;
24 | float probeMaxRayDistance;
25 | int3 probeGridCounts;
26 | float probeDistanceExponent;
27 | float probeHysteresis;
28 | float probeChangeThreshold;
29 | float probeBrightnessThreshold;
30 | float probeIrradianceEncodingGamma;
31 | float probeInverseIrradianceEncodingGamma;
32 | int probeNumIrradianceTexels;
33 | int probeNumDistanceTexels;
34 | float normalBias;
35 | float viewBias;
36 | float4x4 probeRayRotationTransform;
37 |
38 | int volumeMovementType;
39 | int3 probeScrollOffsets;
40 |
41 | float probeBackfaceThreshold;
42 | float probeMinFrontfaceDistance;
43 | };
44 |
45 | #endif // RTXGI_DDGI_VOLUME_DESC_GPU_H
46 |
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Shaders/Private/SDK/ddgi/ProbeStateClassifierCS.usf:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #include "/Engine/Private/Common.ush"
12 | #include "ProbeCommon.ush"
13 |
14 | int ProbeIndexStart;
15 | int ProbeIndexCount;
16 |
17 | // Probe ray radiance and hit distance
18 | RWTexture2D DDGIVolumeRayDataUAV;
19 |
20 | // Probe states
21 | RWTexture2D DDGIVolumeProbeStatesUAV;
22 |
23 | [numthreads(8, 4, 1)]
24 | void DDGIProbeStateClassifierCS(uint3 DispatchThreadID : SV_DispatchThreadID, uint GroupIndex : SV_GroupIndex)
25 | {
26 | // Compute the probe index for this thread
27 | int probeIndex = DDGIGetProbeIndex(DispatchThreadID.xy, DDGIVolume.probeGridCounts);
28 |
29 | // Early out if the thread maps past the number of probes
30 | int numProbes = DDGIVolume.probeGridCounts.x * DDGIVolume.probeGridCounts.y * DDGIVolume.probeGridCounts.z;
31 | if (probeIndex >= numProbes)
32 | {
33 | return;
34 | }
35 |
36 | // Handle round robin updating.
37 | // If this probe is outside of the window for updating, bail out.
38 | {
39 | int probeRRIndex = (probeIndex < ProbeIndexStart) ? probeIndex + numProbes : probeIndex;
40 | if (probeRRIndex >= ProbeIndexStart + ProbeIndexCount)
41 | return;
42 | }
43 |
44 | #if RTXGI_DDGI_INFINITE_SCROLLING_VOLUME
45 | int storageProbeIndex = DDGIGetProbeIndexOffset(probeIndex, DDGIVolume.probeGridCounts, DDGIVolume.probeScrollOffsets);
46 | #else
47 | int storageProbeIndex = probeIndex;
48 | #endif
49 | uint2 offsetTexelPosition = DDGIGetProbeTexelPosition(storageProbeIndex, DDGIVolume.probeGridCounts);
50 |
51 | // Compute the bounds used to check for surrounding geometry
52 | float3 geometryBounds = DDGIVolume.probeGridSpacing;
53 |
54 | // Conservatively increase the geometry search area
55 | geometryBounds *= 2.f;
56 |
57 | #if RTXGI_DDGI_PROBE_RELOCATION
58 | // A conservative bound that assumes the maximum offset value for this probe
59 | geometryBounds *= 1.45f;
60 | #endif
61 |
62 | float closestFrontfaceDistance = 1e27f;
63 | int backfaceCount = 0;
64 |
65 | // Get the number of ray samples to inspect
66 | int numRays = min(DDGIVolume.numRaysPerProbe, RTXGI_DDGI_NUM_FIXED_RAYS);
67 |
68 | // Iterate over the rays cast for this probe
69 | for (int rayIndex = 0; rayIndex < numRays; rayIndex++)
70 | {
71 | int2 rayTexCoord = int2(rayIndex, probeIndex);
72 |
73 | // Load the hit distance from the ray cast
74 | #if (RTXGI_DDGI_FORMAT_RADIANCE == 1)
75 | float hitDistance = DDGIVolumeRayDataUAV[rayTexCoord].a;
76 | #else
77 | float hitDistance = DDGIVolumeRayDataUAV[rayTexCoord].g;
78 | #endif
79 |
80 | // Don't include backface hit distances
81 | if (hitDistance < 0.f)
82 | {
83 | backfaceCount++;
84 | continue;
85 | }
86 |
87 | // Store the closest front face hit distance
88 | closestFrontfaceDistance = min(closestFrontfaceDistance, hitDistance);
89 | }
90 |
91 | // If this probe is near geometry, wake it up if the backface percentage is above probeBackfaceThreshold
92 | if (all(closestFrontfaceDistance <= geometryBounds) && (float(backfaceCount) / numRays < DDGIVolume.probeBackfaceThreshold))
93 | {
94 | DDGIVolumeProbeStatesUAV[offsetTexelPosition] = PROBE_STATE_ACTIVE;
95 | return;
96 | }
97 |
98 | DDGIVolumeProbeStatesUAV[offsetTexelPosition] = PROBE_STATE_INACTIVE;
99 | }
100 |
101 | [numthreads(8, 4, 1)]
102 | void DDGIProbeStateActivateAllCS(uint3 DispatchThreadID : SV_DispatchThreadID)
103 | {
104 | DDGIVolumeProbeStatesUAV[DispatchThreadID.xy] = PROBE_STATE_ACTIVE;
105 | }
106 |
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Shaders/Private/SDKDefines.ush:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #ifndef RTXGI_DEFINES_H
12 | #define RTXGI_DEFINES_H
13 |
14 | #ifndef RTXGI_NAME_D3D_OBJECTS
15 | #define RTXGI_NAME_D3D_OBJECTS 1
16 | #endif
17 |
18 | #ifndef RTXGI_PERF_MARKERS
19 | #define RTXGI_PERF_MARKERS 1
20 | #endif
21 |
22 | #define RTXGI_COORDINATE_SYSTEM_LEFT 0
23 | #define RTXGI_COORDINATE_SYSTEM_LEFT_Z_UP 1
24 | #define RTXGI_COORDINATE_SYSTEM_RIGHT 2
25 | #define RTXGI_COORDINATE_SYSTEM_RIGHT_Z_UP 3
26 |
27 | #ifndef RTXGI_COORDINATE_SYSTEM
28 | #define RTXGI_COORDINATE_SYSTEM RTXGI_COORDINATE_SYSTEM_LEFT_Z_UP
29 | #endif
30 |
31 | #endif /* RTXGI_DEFINES_H */
32 |
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Source/RTXGI/Private/DDGIVolume.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #include "DDGIVolume.h"
12 | #include "DDGIVolumeComponent.h"
13 | #include "Components/BoxComponent.h"
14 | #include "Engine/CollisionProfile.h"
15 |
16 | ADDGIVolume::ADDGIVolume(const FObjectInitializer& ObjectInitializer)
17 | : Super(ObjectInitializer)
18 | {
19 | DDGIVolumeComponent = CreateDefaultSubobject(TEXT("DDGI"));
20 |
21 | #if WITH_EDITORONLY_DATA
22 | BoxComponent = CreateDefaultSubobject(TEXT("Volume"));
23 | if (!IsRunningCommandlet())
24 | {
25 | if (BoxComponent != nullptr)
26 | {
27 | BoxComponent->SetBoxExtent(FVector{ 100.0f, 100.0f, 100.0f });
28 | BoxComponent->SetCollisionProfileName(UCollisionProfile::NoCollision_ProfileName);
29 | BoxComponent->SetupAttachment(DDGIVolumeComponent);
30 | }
31 | }
32 | #endif // WITH_EDITORONLY_DATA
33 |
34 | #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
35 | PrimaryActorTick.bCanEverTick = true;
36 | PrimaryActorTick.bStartWithTickEnabled = true;
37 | #endif
38 | }
39 |
40 | #if WITH_EDITOR
41 | void ADDGIVolume::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
42 | {
43 | Super::PostEditChangeProperty(PropertyChangedEvent);
44 | DDGIVolumeComponent->MarkRenderDynamicDataDirty();
45 | }
46 |
47 | void ADDGIVolume::PostEditMove(bool bFinished)
48 | {
49 | Super::PostEditMove(bFinished);
50 | DDGIVolumeComponent->MarkRenderDynamicDataDirty();
51 | }
52 | #endif
53 |
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Source/RTXGI/Private/DDGIVolumeDescGPU.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #ifndef RTXGI_DDGI_VOLUME_DESC_GPU_H
12 | #define RTXGI_DDGI_VOLUME_DESC_GPU_H
13 |
14 | /**
15 | * DDGIVolumeDescGPU
16 | * The condensed DDGIVolume descriptor for use on the GPU.
17 | */
18 | BEGIN_UNIFORM_BUFFER_STRUCT(FDDGIVolumeDescGPU, )
19 | SHADER_PARAMETER(FVector, origin)
20 | SHADER_PARAMETER(int, numRaysPerProbe)
21 | SHADER_PARAMETER(FVector4, rotation)
22 | SHADER_PARAMETER(FVector, probeGridSpacing)
23 | SHADER_PARAMETER(float, probeMaxRayDistance)
24 | SHADER_PARAMETER(FIntVector, probeGridCounts)
25 | SHADER_PARAMETER(float, probeDistanceExponent)
26 | SHADER_PARAMETER(float, probeHysteresis)
27 | SHADER_PARAMETER(float, probeChangeThreshold)
28 | SHADER_PARAMETER(float, probeBrightnessThreshold)
29 | SHADER_PARAMETER(float, probeIrradianceEncodingGamma)
30 | SHADER_PARAMETER(float, probeInverseIrradianceEncodingGamma)
31 | SHADER_PARAMETER(int, probeNumIrradianceTexels)
32 | SHADER_PARAMETER(int, probeNumDistanceTexels)
33 | SHADER_PARAMETER(float, normalBias)
34 | SHADER_PARAMETER(float, viewBias)
35 | SHADER_PARAMETER(FMatrix, probeRayRotationTransform)
36 |
37 | SHADER_PARAMETER(int, volumeMovementType)
38 | SHADER_PARAMETER(FIntVector, probeScrollOffsets)
39 |
40 | SHADER_PARAMETER(float, probeBackfaceThreshold)
41 | SHADER_PARAMETER(float, probeMinFrontfaceDistance)
42 | END_UNIFORM_BUFFER_STRUCT()
43 |
44 | #endif /* RTXGI_DDGI_VOLUME_DESC_GPU_H */
45 |
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Source/RTXGI/Private/DDGIVolumeUpdate.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "CoreMinimal.h"
14 |
15 | class FViewInfo;
16 | class FRDGBuilder;
17 | class UDDGIVolumeComponent;
18 | class FScene;
19 |
20 | namespace DDGIVolumeUpdate
21 | {
22 | void Startup();
23 | void Shutdown();
24 |
25 | void DDGIUpdatePerFrame_RenderThread(const FScene& Scene, const FViewInfo& View, FRDGBuilder& GraphBuilder);
26 | }
27 |
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Source/RTXGI/Private/RTXGIPlugin.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #include "RTXGIPlugin.h"
12 |
13 | #include "Modules/ModuleManager.h"
14 | #include "Interfaces/IPluginManager.h"
15 | #include "Tickable.h"
16 |
17 | #include "DDGIVolumeUpdate.h"
18 | #include "DDGIVolumeComponent.h"
19 | #include "Misc/Paths.h"
20 | #include "ShaderCore.h"
21 |
22 | #define LOCTEXT_NAMESPACE "FRTXGIPlugin"
23 |
24 | void FRTXGIPlugin::StartupDDGI()
25 | {
26 | DDGIVolumeUpdate::Startup();
27 | UDDGIVolumeComponent::Startup();
28 | }
29 |
30 | void FRTXGIPlugin::ShutdownDDGI()
31 | {
32 | DDGIVolumeUpdate::Shutdown();
33 | UDDGIVolumeComponent::Shutdown();
34 | }
35 |
36 | void FRTXGIPlugin::StartupModule()
37 | {
38 | // Get the base directory of this plugin
39 | FString BaseDir = IPluginManager::Get().FindPlugin(GetModularFeatureName())->GetBaseDir();
40 |
41 | // Register the shader directory
42 | FString PluginShaderDir = FPaths::Combine(BaseDir, TEXT("Shaders"));
43 | FString PluginMapping = TEXT("/Plugin/") + GetModularFeatureName();
44 | AddShaderSourceDirectoryMapping(PluginMapping, PluginShaderDir);
45 |
46 | StartupDDGI();
47 | }
48 |
49 | void FRTXGIPlugin::ShutdownModule()
50 | {
51 | // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
52 | // we call this function before unloading the module.
53 |
54 | ShutdownDDGI();
55 | }
56 |
57 | #undef LOCTEXT_NAMESPACE
58 |
59 | IMPLEMENT_MODULE(FRTXGIPlugin, RTXGI)
60 |
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Source/RTXGI/Private/RTXGIPluginSettings.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #include "RTXGIPluginSettings.h"
12 | #include "RTXGIPlugin.h"
13 | #include "DDGIVolumeComponent.h"
14 |
15 | #define LOCTEXT_NAMESPACE "RTXGIPlugin"
16 |
17 | #if WITH_EDITOR
18 |
19 | void URTXGIPluginSettings::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent)
20 | {
21 | Super::PostEditChangeProperty(PropertyChangedEvent);
22 |
23 | // tell the scene proxies about the bit depth change
24 | if (PropertyChangedEvent.MemberProperty)
25 | {
26 | if (PropertyChangedEvent.MemberProperty->GetFName() == GET_MEMBER_NAME_CHECKED(URTXGIPluginSettings, IrradianceBits) ||
27 | PropertyChangedEvent.MemberProperty->GetFName() == GET_MEMBER_NAME_CHECKED(URTXGIPluginSettings, DistanceBits))
28 | {
29 | FDDGIVolumeSceneProxy::OnIrradianceOrDistanceBitsChange();
30 | }
31 | }
32 | }
33 |
34 | FText URTXGIPluginSettings::GetSectionText() const
35 | {
36 | return LOCTEXT("SettingsDisplayName", "RTXGI");
37 | }
38 |
39 | #endif // WITH_EDITOR
40 |
41 | URTXGIPluginSettings::URTXGIPluginSettings()
42 | {
43 | CategoryName = TEXT("Plugins");
44 | SectionName = TEXT("RTXGI");
45 | }
46 |
47 | #undef LOCTEXT_NAMESPACE
48 |
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Source/RTXGI/Private/RTXGIPluginSettings.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "CoreMinimal.h"
14 | #include "Engine/EngineTypes.h"
15 | #include "Engine/DeveloperSettings.h"
16 | #include "RTXGIPluginSettings.generated.h"
17 |
18 | UENUM()
19 | enum class EDDGIIrradianceBits : uint8
20 | {
21 | n10 UMETA(DisplayName = "10 bit"),
22 | n32 UMETA(DisplayName = "32 bit (for bright lighting and extended luminance range rendering)")
23 | };
24 |
25 | UENUM()
26 | enum class EDDGIDistanceBits : uint8
27 | {
28 | n16 UMETA(DisplayName = "16 bit"),
29 | n32 UMETA(DisplayName = "32 bit (for larger distances)")
30 | };
31 |
32 | UENUM()
33 | enum class EDDGIProbesVisulizationMode : uint8
34 | {
35 | off UMETA(DisplayName = "Off"),
36 | irrad UMETA(DisplayName = "Irradiance"),
37 | distr UMETA(DisplayName = "Squared Hit Distance"),
38 | distg UMETA(DisplayName = "Hit Distance")
39 | };
40 |
41 | /**
42 | * Configure the RTXGI plug-in.
43 | */
44 | UCLASS(config=Engine, defaultconfig)
45 | class URTXGIPluginSettings : public UDeveloperSettings
46 | {
47 | GENERATED_BODY()
48 |
49 | public:
50 | URTXGIPluginSettings();
51 |
52 | #if WITH_EDITOR
53 | //~ UObject interface
54 | virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override;
55 |
56 | //~ UDeveloperSettings interface
57 | virtual FText GetSectionText() const override;
58 | #endif
59 |
60 | /** Light clipping can occur when lighting values are too large due to bright lights or extended radiance.
61 | * With 10-bits texture format, clipping can be componsated through the irradiance scalar parameter on the DDGI volume.
62 | * 32-bit texture format shows no clipping but with higher memory cost and slower updates.
63 | */
64 | UPROPERTY(config, EditAnywhere, Category=DDGI)
65 | EDDGIIrradianceBits IrradianceBits = EDDGIIrradianceBits::n10;
66 |
67 | /** Same story, but for probe distances and squared distances, used to prevent leaks.
68 | */
69 | UPROPERTY(config, EditAnywhere, Category=DDGI)
70 | EDDGIDistanceBits DistanceBits = EDDGIDistanceBits::n16;
71 |
72 | /** The radius of the spheres that visualize the ddgi probes */
73 | UPROPERTY(config, EditAnywhere, Category=DDGI)
74 | float DebugProbeRadius = 5.0f;
75 |
76 | /** The number of rays per frame DDGI is allowed to use to update volumes at max. One volume is updated per frame
77 | * in a weighted round robin fashion, based on each volume's update priority. It will use this many rays maximum
78 | * when updating a volume. A budget value of 0 means there is no budget, and all probes will be updated each time.
79 | * A default volume has 8x8x8 probes, and uses 288 rays per probe for updates. That means it takes 147,456 rays
80 | * to update all probes. If you set the budget to 50,000 rays, it would take 3 frames to update all the probes which
81 | * means the probes will be less responsive to lighting changes, but will take less processing time each frame to update.
82 | */
83 | UPROPERTY(config, EditAnywhere, Category = DDGI, meta = (ClampMin = "0"))
84 | int ProbeUpdateRayBudget = 0;
85 |
86 | /** Probes visualization mode for all volumes. */
87 | UPROPERTY(config, EditAnywhere, Category = DDGI)
88 | EDDGIProbesVisulizationMode ProbesVisualization = EDDGIProbesVisulizationMode::irrad;
89 |
90 | /** The depth value is divided by this scale before being shown on the sphere. */
91 | UPROPERTY(config, EditAnywhere, Category = DDGI)
92 | float ProbesDepthScale = 1000.0f;
93 |
94 | /** Save probes data to map file. Disabling it will clear existing saved data */
95 | UPROPERTY(config, EditAnywhere, Category = DDGI)
96 | bool SerializeProbes = true;
97 | };
98 |
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Source/RTXGI/Public/DDGIVolume.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 | #pragma once
11 |
12 | #include "CoreMinimal.h"
13 | #include "GameFramework/Actor.h"
14 |
15 | #include "DDGIVolume.generated.h"
16 |
17 | class UBillboardComponent;
18 | class UBoxComponent;
19 | class UDDGIVolumeComponent;
20 |
21 | UCLASS(HideCategories = (Navigation, Physics, Collision, Rendering, Tags, Cooking, Replication, Input, Actor, HLOD, Mobile, LOD))
22 | class RTXGI_API ADDGIVolume : public AActor
23 | {
24 | GENERATED_UCLASS_BODY()
25 |
26 | public:
27 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "GI", meta = (AllowPrivateAccess = "true"));
28 | UDDGIVolumeComponent* DDGIVolumeComponent;
29 |
30 | #if WITH_EDITORONLY_DATA
31 | UPROPERTY(Transient);
32 | UBoxComponent* BoxComponent = nullptr;
33 | #endif // WITH_EDITORONLY_DATA
34 |
35 | #if WITH_EDITOR
36 | void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override final;
37 | void PostEditMove(bool bFinished) override final;
38 | #endif
39 | };
40 |
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Source/RTXGI/Public/RTXGIPlugin.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "CoreMinimal.h"
14 | #include "Modules/ModuleManager.h"
15 | #include "Features/IModularFeatures.h"
16 | #include "Modules/ModuleInterface.h"
17 |
18 | /**
19 | * The public interface of the IRTXGIPlugin
20 | */
21 | class FRTXGIPlugin : public IModuleInterface, public IModularFeature
22 | {
23 | public:
24 | static FString GetModularFeatureName()
25 | {
26 | static FString FeatureName = FString(TEXT("RTXGI"));
27 | return FeatureName;
28 | }
29 |
30 | /** IModuleInterface implementation */
31 | virtual void StartupModule() override;
32 | virtual void ShutdownModule() override;
33 |
34 | private:
35 | void StartupDDGI();
36 | void ShutdownDDGI();
37 | };
38 |
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Source/RTXGI/RTXGI.Build.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | using UnrealBuildTool;
12 | using System.IO;
13 |
14 | public class RTXGI : ModuleRules
15 | {
16 | private string ModulePath
17 | {
18 | get { return ModuleDirectory; }
19 | }
20 |
21 | public RTXGI(ReadOnlyTargetRules Target) : base(Target)
22 | {
23 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
24 |
25 | PrivateDependencyModuleNames.AddRange(new string[]
26 | {
27 | "CoreUObject",
28 | "Engine",
29 | "RenderCore",
30 | "Renderer",
31 | "DeveloperSettings",
32 | "RHI",
33 | });
34 |
35 | PrivateIncludePaths.AddRange(new string[]
36 | {
37 | EngineDirectory + "/Source/Runtime/Renderer/Private",
38 | EngineDirectory + "/Source/Runtime/RenderCore/Public",
39 | });
40 |
41 | PublicDependencyModuleNames.AddRange(new string[]
42 | {
43 | "Core",
44 | "Projects"
45 | });
46 |
47 | PublicIncludePaths.AddRange(new string[]
48 | {
49 | "../Shaders/Shared"
50 | });
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Source/RTXGIEditor/Private/RTXGIDetails.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #include "RTXGIDetails.h"
12 | #include "DDGIVolume.h"
13 | #include "DDGIVolumeComponent.h"
14 | #include "Widgets/Input/SButton.h"
15 | #include "PropertyHandle.h"
16 | #include "DetailLayoutBuilder.h"
17 | #include "DetailWidgetRow.h"
18 | #include "DetailCategoryBuilder.h"
19 | #include "IDetailsView.h"
20 |
21 | #define LOCTEXT_NAMESPACE "RTXGIDetails"
22 |
23 | TSharedRef FRTXGIDetails::MakeInstance()
24 | {
25 | return MakeShareable(new FRTXGIDetails);
26 | }
27 |
28 | void FRTXGIDetails::CustomizeDetails(IDetailLayoutBuilder& DetailLayout)
29 | {
30 | const TArray< TWeakObjectPtr >& SelectedObjects = DetailLayout.GetSelectedObjects();
31 | for (int32 ObjectIndex = 0; ObjectIndex < SelectedObjects.Num(); ++ObjectIndex)
32 | {
33 | const TWeakObjectPtr& CurrentObject = SelectedObjects[ObjectIndex];
34 | if (CurrentObject.IsValid())
35 | {
36 | ADDGIVolume* CurrentDDGIVolumeActor = Cast(CurrentObject.Get());
37 | if (CurrentDDGIVolumeActor != NULL)
38 | {
39 | DDGIVolume = CurrentDDGIVolumeActor;
40 | break;
41 | }
42 | }
43 | }
44 |
45 | DetailLayout.EditCategory("GI Volume")
46 | .AddCustomRow(FText::FromString("Clear Probes Row"), true)
47 | .ValueContent()
48 | [
49 | SNew(SButton)
50 | .HAlign(HAlign_Center)
51 | .OnClicked(this, &FRTXGIDetails::OnClearProbes)
52 | [ SNew(STextBlock).Text(FText::FromString("Clear Probes")) ]
53 | ];
54 | }
55 |
56 | void FRTXGIDetails::CustomizeDetails(const TSharedPtr& DetailBuilder)
57 | {
58 | CachedDetailBuilder = DetailBuilder;
59 | CustomizeDetails(*DetailBuilder);
60 | }
61 |
62 | FReply FRTXGIDetails::OnClearProbes()
63 | {
64 | UDDGIVolumeComponent* DDGIComponent = DDGIVolume.IsValid() ? DDGIVolume->DDGIVolumeComponent : nullptr;
65 | if (DDGIComponent != nullptr)
66 | {
67 | DDGIComponent->ClearProbeData();
68 | }
69 | return FReply::Handled();
70 | }
71 |
72 | void FRTXGIDetails::OnSourceTypeChanged()
73 | {
74 | IDetailLayoutBuilder* DetailBuilder = CachedDetailBuilder.Pin().Get();
75 | if (DetailBuilder)
76 | {
77 | DetailBuilder->ForceRefreshDetails();
78 | }
79 | }
80 |
81 | #undef LOCTEXT_NAMESPACE
82 |
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Source/RTXGIEditor/Private/RTXGIEditor.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #include "RTXGIEditor.h"
12 | #include "DDGIVolume.h"
13 | #include "IPlacementModeModule.h"
14 | #include "Interfaces/IPluginManager.h"
15 | #include "Styling/SlateStyleRegistry.h"
16 | #include "RTXGIDetails.h"
17 | #include "PropertyEditorModule.h"
18 |
19 | #define LOCTEXT_NAMESPACE "FRTXGIEditor"
20 |
21 | TSharedPtr FRTXGIEditor::StyleSet;
22 |
23 | void FRTXGIEditor::StartupModule()
24 | {
25 | if (!StyleSet.IsValid())
26 | {
27 | StyleSet = MakeShared(FName("RTXGIPlacementStyle"));
28 | FString IconPath = IPluginManager::Get().FindPlugin(TEXT("RTXGI"))->GetBaseDir() + TEXT("/Resources/Icon40.png");
29 | StyleSet->Set("RTXGIPlacement.ModesIcon", new FSlateImageBrush(IconPath, FVector2D(40.0f, 40.0f)));
30 |
31 | FSlateStyleRegistry::RegisterSlateStyle(*StyleSet.Get());
32 | }
33 |
34 | IPlacementModeModule& PlacementModeModule = IPlacementModeModule::Get();
35 | PlacementModeModule.OnPlacementModeCategoryRefreshed().AddRaw(this, &FRTXGIEditor::OnPlacementModeRefresh);
36 |
37 | //Get the property module
38 | FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked("PropertyEditor");
39 | //Register the custom details panel we have created
40 | PropertyModule.RegisterCustomClassLayout(ADDGIVolume::StaticClass()->GetFName(), FOnGetDetailCustomizationInstance::CreateStatic(&FRTXGIDetails::MakeInstance));
41 | }
42 |
43 | void FRTXGIEditor::ShutdownModule()
44 | {
45 | // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
46 | // we call this function before unloading the module.
47 | if (StyleSet.IsValid())
48 | {
49 | FSlateStyleRegistry::UnRegisterSlateStyle(*StyleSet.Get());
50 | ensure(StyleSet.IsUnique());
51 | StyleSet.Reset();
52 | }
53 |
54 | if (IPlacementModeModule::IsAvailable())
55 | {
56 | IPlacementModeModule::Get().OnPlacementModeCategoryRefreshed().RemoveAll(this);
57 | }
58 | }
59 |
60 | void FRTXGIEditor::OnPlacementModeRefresh(FName CategoryName)
61 | {
62 | static FName VolumeName = FName(TEXT("Volumes"));
63 | if (CategoryName == VolumeName)
64 | {
65 | FPlaceableItem* DDGIVolumePlacement = new FPlaceableItem(
66 | *UActorFactory::StaticClass(),
67 | FAssetData(ADDGIVolume::StaticClass()),
68 | FName("RTXGIPlacement.ModesIcon"),
69 | TOptional(),
70 | TOptional(),
71 | FText::FromString("RTXGI DDGI Volume")
72 | );
73 |
74 | IPlacementModeModule::Get().RegisterPlaceableItem(CategoryName, MakeShareable(DDGIVolumePlacement));
75 | }
76 | }
77 |
78 | #undef LOCTEXT_NAMESPACE
79 |
80 | IMPLEMENT_MODULE(FRTXGIEditor, RTXGIEditor)
81 |
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Source/RTXGIEditor/Public/RTXGIDetails.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "CoreMinimal.h"
14 | #include "UObject/WeakObjectPtr.h"
15 | #include "Input/Reply.h"
16 | #include "IDetailCustomization.h"
17 |
18 | class ADDGIVolume;
19 | class IDetailLayoutBuilder;
20 |
21 | class FRTXGIDetails : public IDetailCustomization
22 | {
23 | public:
24 | /** Makes a new instance of this detail layout class for a specific detail view requesting it */
25 | static TSharedRef MakeInstance();
26 | private:
27 |
28 | /** IDetailCustomization interface */
29 | virtual void CustomizeDetails(IDetailLayoutBuilder& DetailLayout) override;
30 | virtual void CustomizeDetails(const TSharedPtr& DetailBuilder) override;
31 |
32 | FReply OnClearProbes();
33 |
34 | void OnSourceTypeChanged();
35 |
36 | private:
37 | // The detail builder for this customization
38 | TWeakPtr CachedDetailBuilder;
39 |
40 | /** The selected DDGI Volume */
41 | TWeakObjectPtr DDGIVolume;
42 | };
43 |
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Source/RTXGIEditor/Public/RTXGIEditor.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | #pragma once
12 |
13 | #include "CoreMinimal.h"
14 | #include "Modules/ModuleManager.h"
15 | #include "Features/IModularFeatures.h"
16 | #include "Modules/ModuleInterface.h"
17 | #include "Styling/SlateStyle.h"
18 |
19 | /**
20 | * The public interface of the RTXGIPlacement
21 | */
22 | class FRTXGIEditor : public IModuleInterface, public IModularFeature
23 | {
24 | public:
25 | static FString GetModularFeatureName()
26 | {
27 | static FString FeatureName = FString(TEXT("RTXGIEditor"));
28 | return FeatureName;
29 | }
30 |
31 | /** IModuleInterface implementation */
32 | virtual void StartupModule() override;
33 | virtual void ShutdownModule() override;
34 |
35 | private:
36 | static TSharedPtr StyleSet;
37 | void OnPlacementModeRefresh(FName CategoryName);
38 | };
39 |
--------------------------------------------------------------------------------
/ue4-plugin/4.27/RTXGI/Source/RTXGIEditor/RTXGIEditor.Build.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
3 | *
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property
5 | * and proprietary rights in and to this software, related documentation
6 | * and any modifications thereto. Any use, reproduction, disclosure or
7 | * distribution of this software and related documentation without an express
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 | */
10 |
11 | using UnrealBuildTool;
12 | using System.IO;
13 |
14 | public class RTXGIEditor : ModuleRules
15 | {
16 | private string ModulePath
17 | {
18 | get { return ModuleDirectory; }
19 | }
20 |
21 | public RTXGIEditor(ReadOnlyTargetRules Target) : base(Target)
22 | {
23 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
24 |
25 | PrivateDependencyModuleNames.AddRange(new string[]
26 | {
27 | "CoreUObject",
28 | "Engine",
29 | "PropertyEditor",
30 | "Slate",
31 | "SlateCore",
32 | "UnrealEd",
33 | "PlacementMode",
34 | "RTXGI",
35 | });
36 |
37 | PublicDependencyModuleNames.AddRange(new string[]
38 | {
39 | "Core",
40 | "Projects"
41 | });
42 | }
43 | }
44 |
--------------------------------------------------------------------------------