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

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