MCPcopy Create free account
hub / github.com/NVIDIA-RTX/NVRHI / createFramebuffer

Method createFramebuffer

src/validation/validation-device.cpp:667–818  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

665 }
666
667 FramebufferHandle DeviceWrapper::createFramebuffer(const FramebufferDesc& desc)
668 {
669 uint32_t width = 0;
670 uint32_t height = 0;
671 uint32_t arraySize = 0;
672 uint32_t sampleCount = 0;
673
674 if (desc.depthAttachment.texture)
675 {
676 TextureDesc const& d = desc.depthAttachment.texture->getDesc();
677
678 TextureSubresourceSet const subresources = desc.depthAttachment.subresources.resolve(d, true);
679
680 uint32_t const mipWidth = std::max(d.width >> subresources.baseMipLevel, 1u);
681 uint32_t const mipHeight = std::max(d.height >> subresources.baseMipLevel, 1u);
682
683 width = mipWidth;
684 height = mipHeight;
685 arraySize = subresources.numArraySlices;
686 sampleCount = d.sampleCount;
687
688 if (!d.isRenderTarget)
689 {
690 std::stringstream ss;
691 ss << "Depth attachment texture " << utils::DebugNameToString(d.debugName)
692 << " must be created with isRenderTarget = true";
693 error(ss.str());
694 return nullptr;
695 }
696
697 FormatInfo const& formatInfo = getFormatInfo(d.format);
698 if (formatInfo.kind != FormatKind::DepthStencil)
699 {
700 std::stringstream ss;
701 ss << "Depth attachment texture " << utils::DebugNameToString(d.debugName) << " has a format "
702 << formatInfo.name << " that does not support depth or stencil";
703 error(ss.str());
704 return nullptr;
705 }
706 }
707
708 for (size_t i = 0; i < desc.colorAttachments.size(); ++i)
709 {
710 FramebufferAttachment const& att = desc.colorAttachments[i];
711 if (!att.texture)
712 {
713 std::stringstream ss;
714 ss << "Color attachment " << i << " is NULL";
715 error(ss.str());
716 return nullptr;
717 }
718
719 TextureDesc const& d = att.texture->getDesc();
720 if (!d.isRenderTarget)
721 {
722 std::stringstream ss;
723 ss << "Color attachment " << i << " texture " << utils::DebugNameToString(d.debugName)
724 << " must be created with isRenderTarget = true";

Callers

nothing calls this directly

Calls 4

DebugNameToStringFunction · 0.85
resolveMethod · 0.80
sizeMethod · 0.80
getDescMethod · 0.45

Tested by

no test coverage detected