Skip to content

Commit

Permalink
v4.9.1:
Browse files Browse the repository at this point in the history
HIGHLIGHTS:
- improvements and bug fixes

DETAILS:
- NRD: improved per-frame random rotations offer a better distribution of samples across frames (barely visible in OCCLUSION and SIGMA)
- REFERENCE: split-screen and resolution scaling related bug fixes
- NRD INTEGRATION: updated NRI
- updated MathLib
  • Loading branch information
dzhdanNV committed Aug 14, 2024
1 parent 7942116 commit 7e36d4b
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 52 deletions.
2 changes: 1 addition & 1 deletion External/MathLib
Submodule MathLib updated 1 files
+10 −0 ml.hlsli
4 changes: 2 additions & 2 deletions Include/NRD.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.

#define NRD_VERSION_MAJOR 4
#define NRD_VERSION_MINOR 9
#define NRD_VERSION_BUILD 0
#define NRD_VERSION_DATE "1 August 2024"
#define NRD_VERSION_BUILD 1
#define NRD_VERSION_DATE "14 August 2024"

#if defined(_MSC_VER)
#define NRD_CALL __fastcall
Expand Down
4 changes: 2 additions & 2 deletions Integration/NRDIntegration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.
#include "NRDIntegration.h"

static_assert(NRD_VERSION_MAJOR >= 4 && NRD_VERSION_MINOR >= 5, "Unsupported NRD version!");
static_assert(NRI_VERSION_MAJOR >= 1 && NRI_VERSION_MINOR >= 125, "Unsupported NRI version!");
static_assert(NRI_VERSION_MAJOR >= 1 && NRI_VERSION_MINOR >= 140, "Unsupported NRI version!");

#ifdef _WIN32
#define alloca _alloca
Expand Down Expand Up @@ -133,7 +133,7 @@ void NrdIntegration::CreatePipelines()
uint32_t samplerOffset = 0;
uint32_t textureOffset = 0;
uint32_t storageTextureAndBufferOffset = 0;
if (m_NRI->GetDeviceDesc(*m_Device).graphicsAPI == nri::GraphicsAPI::VULKAN)
if (m_NRI->GetDeviceDesc(*m_Device).graphicsAPI == nri::GraphicsAPI::VK)
{
const nrd::LibraryDesc& nrdLibraryDesc = nrd::GetLibraryDesc();
constantBufferOffset = nrdLibraryDesc.spirvBindingOffsets.constantBufferOffset;
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NVIDIA REAL-TIME DENOISERS v4.9.0 (NRD)
# NVIDIA REAL-TIME DENOISERS v4.9.1 (NRD)

[![Build NRD SDK](https://github.com/NVIDIAGameWorks/RayTracingDenoiser/actions/workflows/build.yml/badge.svg)](https://github.com/NVIDIAGameWorks/RayTracingDenoiser/actions/workflows/build.yml)

Expand Down
2 changes: 1 addition & 1 deletion Resources/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ Versioning rules:

#define VERSION_MAJOR 4
#define VERSION_MINOR 9
#define VERSION_BUILD 0
#define VERSION_BUILD 1

#define VERSION_STRING STR(VERSION_MAJOR.VERSION_MINOR.VERSION_BUILD encoding=NRD_NORMAL_ENCODING.NRD_ROUGHNESS_ENCODING)
2 changes: 1 addition & 1 deletion Shaders.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ REBLUR_Specular_SplitScreen.cs.hlsl -T cs
REBLUR_Specular_TemporalAccumulation.cs.hlsl -T cs
REBLUR_Specular_TemporalStabilization.cs.hlsl -T cs
REBLUR_Validation.cs.hlsl -T cs
REFERENCE_SplitScreen.cs.hlsl -T cs
REFERENCE_Copy.cs.hlsl -T cs
REFERENCE_TemporalAccumulation.cs.hlsl -T cs
RELAX_ClassifyTiles.cs.hlsl -T cs
RELAX_Diffuse_AntiFirefly.cs.hlsl -T cs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ distribution of this software and related documentation without an express
license agreement from NVIDIA CORPORATION is strictly prohibited.
*/

NRD_CONSTANTS_START( REFERENCE_SplitScreenConstants )
NRD_CONSTANTS_START( REFERENCE_CopyConstants )
NRD_CONSTANT( float2, gRectSizeInv )
NRD_CONSTANT( float, gSplitScreen )
NRD_CONSTANT( float, gDebug ) // only for availability in Common.hlsl
NRD_CONSTANT( float, gViewZScale ) // only for availability in Common.hlsl
NRD_CONSTANTS_END
Expand All @@ -22,11 +24,11 @@ NRD_OUTPUTS_START
NRD_OUTPUTS_END

// Macro magic
#define REFERENCE_SplitScreenGroupX 16
#define REFERENCE_SplitScreenGroupY 16
#define REFERENCE_CopyGroupX 16
#define REFERENCE_CopyGroupY 16

// Redirection
#undef GROUP_X
#undef GROUP_Y
#define GROUP_X REFERENCE_SplitScreenGroupX
#define GROUP_Y REFERENCE_SplitScreenGroupY
#define GROUP_X REFERENCE_CopyGroupX
#define GROUP_Y REFERENCE_CopyGroupY
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.

NRD_CONSTANTS_START( REFERENCE_TemporalAccumulationConstants )
NRD_CONSTANT( uint2, gRectOrigin )
NRD_CONSTANT( float2, gRectSizeInv )
NRD_CONSTANT( float, gSplitScreen )
NRD_CONSTANT( float, gAccumSpeed )
NRD_CONSTANT( float, gDebug ) // only for availability in Common.hlsl
NRD_CONSTANT( float, gViewZScale ) // only for availability in Common.hlsl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.
#include "NRD.hlsli"
#include "ml.hlsli"

#include "REFERENCE_SplitScreen.resources.hlsli"
#include "REFERENCE_Copy.resources.hlsli"

#include "Common.hlsli"

[numthreads( GROUP_X, GROUP_Y, 1 )]
NRD_EXPORT void NRD_CS_MAIN( uint2 pixelPos : SV_DispatchThreadId )
{
gOut_Output[ pixelPos ] = gIn_Input[ pixelPos ];
float2 pixelUv = float2( pixelPos + 0.5 ) * gRectSizeInv;

if( pixelUv.x > gSplitScreen )
gOut_Output[ pixelPos ] = gIn_Input[ pixelPos ];
}
5 changes: 1 addition & 4 deletions Shaders/Source/REFERENCE_TemporalAccumulation.cs.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.
[numthreads( GROUP_X, GROUP_Y, 1 )]
NRD_EXPORT void NRD_CS_MAIN( uint2 pixelPos : SV_DispatchThreadId )
{
float2 pixelUv = float2( pixelPos + 0.5 ) * gRectSizeInv;

float4 input = gIn_Input[ pixelPos ];
float4 history = gInOut_History[ pixelPos ];
float4 result = lerp( history, input, gAccumSpeed );

gInOut_History[ pixelPos ] = pixelUv.x > gSplitScreen ? result : input;
gInOut_History[ pixelPos ] = result;
}

14 changes: 8 additions & 6 deletions Source/Denoisers/Reference.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.
*/

#include "../Shaders/Resources/REFERENCE_TemporalAccumulation.resources.hlsli"
#include "../Shaders/Resources/REFERENCE_SplitScreen.resources.hlsli"
#include "../Shaders/Resources/REFERENCE_Copy.resources.hlsli"

void nrd::InstanceImpl::Add_Reference(DenoiserData& denoiserData)
{
Expand Down Expand Up @@ -40,7 +40,7 @@ void nrd::InstanceImpl::Add_Reference(DenoiserData& denoiserData)

PushOutput( AsUint(ResourceType::OUT_SIGNAL) );

AddDispatch( REFERENCE_SplitScreen, REFERENCE_SplitScreen, 1 ); // TODO: rename to Copy
AddDispatch( REFERENCE_Copy, REFERENCE_Copy, 1 );
}

#undef DENOISER_NAME
Expand All @@ -56,7 +56,9 @@ void nrd::InstanceImpl::Update_Reference(const DenoiserData& denoiserData)

const ReferenceSettings& settings = denoiserData.settings.reference;

if (m_WorldToClip != m_WorldToClipPrev || m_CommonSettings.accumulationMode != AccumulationMode::CONTINUE)
if (m_WorldToClip != m_WorldToClipPrev || m_CommonSettings.accumulationMode != AccumulationMode::CONTINUE ||
m_CommonSettings.rectSize[0] != m_CommonSettings.rectSizePrev[0] ||
m_CommonSettings.rectSize[1] != m_CommonSettings.rectSizePrev[1])
m_AccumulatedFrameNum = 0;
else
m_AccumulatedFrameNum = min(m_AccumulatedFrameNum + 1, settings.maxAccumulatedFrameNum);
Expand All @@ -66,13 +68,13 @@ void nrd::InstanceImpl::Update_Reference(const DenoiserData& denoiserData)
{ // ACCUMULATE
REFERENCE_TemporalAccumulationConstants* consts = (REFERENCE_TemporalAccumulationConstants*)PushDispatch(denoiserData, AsUint(Dispatch::ACCUMULATE));
consts->gRectOrigin = uint2(m_CommonSettings.rectOrigin[0], m_CommonSettings.rectOrigin[1]);
consts->gRectSizeInv = float2(1.0f / float(rectW), 1.0f / float(rectH));
consts->gSplitScreen = m_CommonSettings.splitScreen;
consts->gAccumSpeed = 1.0f / (1.0f + float(m_AccumulatedFrameNum));
consts->gDebug = m_CommonSettings.debug;
}

{ // COPY
PushDispatch(denoiserData, AsUint(Dispatch::COPY));
REFERENCE_CopyConstants* consts = (REFERENCE_CopyConstants*)PushDispatch(denoiserData, AsUint(Dispatch::COPY));
consts->gRectSizeInv = float2(1.0f / float(rectW), 1.0f / float(rectH));
consts->gSplitScreen = m_CommonSettings.splitScreen;
}
}
19 changes: 6 additions & 13 deletions Source/InstanceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,20 +283,13 @@ nrd::Result nrd::InstanceImpl::SetCommonSettings(const CommonSettings& commonSet

memcpy(&m_CommonSettings, &commonSettings, sizeof(commonSettings));

// Rotators
float4 rndAngle = Rng::Hash::GetFloat4(m_RngState) * radians(360.0f);
// Rotators (respecting sample patterns symmetry)
float angle1 = Sequence::Weyl1D(0.5f, commonSettings.frameIndex) * radians(90.0f);
m_Rotator_PrePass = Geometry::GetRotator(angle1);

float ca = cos( rndAngle.x );
float sa = sin( rndAngle.x );
m_Rotator_PrePass = float4( ca, sa, -sa, ca );

ca = cos( rndAngle.y );
sa = sin( rndAngle.y );
m_Rotator_Blur = float4( ca, sa, -sa, ca );

ca = cos( rndAngle.z );
sa = sin( rndAngle.z );
m_Rotator_PostBlur = float4( ca, sa, -sa, ca );
float angle2 = Sequence::Weyl1D(0.0f, commonSettings.frameIndex) * radians(90.0f);
m_Rotator_Blur = Geometry::GetRotator(angle2);
m_Rotator_PostBlur = Geometry::GetRotator(angle2 + radians(45.0f));

// Main matrices
m_ViewToClip = float4x4
Expand Down
9 changes: 0 additions & 9 deletions Source/InstanceImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,6 @@ namespace nrd
void Add_Reference(DenoiserData& denoiserData);
void Update_Reference(const DenoiserData& denoiserData);

void Add_SpecularReflectionMv(DenoiserData& denoiserData);
void Update_SpecularReflectionMv(const DenoiserData& denoiserData);

void Add_SpecularDeltaMv(DenoiserData& denoiserData);
void Update_SpecularDeltaMv(const DenoiserData& denoiserData);

// Internal
public:
inline InstanceImpl(const StdAllocator<uint8_t>& stdAllocator) :
Expand All @@ -230,8 +224,6 @@ namespace nrd
, m_ActiveDispatches(GetStdAllocator())
, m_IndexRemap(GetStdAllocator())
{
Rng::Hash::Initialize(m_RngState, 106937, 69);

m_ConstantDataUnaligned = m_StdAllocator.allocate(CONSTANT_DATA_SIZE + sizeof(float4));

// IMPORTANT: underlying memory for constants must be aligned, as well as any individual SSE-type containing member,
Expand Down Expand Up @@ -316,7 +308,6 @@ namespace nrd
Vector<DispatchDesc> m_ActiveDispatches;
Vector<uint16_t> m_IndexRemap;
Timer m_Timer;
uint32_t m_RngState = {};
InstanceDesc m_Desc = {};
CommonSettings m_CommonSettings = {};
float4x4 m_ViewToClip = float4x4::Identity();
Expand Down
6 changes: 3 additions & 3 deletions Source/Reference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.
// REFERENCE
#ifdef NRD_EMBEDS_DXBC_SHADERS
#include "REFERENCE_TemporalAccumulation.cs.dxbc.h"
#include "REFERENCE_SplitScreen.cs.dxbc.h"
#include "REFERENCE_Copy.cs.dxbc.h"
#endif

#ifdef NRD_EMBEDS_DXIL_SHADERS
#include "REFERENCE_TemporalAccumulation.cs.dxil.h"
#include "REFERENCE_SplitScreen.cs.dxil.h"
#include "REFERENCE_Copy.cs.dxil.h"
#endif

#ifdef NRD_EMBEDS_SPIRV_SHADERS
#include "REFERENCE_TemporalAccumulation.cs.spirv.h"
#include "REFERENCE_SplitScreen.cs.spirv.h"
#include "REFERENCE_Copy.cs.spirv.h"
#endif

#include "Denoisers/Reference.hpp"

0 comments on commit 7e36d4b

Please sign in to comment.