Skip to content

Commit 344c885

Browse files
committed
NRD: "frameIndex" validation moved from NRD to Integration (since there is no "frame" idiom in NRD)
1 parent e768155 commit 344c885

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

Include/NRDSettings.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ namespace nrd
167167
uint32_t rectOrigin[2] = {};
168168

169169
// A consecutively growing number. Valid usage:
170-
// - must be incremented by 1 each frame
170+
// - must be incremented by 1 on each frame (not by 1 on each "SetCommonSettings" call)
171171
// - sequence can be restarted after passing "AccumulationMode != CONTINUE"
172172
// - must be in sync with "CheckerboardMode" (if not OFF)
173173
uint32_t frameIndex = 0;

Integration/NRDIntegration.h

+1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ class Integration
148148
uint32_t m_ConstantBufferOffset = 0;
149149
uint32_t m_DescriptorPoolIndex = 0;
150150
uint32_t m_FrameIndex = uint32_t(-1); // 0 needed after 1st "NewFrame"
151+
uint32_t m_PrevFrameIndexFromSettings = 0;
151152
uint8_t m_BufferedFramesNum = 0;
152153
char m_Name[32] = {};
153154
bool m_ReloadShaders = false;

Integration/NRDIntegration.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ void Integration::NewFrame()
478478
}
479479

480480
m_FrameIndex++;
481+
m_PrevFrameIndexFromSettings++;
481482
}
482483

483484
bool Integration::SetCommonSettings(const CommonSettings& commonSettings)
@@ -487,6 +488,11 @@ bool Integration::SetCommonSettings(const CommonSettings& commonSettings)
487488
Result result = nrd::SetCommonSettings(*m_Instance, commonSettings);
488489
NRD_INTEGRATION_ASSERT(result == Result::SUCCESS, "SetCommonSettings(): failed!");
489490

491+
if (m_FrameIndex == 0 || commonSettings.accumulationMode != AccumulationMode::CONTINUE)
492+
m_PrevFrameIndexFromSettings = commonSettings.frameIndex;
493+
else
494+
NRD_INTEGRATION_ASSERT(m_PrevFrameIndexFromSettings == commonSettings.frameIndex, "'frameIndex' must be incremented by 1 on each frame");
495+
490496
return result == Result::SUCCESS;
491497
}
492498

Source/InstanceImpl.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,6 @@ nrd::Result nrd::InstanceImpl::SetCommonSettings(const CommonSettings& commonSet
302302
isValid &= commonSettings.disocclusionThresholdAlternate > 0.0f;
303303
assert("'disocclusionThresholdAlternate' must be > 0" && isValid);
304304

305-
isValid &= commonSettings.accumulationMode != AccumulationMode::CONTINUE || commonSettings.frameIndex == m_CommonSettings.frameIndex + 1 || m_IsFirstUse;
306-
assert("'frameIndex' must be a consecutively growing number" && isValid);
307-
308305
isValid &= commonSettings.strandMaterialID != 0.0f || GetLibraryDesc().normalEncoding == NormalEncoding::R10_G10_B10_A2_UNORM;
309306
assert("'strandMaterialID' can't be 0 if material ID is not supported by encoding" && isValid);
310307

0 commit comments

Comments
 (0)