Skip to content

Commit

Permalink
Updated to v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
avmihut committed Jun 3, 2024
1 parent 0739338 commit ee016ca
Show file tree
Hide file tree
Showing 21 changed files with 233 additions and 205 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# RTXGI SDK Change Log

## 2.1.0

### Fixed issues
- Internal fix for NRC to allow it to run on NVIDIA 20xx series GPUs
- Window resizing for the pathtracer sample

### API changes
- NRC's `CountersData` buffer is now of type `StructuredBuffer`
- SHARC's `VoxelData` buffers are now of type `StructuredBuffer`
- SHARC modifications to improve GLSL compatibility

### Misc. changes
- Readability improvements for the code sample and documentation
- Update to dependencies:
- NRD version in use is [v4.6.1](https://github.com/NVIDIAGameWorks/RayTracingDenoiser/tree/db4f66f301406344211d86463d9f3ba43e74412a)
- Donut version in use is [e053410](https://github.com/NVIDIAGameWorks/donut/tree/e05341011f82ca72dd0d37adc8ef9235ef5607b3)

## 2.0.0
Initial release.
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
<br />
<div align="center">
·
<a href="CHANGELOG.md">Change Log</a>
·
<a href="docs/QuickStart.md">Quick Start</a>
·
<a href="docs/NrcGuide.md">NRC Guide</a>
·
<a href="docs/SharcGuide.md">SHaRC Guide</a>
<a href="https://github.com/NVIDIAGameWorks/SHARC/blob/main/docs/Integration.md">SHARC Guide</a>
·
</div>
<br/>
Expand All @@ -16,7 +18,7 @@ Advances in path tracing techniques have allowed for the capture of lighting dat

These techniques may be combined with a regular path tracing pipeline for the primary rays, sampling cached data only for indirect bounce evaluation. By replacing the whole path trace with a single ray hit evaluation and cache lookup, the cost is reduced with little to no compromise in signal quality, while remaining responsive to change and supporting large-scale dynamic scenes with complex lighting setups.

RTXGI SDK provides an example integration (DX12 and Vulkan) of two state-of-the-art radiance caching techniques for path tracing - a (currently experimental) AI-based approach known as Neural Radiance Cache (NRC), and Spatial Hash Radiance Cache (SHaRC). The former requires Tensor Cores while the latter has certain limitations but is currently supported on a wider range of hardware without any vendor-specific requirements. RTXGI SDK also hosts documentation and distribution corresponding to both of these techniques, see [Project Structure][ProjectStructure] section for further details.
RTXGI SDK provides an example integration (DX12 and Vulkan) of two state-of-the-art radiance caching techniques for path tracing - a (currently experimental) AI-based approach known as Neural Radiance Cache (NRC), and Spatially Hashed Radiance Cache (SHARC). The former requires Tensor Cores while the latter has certain limitations but is currently supported on a wider range of hardware without any vendor-specific requirements. RTXGI SDK also hosts documentation and distribution corresponding to both of these techniques, see [Project Structure][ProjectStructure] section for further details.


## Project structure
Expand All @@ -33,24 +35,35 @@ RTXGI SDK provides an example integration (DX12 and Vulkan) of two state-of-the-
## Getting up and running

### Prerequisites
Any DXR GPU - SHaRC **|** Min 30xx - NRC **|** [CMake v3.24.3][CMake] **|** [Git LFS][LFS] **|** [Vulkan SDK 1.3.268.0][VKSDK] **|** [VS 2022][VS22] **|** Windows SDK ≥ 10.0.20348.0
Any DXR GPU **|** [CMake v3.24.3][CMake] **|** [Git LFS][LFS] **|** [Vulkan SDK 1.3.268.0][VKSDK] **|** [VS 2022][VS22] **|** Windows SDK ≥ 10.0.20348.0 **|** Latest driver recommended

### Further steps
- [Quick start guide][QuickStart] for building and running the pathtracer example.
- [NRC integration guide][NrcGuide] and the [SHaRC integration guide][SharcGuide] respectively.
- [NRC integration guide][NrcGuide] and the [SHARC integration guide][SharcGuide] respectively.
- [Change log][ChangeLog] for release information.

## Contact
RTXGI SDK is actively being developed. Please report any issues directly through the GitHub issue tracker, and for any information or suggestions contact us at [email protected].

## Citation
Use the following BibTex entry to cite the usage of RTXGI in published research:
```bibtex
@online{RTXGI,
title = {{{NVIDIA}}\textregistered{} {RTXGI}},
author = {{NVIDIA}},
year = 2024,
url = {https://github.com/NVIDIAGameWorks/RTXGI},
urldate = {2024-03-18},
}
```

## License
See [LICENSE.md](LICENSE.md)

### RTXGI v1.x
Please note that version v1.x of RTXGI which includes the DDGI algorithm is located in a separate repo at the following url: https://github.com/NVIDIAGameWorks/RTXGI-DDGI"


[ChangeLog]: CHANGELOG.md
[QuickStart]: docs/QuickStart.md
[SharcGuide]: docs/SharcGuide.md
[SharcGuide]: https://github.com/NVIDIAGameWorks/SHARC/blob/main/docs/Integration.md
[NrcGuide]: docs/NrcGuide.md
[ProjectStructure]: #project-structure
[docs]: docs
Expand Down
21 changes: 13 additions & 8 deletions docs/NrcGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ Below is another variant which shows how NRC is integrated if the primary ray is

void RayGenFunc()
{
// Prepare launchIndex, launchDimensions
if (NrcIsUpdateMode())
launchIndex = (float2(DispatchRaysIndex().xy) + Rng::GetFloat2()) * nrcTrainingDownscaleFactor;
else
launchIndex = DispatchRaysIndex().xy;

// Load data from G-Buffer...

// Flag G-Buffer miss to write it to NRC later
Expand All @@ -171,8 +177,7 @@ void RayGenFunc()

if (NrcIsUpdateMode()) {/*Add random offset to pixel's coords...*/}
if(flagGbufferMiss)
{
if(flagGbufferMiss) {
NrcUpdateOnMiss(nrcPathState);
break;
}
Expand Down Expand Up @@ -203,8 +208,7 @@ void RayGenFunc()
// Account for emissives and evaluate NEE with RIS...

// Terminate loop early on last bounce (don't sample BRDF)
if (bounce == gData.maxPathVertices - 1)
{
if (bounce == gData.maxPathVertices - 1) {
NrcSetDebugPathTerminationReason(...);
break;
}
Expand Down Expand Up @@ -248,23 +252,24 @@ void CustomResolve(int3 DispatchThreadID : SV_DispatchThreadID)
{
const uint2 launchIndex = DispatchThreadID.xy;
if(any(launchIndex >= screenResolution))
return;
return;

const uint sampleIndex = 0;
const uint samplesPerPixel = 1;

const uint pathIndex = NrcGetPathInfoIndex(screenResolution, launchIndex, sampleIndex, samplesPerPixel);
const NrcQueryPathInfo path = NrcUnpackQueryPathInfo(nrcQueryPathInfo[pathIndex]);

const NrcQueryPathInfo path = NrcUnpackQueryPathInfo(nrcQueryPathInfo[pathIndex]);

if (path.queryBufferIndex < 0xFFFFFFFF)
if (path.queryBufferIndex < 0xFFFFFFFF)
{
float3 radiance = NrcUnpackRadiance(nrcQueryRadiance[path.queryBufferIndex], radianceUnpackMultiplier) * path.prefixThroughput;
uint uBrdfType = brdfTypeTarget[launchIndex];

if(uBrdfType == BRDF_SPECULAR)
specularPathTracingTarget[launchIndex] += float4(radiance, 0.0f);
if(uBrdfType == BRDF_DIFFUSE)
diffusePathTracingTarget[launchIndex] += float4(radiance, 0.0f);
diffusePathTracingTarget[launchIndex] += float4(radiance, 0.0f);
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/QuickStart.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ This showcases an elementary path tracer that relies on either NRC or SHARC to t
**7. Tone mapping.** Post processing section that currently only accounts for tone mapping - useful for clamping radiance values.
[NrcGuide]: NrcGuide.md
[SharcGuide]: SharcGuide.md
[SharcGuide]: https://github.com/NVIDIAGameWorks/SHARC/blob/main/docs/Integration.md
[Prereq]: ../README.md/#prerequisites
8 changes: 0 additions & 8 deletions docs/SharcGuide.md

This file was deleted.

2 changes: 1 addition & 1 deletion external/RayTracingDenoiser
4 changes: 2 additions & 2 deletions samples/pathtracer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ set(SHARC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../sdk-libraries)

# Shader Model 6_6 requires Agility SDK on Windows 10.
if(DONUT_WITH_VULKAN)
set (SHADERMAKE_GENERAL_ARGS_SPIRV "--shaderModel 6_6 -I ${NRC_DIR}/include -I ${SHARC_INCLUDE_DIR}/Sharc/Shaders/Include --vulkanMemoryLayout dx")
set (SHADERMAKE_GENERAL_ARGS_SPIRV "--shaderModel 6_6 -I ${NRC_DIR}/include -I ${SHARC_INCLUDE_DIR}/Sharc/include --vulkanMemoryLayout dx")
endif()
set (SHADERMAKE_GENERAL_ARGS_DXIL "--shaderModel 6_6 --useAPI --WX --PDB -I ${NRC_DIR}/include -I ${SHARC_INCLUDE_DIR}/Sharc/Shaders/Include")
set (SHADERMAKE_GENERAL_ARGS_DXIL "--shaderModel 6_6 --useAPI --WX --PDB -I ${NRC_DIR}/include -I ${SHARC_INCLUDE_DIR}/Sharc/include")

donut_compile_shaders(
TARGET ${project}_shaders
Expand Down
2 changes: 1 addition & 1 deletion samples/pathtracer/NrcIntegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <string>
#include <mutex>
#include "../../donut/nvrhi/src/vulkan/vulkan-backend.h"

using namespace donut::math;

#define SAFE_RELEASE(x) \
Expand Down Expand Up @@ -75,7 +76,6 @@ static void NRCMemoryEventsCallback(nrc::MemoryEventType eventType, size_t size,

static std::mutex loggerMutex;

// Make the logging thread-safe
loggerMutex.lock();
{
std::string message = "NRC SDK Memory Stats: ";
Expand Down
6 changes: 3 additions & 3 deletions samples/pathtracer/NrdConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@

namespace NrdConfig
{
nrd::RelaxDiffuseSpecularSettings GetDefaultRELAXSettings()
nrd::RelaxSettings GetDefaultRELAXSettings()
{
nrd::RelaxDiffuseSpecularSettings settings;
nrd::RelaxSettings settings;
settings.enableAntiFirefly = true;
settings.hitDistanceReconstructionMode = nrd::HitDistanceReconstructionMode::AREA_3X3;

settings.historyFixFrameNum = 4;
settings.spatialVarianceEstimationHistoryThreshold = 4;

settings.enableReprojectionTestSkippingWithoutMotion = false;
//settings.enableReprojectionTestSkippingWithoutMotion = false;

// (pixels) - pre-accumulation spatial reuse pass blur radius (0 = disabled, must be used in case of probabilistic sampling) <- we're using probabilistic sampling
settings.diffusePrepassBlurRadius = 0.0f;
Expand Down
2 changes: 1 addition & 1 deletion samples/pathtracer/NrdConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ namespace NrdConfig
MaxCount
};

nrd::RelaxDiffuseSpecularSettings GetDefaultRELAXSettings();
nrd::RelaxSettings GetDefaultRELAXSettings();
nrd::ReblurSettings GetDefaultREBLURSettings();
}
28 changes: 11 additions & 17 deletions samples/pathtracer/NrdIntegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ bool NrdIntegration::Initialize(uint32_t width, uint32_t height, donut::engine::

const nrd::DenoiserDesc denoiserDescs[] =
{
{ m_identifier, m_denoiser, uint16_t(width), uint16_t(height)}
{ m_identifier, m_denoiser}
};

nrd::InstanceCreationDesc instanceCreationDesc = {};
Expand Down Expand Up @@ -127,18 +127,10 @@ bool NrdIntegration::Initialize(uint32_t width, uint32_t height, donut::engine::
addressMode = nvrhi::SamplerAddressMode::Clamp;
filter = false;
break;
case nrd::Sampler::NEAREST_MIRRORED_REPEAT:
addressMode = nvrhi::SamplerAddressMode::Mirror;
filter = false;
break;
case nrd::Sampler::LINEAR_CLAMP:
addressMode = nvrhi::SamplerAddressMode::Clamp;
filter = true;
break;
case nrd::Sampler::LINEAR_MIRRORED_REPEAT:
addressMode = nvrhi::SamplerAddressMode::Mirror;
filter = true;
break;
default:
assert(!"Unknown NRD sampler mode");
break;
Expand Down Expand Up @@ -268,10 +260,9 @@ bool NrdIntegration::Initialize(uint32_t width, uint32_t height, donut::engine::
ss << "NRD " << (isPermanent ? "Permanent" : "Transient") << "Texture [" << (isPermanent ? i : i - instanceDesc.permanentPoolSize) << "]";

nvrhi::TextureDesc textureDesc;
textureDesc.width = nrdTextureDesc.width;
textureDesc.height = nrdTextureDesc.height;
textureDesc.width = width;
textureDesc.height = height;
textureDesc.format = format;
textureDesc.mipLevels = nrdTextureDesc.mipNum;
textureDesc.dimension = nvrhi::TextureDimension::Texture2D;
textureDesc.initialState = nvrhi::ResourceStates::ShaderResource;
textureDesc.keepInitialState = true;
Expand Down Expand Up @@ -341,6 +332,14 @@ void NrdIntegration::RunDenoiserPasses(
commonSettings.cameraJitter[1] = pixelOffset.y;
commonSettings.cameraJitterPrev[0] = prevPixelOffset.x;
commonSettings.cameraJitterPrev[1] = prevPixelOffset.y;
commonSettings.resourceSize[0] = view.GetViewExtent().width();
commonSettings.resourceSize[1] = view.GetViewExtent().height();
commonSettings.resourceSizePrev[0] = viewPrev.GetViewExtent().width();
commonSettings.resourceSizePrev[1] = viewPrev.GetViewExtent().height();
commonSettings.rectSize[0] = view.GetViewExtent().width();
commonSettings.rectSize[1] = view.GetViewExtent().height();
commonSettings.rectSizePrev[0] = viewPrev.GetViewExtent().width();
commonSettings.rectSizePrev[1] = viewPrev.GetViewExtent().height();
commonSettings.frameIndex = frameIndex;
commonSettings.enableValidation = enableValidation;
commonSettings.disocclusionThreshold = disocclusionThreshold;
Expand Down Expand Up @@ -387,8 +386,6 @@ void NrdIntegration::RunDenoiserPasses(
assert(resourceIndex < dispatchDesc.resourcesNum);
const nrd::ResourceDesc& resource = dispatchDesc.resources[resourceIndex];

assert(resource.stateNeeded == nrdDescriptorRange.descriptorType);

nvrhi::TextureHandle texture;
switch (resource.type)
{
Expand Down Expand Up @@ -427,9 +424,6 @@ void NrdIntegration::RunDenoiserPasses(
assert(texture);

nvrhi::TextureSubresourceSet subresources = nvrhi::AllSubresources;
subresources.baseMipLevel = resource.mipOffset;
subresources.numMipLevels = resource.mipNum;

nvrhi::BindingSetItem setItem = nvrhi::BindingSetItem::None();
setItem.resourceHandle = texture;
setItem.slot = nrdDescriptorRange.baseRegisterIndex + descriptorOffset;
Expand Down
Loading

0 comments on commit ee016ca

Please sign in to comment.