Skip to content

Commit

Permalink
NRD: "frameIndex" validation moved from NRD to Integration (since the…
Browse files Browse the repository at this point in the history
…re is no "frame" idiom in NRD)
  • Loading branch information
dzhdanNV committed Nov 14, 2024
1 parent e768155 commit 344c885
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Include/NRDSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ namespace nrd
uint32_t rectOrigin[2] = {};

// A consecutively growing number. Valid usage:
// - must be incremented by 1 each frame
// - must be incremented by 1 on each frame (not by 1 on each "SetCommonSettings" call)
// - sequence can be restarted after passing "AccumulationMode != CONTINUE"
// - must be in sync with "CheckerboardMode" (if not OFF)
uint32_t frameIndex = 0;
Expand Down
1 change: 1 addition & 0 deletions Integration/NRDIntegration.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class Integration
uint32_t m_ConstantBufferOffset = 0;
uint32_t m_DescriptorPoolIndex = 0;
uint32_t m_FrameIndex = uint32_t(-1); // 0 needed after 1st "NewFrame"
uint32_t m_PrevFrameIndexFromSettings = 0;
uint8_t m_BufferedFramesNum = 0;
char m_Name[32] = {};
bool m_ReloadShaders = false;
Expand Down
6 changes: 6 additions & 0 deletions Integration/NRDIntegration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ void Integration::NewFrame()
}

m_FrameIndex++;
m_PrevFrameIndexFromSettings++;
}

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

if (m_FrameIndex == 0 || commonSettings.accumulationMode != AccumulationMode::CONTINUE)
m_PrevFrameIndexFromSettings = commonSettings.frameIndex;
else
NRD_INTEGRATION_ASSERT(m_PrevFrameIndexFromSettings == commonSettings.frameIndex, "'frameIndex' must be incremented by 1 on each frame");

return result == Result::SUCCESS;
}

Expand Down
3 changes: 0 additions & 3 deletions Source/InstanceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,6 @@ nrd::Result nrd::InstanceImpl::SetCommonSettings(const CommonSettings& commonSet
isValid &= commonSettings.disocclusionThresholdAlternate > 0.0f;
assert("'disocclusionThresholdAlternate' must be > 0" && isValid);

isValid &= commonSettings.accumulationMode != AccumulationMode::CONTINUE || commonSettings.frameIndex == m_CommonSettings.frameIndex + 1 || m_IsFirstUse;
assert("'frameIndex' must be a consecutively growing number" && isValid);

isValid &= commonSettings.strandMaterialID != 0.0f || GetLibraryDesc().normalEncoding == NormalEncoding::R10_G10_B10_A2_UNORM;
assert("'strandMaterialID' can't be 0 if material ID is not supported by encoding" && isValid);

Expand Down

0 comments on commit 344c885

Please sign in to comment.