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

Method generateMips

Source/Falcor/Core/API/Texture.cpp:670–717  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

668}
669
670void Texture::generateMips(RenderContext* pContext, bool minMaxMips)
671{
672 if (mType != Type::Texture2D)
673 {
674 logWarning("Texture::generateMips() was only tested with Texture2Ds");
675 }
676
677 // #OPTME: should blit support arrays?
678 for (uint32_t m = 0; m < mMipLevels - 1; m++)
679 {
680 for (uint32_t a = 0; a < mArraySize; a++)
681 {
682 auto srv = getSRV(m, 1, a, 1);
683 auto rtv = getRTV(m + 1, a, 1);
684 if (!minMaxMips)
685 {
686 pContext->blit(srv, rtv, RenderContext::kMaxRect, RenderContext::kMaxRect, TextureFilteringMode::Linear);
687 }
688 else
689 {
690 const TextureReductionMode redModes[] = {
691 TextureReductionMode::Standard,
692 TextureReductionMode::Min,
693 TextureReductionMode::Max,
694 TextureReductionMode::Standard,
695 };
696 const float4 componentsTransform[] = {
697 float4(1.0f, 0.0f, 0.0f, 0.0f),
698 float4(0.0f, 1.0f, 0.0f, 0.0f),
699 float4(0.0f, 0.0f, 1.0f, 0.0f),
700 float4(0.0f, 0.0f, 0.0f, 1.0f),
701 };
702 pContext->blit(
703 srv, rtv, RenderContext::kMaxRect, RenderContext::kMaxRect, TextureFilteringMode::Linear, redModes, componentsTransform
704 );
705 }
706 }
707 }
708
709 if (mReleaseRtvsAfterGenMips)
710 {
711 // Releasing RTVs to free space on the heap.
712 // We only do it once to handle the case that generateMips() was called during load.
713 // If it was called more then once, the texture is probably dynamic and it's better to keep the RTVs around
714 mRtvs.clear();
715 mReleaseRtvsAfterGenMips = false;
716 }
717}
718
719uint64_t Texture::getTexelCount() const
720{

Callers 9

executeMethod · 0.80
packBaseColorAlphaMethod · 0.80
createSpecularTextureMethod · 0.80
createImportanceMapMethod · 0.80
updateLightsMethod · 0.80
updateEnvLightMethod · 0.80
GPU_TESTFunction · 0.80

Calls 3

blitMethod · 0.80
logWarningFunction · 0.50
clearMethod · 0.45

Tested by 1

GPU_TESTFunction · 0.64