From 7e36d4b6ecdc4d57068b9754459e99ddf3fae1e5 Mon Sep 17 00:00:00 2001 From: dzhdan Date: Wed, 14 Aug 2024 13:03:16 +0800 Subject: [PATCH] v4.9.1: 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 --- External/MathLib | 2 +- Include/NRD.h | 4 ++-- Integration/NRDIntegration.hpp | 4 ++-- README.md | 2 +- Resources/Version.h | 2 +- Shaders.cfg | 2 +- ...s.hlsli => REFERENCE_Copy.resources.hlsli} | 12 +++++++----- ...RENCE_TemporalAccumulation.resources.hlsli | 2 -- ...tScreen.cs.hlsl => REFERENCE_Copy.cs.hlsl} | 7 +++++-- .../REFERENCE_TemporalAccumulation.cs.hlsl | 5 +---- Source/Denoisers/Reference.hpp | 14 ++++++++------ Source/InstanceImpl.cpp | 19 ++++++------------- Source/InstanceImpl.h | 9 --------- Source/Reference.cpp | 6 +++--- 14 files changed, 38 insertions(+), 52 deletions(-) rename Shaders/Resources/{REFERENCE_SplitScreen.resources.hlsli => REFERENCE_Copy.resources.hlsli} (75%) rename Shaders/Source/{REFERENCE_SplitScreen.cs.hlsl => REFERENCE_Copy.cs.hlsl} (75%) diff --git a/External/MathLib b/External/MathLib index 9114b1e5..f4c7b439 160000 --- a/External/MathLib +++ b/External/MathLib @@ -1 +1 @@ -Subproject commit 9114b1e564d1ccd447e38727451b8e42acebbafa +Subproject commit f4c7b4399168bece42a27a01dba1201d4a0cdd6b diff --git a/Include/NRD.h b/Include/NRD.h index aa111905..6ceb99ce 100644 --- a/Include/NRD.h +++ b/Include/NRD.h @@ -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 diff --git a/Integration/NRDIntegration.hpp b/Integration/NRDIntegration.hpp index 15bf40a9..19325f1d 100644 --- a/Integration/NRDIntegration.hpp +++ b/Integration/NRDIntegration.hpp @@ -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 @@ -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; diff --git a/README.md b/README.md index 0d008200..314cd488 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/Resources/Version.h b/Resources/Version.h index 080a96b0..f0310860 100644 --- a/Resources/Version.h +++ b/Resources/Version.h @@ -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) diff --git a/Shaders.cfg b/Shaders.cfg index 4aa73fb6..950ae21a 100644 --- a/Shaders.cfg +++ b/Shaders.cfg @@ -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 diff --git a/Shaders/Resources/REFERENCE_SplitScreen.resources.hlsli b/Shaders/Resources/REFERENCE_Copy.resources.hlsli similarity index 75% rename from Shaders/Resources/REFERENCE_SplitScreen.resources.hlsli rename to Shaders/Resources/REFERENCE_Copy.resources.hlsli index 02d3beb1..fd96c14d 100644 --- a/Shaders/Resources/REFERENCE_SplitScreen.resources.hlsli +++ b/Shaders/Resources/REFERENCE_Copy.resources.hlsli @@ -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 @@ -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 diff --git a/Shaders/Resources/REFERENCE_TemporalAccumulation.resources.hlsli b/Shaders/Resources/REFERENCE_TemporalAccumulation.resources.hlsli index db9a3975..4d005258 100644 --- a/Shaders/Resources/REFERENCE_TemporalAccumulation.resources.hlsli +++ b/Shaders/Resources/REFERENCE_TemporalAccumulation.resources.hlsli @@ -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 diff --git a/Shaders/Source/REFERENCE_SplitScreen.cs.hlsl b/Shaders/Source/REFERENCE_Copy.cs.hlsl similarity index 75% rename from Shaders/Source/REFERENCE_SplitScreen.cs.hlsl rename to Shaders/Source/REFERENCE_Copy.cs.hlsl index 24738263..1b689033 100644 --- a/Shaders/Source/REFERENCE_SplitScreen.cs.hlsl +++ b/Shaders/Source/REFERENCE_Copy.cs.hlsl @@ -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 ]; } diff --git a/Shaders/Source/REFERENCE_TemporalAccumulation.cs.hlsl b/Shaders/Source/REFERENCE_TemporalAccumulation.cs.hlsl index e8829dc7..8e1e72dc 100644 --- a/Shaders/Source/REFERENCE_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REFERENCE_TemporalAccumulation.cs.hlsl @@ -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; } - diff --git a/Source/Denoisers/Reference.hpp b/Source/Denoisers/Reference.hpp index bb0a5659..9155800b 100644 --- a/Source/Denoisers/Reference.hpp +++ b/Source/Denoisers/Reference.hpp @@ -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) { @@ -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 @@ -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); @@ -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; } } diff --git a/Source/InstanceImpl.cpp b/Source/InstanceImpl.cpp index 27e08688..d4303602 100644 --- a/Source/InstanceImpl.cpp +++ b/Source/InstanceImpl.cpp @@ -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 diff --git a/Source/InstanceImpl.h b/Source/InstanceImpl.h index 251fb0a6..446698a2 100644 --- a/Source/InstanceImpl.h +++ b/Source/InstanceImpl.h @@ -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& stdAllocator) : @@ -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, @@ -316,7 +308,6 @@ namespace nrd Vector m_ActiveDispatches; Vector m_IndexRemap; Timer m_Timer; - uint32_t m_RngState = {}; InstanceDesc m_Desc = {}; CommonSettings m_CommonSettings = {}; float4x4 m_ViewToClip = float4x4::Identity(); diff --git a/Source/Reference.cpp b/Source/Reference.cpp index 5ae37825..cec740c7 100644 --- a/Source/Reference.cpp +++ b/Source/Reference.cpp @@ -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"