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

Function ProcessCommandLine

tools/cli/NtcCommandLine.cpp:84–481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82 float maxBcPsnr = INFINITY;
83 float bcPsnrOffset = 0.f;
84 float bcPsnrThreshold = 0.2f;
85 std::optional<int> customWidth;
86 std::optional<int> customHeight;
87 ntc::CompressionSettings compressionSettings;
88 ntc::LosslessCompressionSettings losslessCompression;
89} g_options;
90
91bool ProcessCommandLine(int argc, const char** argv)
92{
93 const char* bcFormatString = nullptr;
94 const char* imageFormatString = nullptr;
95 const char* dimensionsString = nullptr;
96 const char* gdeflateString = nullptr;
97
98 struct argparse_option options[] = {
99 OPT_GROUP("Actions:"),
100 OPT_BOOLEAN('c', "compress", &g_options.compress, "Perform NTC compression"),
101 OPT_BOOLEAN('D', "decompress", &g_options.decompress, "Perform NTC decompression (implied when needed)"),
102 OPT_BOOLEAN('d', "describe", &g_options.describe, "Describe the contents of a compressed texture set"),
103 OPT_BOOLEAN('g', "generateMips", &g_options.generateMips, "Generate MIP level images before compression"),
104 OPT_STRING (0, "loadCompressed", &g_options.loadCompressedFileName, "Load compressed texture set from the specified file"),
105 OPT_STRING (0, "loadImages", &g_options.loadImagesPath, "Load channel images from the specified folder"),
106 OPT_STRING (0, "loadManifest", &g_options.loadManifestFileName, "Load channel images and their parameters using the specified JSON manifest file"),
107 OPT_BOOLEAN(0, "loadMips", &g_options.loadMips, "Load MIP level images from <loadImages>/mips/<texture>.<mip>.<ext> before compression"),
108 OPT_BOOLEAN(0, "optimizeBC", &g_options.optimizeBC, "Run slow BC compression and store acceleration info in the NTC package"),
109 OPT_BOOLEAN(0, "readManifestFromStdin", &g_options.readManifestFromStdin, "Load channel images using a JSON manifest passed through standard input (stdin)"),
110 OPT_STRING ('o', "saveCompressed", &g_options.saveCompressedFileName, "Save compressed texture set into the specified file"),
111 OPT_STRING ('i', "saveImages", &g_options.saveImagesPath, "Save channel images into the specified folder"),
112 OPT_STRING (0, "saveManifest", &g_options.saveManifestFileName, "Save a manifest JSON file (only for image inputs)"),
113 OPT_STRING (0, "writeManifestSemanticsJson", &g_options.writeManifestSemanticsJson,
114 "With --saveManifest, use this semantics.json for per-slot channel strings (R/RGB/...); if omitted, "
115 "semantics.json beside the manifest path is used when present"),
116 OPT_BOOLEAN(0, "saveMips", &g_options.saveMips, "Save MIP level images into <saveImages>/mips/ after decompression"),
117 OPT_BOOLEAN(0, "version", &g_options.printVersion, "Print version information and exit"),
118 OPT_HELP(),
119
120 OPT_GROUP("Basic compression options:"),
121 OPT_FLOAT ('b', "bitsPerPixel", &g_options.bitsPerPixel, "Request an optimal compression configuration for the provided BPP value"),
122 OPT_FLOAT (0, "maxBitsPerPixel", &g_options.maxBitsPerPixel, "Maximum BPP value to use in the compression parameter search"),
123 OPT_FLOAT ('p', "targetPsnr", &g_options.targetPsnr, "Perform compression parameter search to reach at least the provided PSNR value"),
124
125 OPT_GROUP("Custom latent shape selection:"),
126 OPT_INTEGER(0, "gridSizeScale", &g_options.gridSizeScale, "Ratio of source image size to high-resolution feature grid size"),
127 OPT_INTEGER(0, "numFeatures", &g_options.numFeatures, "Number of features"),
128
129 OPT_GROUP("Training process controls:"),
130 OPT_FLOAT (0, "gridLearningRate", &g_options.compressionSettings.gridLearningRate, "Maximum learning rate for the feature grid"),
131 OPT_INTEGER(0, "kPixelsPerBatch", &g_options.compressionSettings.kPixelsPerBatch, "Number of kilopixels from the image to process in one training step"),
132 OPT_FLOAT (0, "networkLearningRate", &g_options.compressionSettings.networkLearningRate, "Maximum learning rate for the MLP weights"),
133 OPT_INTEGER(0, "randomSeed", &g_options.compressionSettings.randomSeed, "Random seed, set to a nonzero value to get more stable compression results"),
134 OPT_BOOLEAN(0, "stableTraining", &g_options.compressionSettings.stableTraining, "Use a more expensive but more numerically stable training algorithm for reproducible results"),
135 OPT_INTEGER(0, "stepsPerIteration", &g_options.compressionSettings.stepsPerIteration, "Training steps between progress reports"),
136 OPT_INTEGER('S', "trainingSteps", &g_options.compressionSettings.trainingSteps, "Total training step count"),
137
138 OPT_GROUP("Output settings:"),
139 OPT_STRING ('B', "bcFormat", &bcFormatString, "Set or override the BCn encoding format, BC1-BC7"),
140 OPT_STRING ('F', "imageFormat", &imageFormatString, "Set the output file format for color images: Auto (default), BMP, JPG, TGA, PNG, PNG16, EXR"),
141 OPT_STRING (0, "dimensions", &dimensionsString, "Set the dimensions of the NTC texture set before compression, in the 'WxH' format"),

Callers 1

mainFunction · 0.70

Calls 8

argparse_initFunction · 0.85
argparse_describeFunction · 0.85
argparse_parseFunction · 0.85
UpdateToolInputTypeFunction · 0.85
LowercaseStringFunction · 0.85
ParseImageContainerFunction · 0.85

Tested by

no test coverage detected