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

Method initIntegrator

Source/Falcor/Scene/Lights/LightCollection.cpp:117–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115 }
116
117 void LightCollection::initIntegrator(RenderContext* pRenderContext, const Scene& scene)
118 {
119 // The current algorithm rasterizes emissive triangles in texture space,
120 // and uses atomic operations to sum up the contribution from all covered texels.
121 // We do this in a raster pass, so we get one thread per texel/triangle.
122
123 // Check for required features.
124 if (!mpDevice->isFeatureSupported(Device::SupportedFeatures::ConservativeRasterizationTier3))
125 {
126 FALCOR_THROW("LightCollection requires conservative rasterization tier 3 support.");
127 }
128 if (!mpDevice->isShaderModelSupported(ShaderModel::SM6_6))
129 {
130 FALCOR_THROW("LightCollection requires Shader Model 6.6 support.");
131 }
132
133 // Create program.
134 auto defines = scene.getSceneDefines();
135 defines.add("INTEGRATOR_PASS", "1");
136
137 ProgramDesc desc;
138 desc.addShaderLibrary(kEmissiveIntegratorFile).vsEntry("vsMain").gsEntry("gsMain").psEntry("psMain");
139 mIntegrator.pProgram = Program::create(mpDevice, desc, defines);
140
141 // Create graphics state.
142 mIntegrator.pState = GraphicsState::create(mpDevice);
143
144 // Set state.
145 mIntegrator.pState->setProgram(mIntegrator.pProgram);
146 mIntegrator.pState->setVao(Vao::create(Vao::Topology::PointList));
147
148 // Set viewport. Note we don't bind any render targets so the size just determines the dispatch limits.
149 const uint32_t vpDim = 16384; // 16K x 16K
150 mIntegrator.pState->setViewport(0, GraphicsState::Viewport(0.f, 0.f, (float)vpDim, (float)vpDim, 0.f, 1.f));
151 mIntegrator.pProgram->addDefine("_VIEWPORT_DIM", std::to_string(vpDim)); // Pass size to shader
152
153 // Set raster state to disable culling. We don't care about winding in texture space when integrating.
154 RasterizerState::Desc rsDesc;
155 rsDesc.setCullMode(RasterizerState::CullMode::None);
156 rsDesc.setFillMode(RasterizerState::FillMode::Solid);
157 rsDesc.setConservativeRasterization(true);
158 mIntegrator.pState->setRasterizerState(RasterizerState::create(rsDesc));
159
160 // Set depth-stencil state to disable depth test/writes.
161 DepthStencilState::Desc dsDesc;
162 dsDesc.setDepthEnabled(false);
163 dsDesc.setDepthWriteMask(false);
164 mIntegrator.pState->setDepthStencilState(DepthStencilState::create(dsDesc));
165
166 // Create sampler for texel fetch. This is identical to material sampler but uses point sampling.
167 Sampler::Desc samplerDesc = mpSamplerState ? mpSamplerState->getDesc() : Sampler::Desc();
168 samplerDesc.setFilterMode(TextureFilteringMode::Point, TextureFilteringMode::Point, TextureFilteringMode::Point);
169 mIntegrator.pPointSampler = mpDevice->createSampler(samplerDesc);
170 }
171
172 void LightCollection::setupMeshLights(const Scene& scene)
173 {

Callers

nothing calls this directly

Calls 12

ViewportClass · 0.85
isFeatureSupportedMethod · 0.80
getSceneDefinesMethod · 0.80
setViewportMethod · 0.80
setCullModeMethod · 0.80
createSamplerMethod · 0.80
createFunction · 0.50
to_stringFunction · 0.50
DescClass · 0.50
addMethod · 0.45
addDefineMethod · 0.45

Tested by

no test coverage detected