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

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