MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / init

Method init

Source/Falcor/Core/Program/ProgramVars.cpp:75–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75void RtProgramVars::init(const ref<RtBindingTable>& pBindingTable)
76{
77 mRayTypeCount = pBindingTable->getRayTypeCount();
78 mGeometryCount = pBindingTable->getGeometryCount();
79
80 // We must create sub-shader-objects for all the entry point
81 // groups that are used by the supplied binding table.
82 //
83 FALCOR_ASSERT(mpProgramVersion);
84 auto pProgram = dynamic_cast<Program*>(mpProgramVersion->getProgram());
85 FALCOR_ASSERT(pProgram);
86 auto pReflector = mpProgramVersion->getReflector();
87
88 std::set<int32_t> entryPointGroupIndices;
89
90 // Ray generation and miss programs are easy: we just allocate space
91 // for one parameter block per entry-point of the given type in the binding table.
92 //
93 const auto& rayGenInfo = pBindingTable->getRayGen();
94 FALCOR_ASSERT(rayGenInfo.isValid());
95 mRayGenVars.resize(1);
96 mRayGenVars[0].entryPointGroupIndex = rayGenInfo.groupIndex;
97 entryPointGroupIndices.insert(rayGenInfo.groupIndex);
98
99 uint32_t missCount = pBindingTable->getMissCount();
100 mMissVars.resize(missCount);
101
102 for (uint32_t i = 0; i < missCount; ++i)
103 {
104 const auto& missInfo = pBindingTable->getMiss(i);
105 if (!missInfo.isValid())
106 {
107 logWarning("Raytracing binding table has no shader at miss index {}. Is that intentional?", i);
108 continue;
109 }
110
111 mMissVars[i].entryPointGroupIndex = missInfo.groupIndex;
112
113 entryPointGroupIndices.insert(missInfo.groupIndex);
114 }
115
116 // Hit groups are more complicated than ray generation and miss shaders.
117 // We typically want a distinct parameter block per declared hit group
118 // and per geometry in the scene.
119 //
120 // We need to take this extra complexity into account when allocating
121 // space for the hit group parameter blocks.
122 //
123 uint32_t hitCount = mRayTypeCount * mGeometryCount;
124 mHitVars.resize(hitCount);
125
126 for (uint32_t rayType = 0; rayType < mRayTypeCount; rayType++)
127 {
128 for (uint32_t geometryID = 0; geometryID < mGeometryCount; geometryID++)
129 {
130 const auto& hitGroupInfo = pBindingTable->getHitGroup(rayType, geometryID);
131 if (!hitGroupInfo.isValid())
132 continue;

Callers 1

createProgramVersionMethod · 0.45

Calls 11

getGeometryCountMethod · 0.80
getProgramMethod · 0.80
assignMethod · 0.80
logWarningFunction · 0.50
isValidMethod · 0.45
resizeMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected