MCPcopy Create free account
hub / github.com/NVIDIA-RTX/RTXNTC / BlockCompressAndSaveGraphicsTextures

Function BlockCompressAndSaveGraphicsTextures

tools/cli/GraphicsPasses.cpp:572–776  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

570}
571
572bool BlockCompressAndSaveGraphicsTextures(
573 ntc::IContext* context,
574 ntc::ITextureSetMetadata* metadata,
575 ntc::IStream* inputFile,
576 nvrhi::IDevice* device,
577 nvrhi::ICommandList* commandList,
578 nvrhi::ITimerQuery* timerQuery,
579 GDeflateFeatures* gdeflateFeatures,
580 char const* savePath,
581 int benchmarkIterations,
582 GraphicsResourcesForTextureSet const& graphicsResources)
583{
584 GraphicsBlockCompressionPass blockCompressionPass(device, 2);
585 if (!blockCompressionPass.Init())
586 return false;
587
588 GraphicsImageDifferencePass compareImagesPass(device);
589 if (!compareImagesPass.Init())
590 return false;
591
592 float const alphaThreshold = 1.f / 255.f;
593
594 ntc::TextureSetDesc const& textureSetDesc = metadata->GetDesc();
595
596 for (int index = 0; index < int(graphicsResources.perTexture.size()); ++index)
597 {
598 GraphicsResourcesForTexture const& textureResources = graphicsResources.perTexture[index];
599 ntc::ITextureMetadata* textureMetadata = metadata->GetTexture(index);
600 ntc::BlockCompressedFormat bcFormat = textureMetadata->GetBlockCompressedFormat();
601
602 if (bcFormat == ntc::BlockCompressedFormat::None)
603 continue;
604
605 bool const useAlphaThreshold = bcFormat == ntc::BlockCompressedFormat::BC1;
606 bool const useMSLE = bcFormat == ntc::BlockCompressedFormat::BC6;
607
608 nvrhi::BufferHandle modeBuffer;
609 std::vector<BufferLoadingTask> modeBufferTasks;
610
611 if (bcFormat == ntc::BlockCompressedFormat::BC7)
612 {
613 size_t stagingBufferSize = 0;
614 size_t tempBufferSize = 0;
615 size_t finalBufferSize = 0;
616
617 FillBufferLoadingTasksForBC(textureSetDesc, textureMetadata, modeBufferTasks,
618 gdeflateFeatures && gdeflateFeatures->gpuDecompressionSupported, device->getGraphicsAPI(),
619 stagingBufferSize, tempBufferSize, finalBufferSize);
620
621 if (!ExecuteBufferLoadingTasks(device, commandList, context, inputFile, gdeflateFeatures,
622 modeBufferTasks, modeBuffer, stagingBufferSize, tempBufferSize, finalBufferSize))
623 return false;
624 }
625
626 nvrhi::TextureDesc const& textureDesc = textureResources.color->getDesc();
627 BcFormatDefinition const* bcFormatDef = GetBcFormatDefinition(bcFormat);
628
629 std::string outputFileName = (fs::path(savePath) / fs::path(textureResources.name)).generic_string() + ".dds";

Callers 1

mainFunction · 0.85

Calls 9

GetBcFormatDefinitionFunction · 0.85
MedianFunction · 0.85
GetTextureMethod · 0.80
WriteDdsHeaderFunction · 0.70
InitMethod · 0.45
ExecuteComputePassMethod · 0.45

Tested by

no test coverage detected