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

Method initFramebuffer

Source/Falcor/Core/API/FBO.cpp:259–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259void Fbo::initFramebuffer() const
260{
261 mHandleDirty = false;
262
263 gfx::IFramebufferLayout::Desc layoutDesc = {};
264 std::vector<gfx::IFramebufferLayout::TargetLayout> targetLayouts;
265 gfx::IFramebufferLayout::TargetLayout depthTargetLayout = {};
266 gfx::IFramebuffer::Desc desc = {};
267 if (mDepthStencil.pTexture)
268 {
269 auto gfxTexture = mDepthStencil.pTexture->getGfxTextureResource();
270 depthTargetLayout.format = gfxTexture->getDesc()->format;
271 depthTargetLayout.sampleCount = gfxTexture->getDesc()->sampleDesc.numSamples;
272 layoutDesc.depthStencil = &depthTargetLayout;
273 }
274 desc.depthStencilView = getDepthStencilView()->getGfxResourceView();
275 desc.renderTargetCount = 0;
276 std::vector<gfx::IResourceView*> renderTargetViews;
277 for (uint32_t i = 0; i < static_cast<uint32_t>(mColorAttachments.size()); i++)
278 {
279 gfx::IFramebufferLayout::TargetLayout renderTargetLayout = {};
280
281 if (mColorAttachments[i].pTexture)
282 {
283 auto gfxTexture = mColorAttachments[i].pTexture->getGfxTextureResource();
284 renderTargetLayout.format = gfxTexture->getDesc()->format;
285 renderTargetLayout.sampleCount = gfxTexture->getDesc()->sampleDesc.numSamples;
286 targetLayouts.push_back(renderTargetLayout);
287 desc.renderTargetCount = i + 1;
288 }
289 else
290 {
291 renderTargetLayout.format = gfx::Format::R8G8B8A8_UNORM;
292 renderTargetLayout.sampleCount = 1;
293 targetLayouts.push_back(renderTargetLayout);
294 }
295 renderTargetViews.push_back(getRenderTargetView(i)->getGfxResourceView());
296 }
297 desc.renderTargetViews = renderTargetViews.data();
298 layoutDesc.renderTargetCount = desc.renderTargetCount;
299 layoutDesc.renderTargets = targetLayouts.data();
300
301 // Push FBO handle to deferred release queue so it remains valid
302 // for pending GPU commands.
303 mpDevice->releaseResource(mGfxFramebuffer);
304
305 Slang::ComPtr<gfx::IFramebufferLayout> fboLayout;
306 FALCOR_GFX_CALL(mpDevice->getGfxDevice()->createFramebufferLayout(layoutDesc, fboLayout.writeRef()));
307
308 desc.layout = fboLayout.get();
309 FALCOR_GFX_CALL(mpDevice->getGfxDevice()->createFramebuffer(desc, mGfxFramebuffer.writeRef()));
310}
311
312ref<RenderTargetView> Fbo::getRenderTargetView(uint32_t rtIndex) const
313{

Callers

nothing calls this directly

Calls 6

releaseResourceMethod · 0.80
writeRefMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45
dataMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected