| 67 | } g_options; |
| 68 | |
| 69 | bool ProcessCommandLine(int argc, const char** argv) |
| 70 | { |
| 71 | struct argparse_option options[] = { |
| 72 | OPT_HELP(), |
| 73 | OPT_BOOLEAN(0, "debug", &g_options.debug, "Enable graphics debug runtime"), |
| 74 | OPT_BOOLEAN(0, "noshared", &g_options.noshared, "Disable the use of shared textures (CUDA/Graphics interop)"), |
| 75 | OPT_INTEGER(0, "adapter", &g_options.adapterIndex, "Index of the graphics adapter to use (use ntc-cli.exe --dx12|vk --listAdapters to find out)"), |
| 76 | OPT_INTEGER(0, "cudaDevice", &g_options.cudaDevice, "Index of the CUDA device to use (use ntc-cli.exe --listCudaDevices to find out)"), |
| 77 | OPT_BOOLEAN(0, "coopVec", &g_options.enableCoopVec, "Enable CoopVec extensions (default on, use --no-coopVec)"), |
| 78 | OPT_BOOLEAN(0, "captureMode", &g_options.captureMode, "Trace capture mode - run Graphics decompression in a loop"), |
| 79 | OPT_BOOLEAN(0, "compare", &g_options.compare, "Use Explorer to compare two images specified on the command line"), |
| 80 | OPT_BOOLEAN(0, "hdr", &g_options.hdr, "Use an HDR (FP16) swap chain"), |
| 81 | #if NTC_WITH_VULKAN |
| 82 | OPT_BOOLEAN(0, "vk", &g_options.useVulkan, "Use Vulkan API"), |
| 83 | #endif |
| 84 | #if NTC_WITH_DX12 |
| 85 | OPT_BOOLEAN(0, "dx12", &g_options.useDX12, "Use DX12 API"), |
| 86 | #endif |
| 87 | OPT_END() |
| 88 | }; |
| 89 | |
| 90 | static const char* usages[] = { |
| 91 | "ntc-explorer.exe [options...] [<source-folder|source-manifest.json|compressed-file.ntc>]", |
| 92 | nullptr |
| 93 | }; |
| 94 | |
| 95 | struct argparse argparse {}; |
| 96 | argparse_init(&argparse, options, usages, ARGPARSE_USE_MESSAGE_BUFFER | ARGPARSE_NEVER_EXIT); |
| 97 | argparse_describe(&argparse, nullptr, "\nNeural texture compression and decompression tool.\n"); |
| 98 | int argparse_result = argparse_parse(&argparse, argc, argv); |
| 99 | if (argparse_result < 0) |
| 100 | { |
| 101 | if (argparse.messages) |
| 102 | { |
| 103 | bool isError = argparse_result != ARGPARSE_HELP; |
| 104 | #ifdef _WIN32 |
| 105 | MessageBoxA(NULL, argparse.messages, g_ApplicationName, MB_OK | (isError ? MB_ICONERROR : 0)); |
| 106 | #else |
| 107 | log::error("%s\n", argparse.messages); |
| 108 | #endif |
| 109 | } |
| 110 | argparse_cleanup(&argparse); |
| 111 | return false; |
| 112 | } |
| 113 | |
| 114 | // Process positional arguments and detect their input types |
| 115 | for (int i = 0; argparse.out[i]; ++i) |
| 116 | { |
| 117 | char const* arg = argparse.out[i]; |
| 118 | if (!arg[0]) |
| 119 | continue; |
| 120 | |
| 121 | fs::path argPath = arg; |
| 122 | if (fs::is_directory(argPath)) |
| 123 | { |
| 124 | UpdateToolInputType(g_options.inputType, ToolInputType::Directory); |
| 125 | } |
| 126 | else if (fs::exists(argPath)) |
no test coverage detected