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

Function ComputePsnrForBlockCompressedTextureSet

tools/cli/GraphicsPasses.cpp:967–1083  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

965}
966
967bool ComputePsnrForBlockCompressedTextureSet(
968 ntc::IContext* context,
969 ntc::ITextureSetMetadata* textureSetMetadata,
970 nvrhi::IDevice* device,
971 nvrhi::ICommandList* commandList,
972 GraphicsResourcesForTextureSet const& graphicsResources,
973 float& outTargetPsnr)
974{
975 assert(device);
976
977 GraphicsBlockCompressionPass blockCompressionPass(device, 1);
978 if (!blockCompressionPass.Init())
979 return false;
980
981 GraphicsImageDifferencePass compareImagesPass(device);
982 if (!compareImagesPass.Init())
983 return false;
984
985 std::vector<float> perChannelMSE;
986
987 float const alphaThreshold = 1.f / 255.f;
988 float combinedBcBitsPerPixel = 0;
989
990 for (int textureIndex = 0; textureIndex < textureSetMetadata->GetTextureCount(); ++textureIndex)
991 {
992 ntc::ITextureMetadata* textureMetadata = textureSetMetadata->GetTexture(textureIndex);
993 ntc::BlockCompressedFormat const bcFormat = textureMetadata->GetBlockCompressedFormat();
994 int const numChannels = textureMetadata->GetNumChannels();
995 if (textureMetadata->GetBlockCompressedFormat() == ntc::BlockCompressedFormat::None)
996 continue;
997
998 int const bytesPerBlock = GetBcFormatDefinition(textureMetadata->GetBlockCompressedFormat())->bytesPerBlock;
999 combinedBcBitsPerPixel += float(bytesPerBlock) * 0.5f; // (* 8 bits / 16 pixels)
1000
1001 GraphicsResourcesForTexture const& textureResources = graphicsResources.perTexture[textureIndex];
1002
1003 nvrhi::TextureDesc const& textureDesc = textureResources.color->getDesc();
1004 int const width = int(textureDesc.width);
1005 int const height = int(textureDesc.height);
1006
1007 // Make the compression pass
1008 ntc::MakeBlockCompressionComputePassParameters compressParams;
1009 compressParams.srcRect.width = width;
1010 compressParams.srcRect.height = height;
1011 compressParams.dstFormat = bcFormat;
1012 compressParams.alphaThreshold = alphaThreshold;
1013 ntc::ComputePassDesc blockCompressionComputePass;
1014 ntc::Status ntcStatus = context->MakeBlockCompressionComputePass(compressParams, &blockCompressionComputePass);
1015 CHECK_NTC_RESULT("MakeBlockCompressionComputePass");
1016
1017 // Make the image comparison pass
1018 ntc::MakeImageDifferenceComputePassParameters differenceParams;
1019 differenceParams.extent.width = width;
1020 differenceParams.extent.height = height;
1021 differenceParams.useAlphaThreshold = (bcFormat == ntc::BlockCompressedFormat::BC1) && (numChannels == 4);
1022 differenceParams.alphaThreshold = alphaThreshold;
1023 ntc::ComputePassDesc imageDifferenceComputePass;
1024 ntcStatus = context->MakeImageDifferenceComputePass(differenceParams, &imageDifferenceComputePass);

Callers 1

mainFunction · 0.85

Calls 7

GetBcFormatDefinitionFunction · 0.85
CopyBlocksIntoBCTextureFunction · 0.85
GetTextureMethod · 0.80
ReadResultsMethod · 0.80
GetQueryResultMethod · 0.80
InitMethod · 0.45
ExecuteComputePassMethod · 0.45

Tested by

no test coverage detected