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

Method execute

Source/RenderPasses/BSDFViewer/BSDFViewer.cpp:161–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161void BSDFViewer::execute(RenderContext* pRenderContext, const RenderData& renderData)
162{
163 // Update refresh flag if options that affect the output have changed.
164 if (mOptionsChanged)
165 {
166 auto& dict = renderData.getDictionary();
167 auto flags = dict.getValue(kRenderPassRefreshFlags, RenderPassRefreshFlags::None);
168 dict[Falcor::kRenderPassRefreshFlags] = flags | Falcor::RenderPassRefreshFlags::RenderOptionsChanged;
169 mOptionsChanged = false;
170 }
171
172 auto pOutput = renderData.getTexture(kOutput);
173 if (!mpScene || mpScene->getMaterialCount() == 0)
174 {
175 pRenderContext->clearUAV(pOutput->getUAV().get(), uint4(0));
176 return;
177 }
178
179 if (is_set(mpScene->getUpdates(), IScene::UpdateFlags::RecompileNeeded))
180 {
181 FALCOR_THROW("This render pass does not support scene changes that require shader recompilation.");
182 }
183
184 // Read back pixel data from the previous frame if available.
185 // This ensures parameters get updated even if the UI wasn't rendered.
186 readPixelData();
187
188 // Set compile-time constants.
189 if (mParams.useDisneyDiffuse)
190 mpViewerPass->addDefine("DiffuseBrdf", "DiffuseBrdfDisney");
191 else
192 mpViewerPass->removeDefine("DiffuseBrdf");
193 if (mParams.useSeparableMaskingShadowing)
194 mpViewerPass->addDefine("SpecularMaskingFunction", "SpecularMaskingFunctionSmithGGXSeparable");
195 else
196 mpViewerPass->removeDefine("SpecularMaskingFunction");
197
198 // Setup constants.
199 mParams.cameraViewportScale = std::tan(math::radians(mParams.cameraFovY / 2.f)) * mParams.cameraDistance;
200 mParams.useEnvMap = mUseEnvMap && mpEnvMap != nullptr;
201
202 // Set resources.
203 auto var = mpViewerPass->getRootVar()[kParameterBlockName];
204
205 if (!mpPixelDataBuffer)
206 {
207 mpPixelDataBuffer = mpDevice->createStructuredBuffer(
208 var["pixelData"], 1, ResourceBindFlags::UnorderedAccess, MemoryType::DeviceLocal, nullptr, false
209 );
210 mpPixelStagingBuffer =
211 mpDevice->createStructuredBuffer(var["pixelData"], 1, ResourceBindFlags::None, MemoryType::ReadBack, nullptr, false);
212 }
213
214 var["params"].setBlob(mParams);
215 var["outputColor"] = pOutput;
216 var["pixelData"] = mpPixelDataBuffer;
217
218 if (mParams.useEnvMap)

Callers

nothing calls this directly

Calls 15

clearUAVMethod · 0.80
getRootVarMethod · 0.80
getProgramMethod · 0.80
copyResourceMethod · 0.80
tanFunction · 0.50
radiansFunction · 0.50
getValueMethod · 0.45
getTextureMethod · 0.45
getMethod · 0.45
getUAVMethod · 0.45
addDefineMethod · 0.45

Tested by

no test coverage detected