| 73 | } g_options; |
| 74 | |
| 75 | bool ProcessCommandLine(int argc, const char** argv) |
| 76 | { |
| 77 | struct argparse_option options[] = { |
| 78 | OPT_HELP(), |
| 79 | #if NTC_WITH_VULKAN |
| 80 | OPT_BOOLEAN(0, "vk", &g_options.useVulkan, "Use Vulkan API"), |
| 81 | #endif |
| 82 | #if NTC_WITH_DX12 |
| 83 | OPT_BOOLEAN(0, "dx12", &g_options.useDX12, "Use DX12 API"), |
| 84 | #endif |
| 85 | OPT_BOOLEAN(0, "debug", &g_options.debug, "Enable graphics debug runtime"), |
| 86 | OPT_BOOLEAN(0, "referenceMaterials", &g_options.referenceMaterials, "Load materials from regular image files instead of NTC"), |
| 87 | OPT_BOOLEAN(0, "blockCompression", &g_options.blockCompression, "Enable transcoding to BCn (default on, use --no-blockCompression)"), |
| 88 | OPT_BOOLEAN(0, "inferenceOnLoad", &g_options.inferenceOnLoad, "Enable inference on load (default on, use --no-inferenceOnLoad)"), |
| 89 | OPT_BOOLEAN(0, "inferenceOnSample", &g_options.inferenceOnSample, "Enable inference on sample (default on, use --no-inferenceOnSample)"), |
| 90 | OPT_BOOLEAN(0, "inferenceOnFeedback", &g_options.inferenceOnFeedback, "Enable inference on feedback (default on, use --no-inferenceOnFeedback)"), |
| 91 | OPT_BOOLEAN(0, "coopVec", &g_options.enableCoopVec, "Enable CoopVec extensions (default on, use --no-coopVec)"), |
| 92 | OPT_BOOLEAN(0, "gpuGDeflate", &g_options.enableGpuDeflate, "Enable GPU-based GDeflate decompression"), |
| 93 | OPT_BOOLEAN(0, "dlss", &g_options.enableDLSS, "Enable DLSS (default on, use --no-dlss)"), |
| 94 | OPT_INTEGER(0, "adapter", &g_options.adapterIndex, "Index of the graphics adapter to use (use ntc-cli.exe --dx12|vk --listAdapters to find out)"), |
| 95 | OPT_STRING(0, "materialDir", &g_options.materialDir, "Subdirectory near the scene file where NTC materials are located"), |
| 96 | OPT_END() |
| 97 | }; |
| 98 | |
| 99 | static const char* usages[] = { |
| 100 | "ntc-renderer.exe [options...] <path/to/scene.gltf>", |
| 101 | nullptr |
| 102 | }; |
| 103 | |
| 104 | // Copy argv[] pointers into a temporary array, because argparse overwrites those, |
| 105 | // and later DLSS cannot find the path to the executable, at least on Linux. |
| 106 | const char** argvCopy = (const char**)alloca(sizeof(void*) * argc); |
| 107 | for (int i = 0; i < argc; ++i) |
| 108 | argvCopy[i] = argv[i]; |
| 109 | |
| 110 | struct argparse argparse {}; |
| 111 | argparse_init(&argparse, options, usages, ARGPARSE_USE_MESSAGE_BUFFER | ARGPARSE_NEVER_EXIT); |
| 112 | argparse_describe(&argparse, nullptr, "\nScene renderer using NTC materials."); |
| 113 | int argparse_result = argparse_parse(&argparse, argc, argvCopy); |
| 114 | if (argparse_result < 0) |
| 115 | { |
| 116 | if (argparse.messages) |
| 117 | { |
| 118 | bool isError = argparse_result != ARGPARSE_HELP; |
| 119 | #ifdef _WIN32 |
| 120 | MessageBoxA(NULL, argparse.messages, g_ApplicationName, MB_OK | (isError ? MB_ICONERROR : 0)); |
| 121 | #else |
| 122 | fprintf(isError ? stderr : stdout, "%s\n", argparse.messages); |
| 123 | #endif |
| 124 | } |
| 125 | argparse_cleanup(&argparse); |
| 126 | return false; |
| 127 | } |
| 128 | |
| 129 | if (argparse.out[0]) |
| 130 | g_options.scenePath = argparse.out[0]; |
| 131 | |
| 132 | argparse_cleanup(&argparse); |
no test coverage detected