| 34 | } g_options; |
| 35 | |
| 36 | bool ProcessCommandLine(int argc, const char** argv) |
| 37 | { |
| 38 | struct argparse_option options[] = { |
| 39 | OPT_HELP(), |
| 40 | #if DONUT_WITH_VULKAN |
| 41 | OPT_BOOLEAN(0, "vk", &g_options.useVulkan, "Use Vulkan API"), |
| 42 | #endif |
| 43 | #if DONUT_WITH_DX12 |
| 44 | OPT_BOOLEAN(0, "dx12", &g_options.useDX12, "Use D3D12 API"), |
| 45 | #endif |
| 46 | OPT_BOOLEAN(0, "debug", &g_options.debug, "Enable debug features such as Vulkan validation layer or D3D12 debug runtime"), |
| 47 | OPT_INTEGER(0, "adapter", &g_options.adapterIndex, "Index of the graphics adapter to use"), |
| 48 | OPT_INTEGER(0, "channels", &g_options.numChannels, "Number of channels to compare (0 = auto-detect, default)"), |
| 49 | OPT_END() |
| 50 | }; |
| 51 | |
| 52 | static const char* usages[] = { |
| 53 | "imagediff.exe <paths...> [options...]", |
| 54 | nullptr |
| 55 | }; |
| 56 | |
| 57 | struct argparse argparse {}; |
| 58 | argparse_init(&argparse, options, usages, 0); |
| 59 | argparse_describe(&argparse, "\nImage comparison tool.\nInput files must be provided in pairs.", nullptr); |
| 60 | argparse_parse(&argparse, argc, argv); |
| 61 | |
| 62 | if (g_options.useVulkan && g_options.useDX12) |
| 63 | { |
| 64 | fprintf(stderr, "Only one of --vk or --dx12 options can be specified.\n"); |
| 65 | return false; |
| 66 | } |
| 67 | |
| 68 | if (!g_options.useVulkan && !g_options.useDX12) |
| 69 | { |
| 70 | #if DONUT_WITH_VULKAN |
| 71 | g_options.useVulkan = true; |
| 72 | #else |
| 73 | g_options.useDX12 = true; |
| 74 | #endif |
| 75 | assert(g_options.useDX12 || g_options.useVulkan); |
| 76 | } |
| 77 | |
| 78 | if (g_options.numChannels < 0 || g_options.numChannels > 4) |
| 79 | { |
| 80 | fprintf(stderr, "The --channels value must be between 0 and 4.\n"); |
| 81 | return false; |
| 82 | } |
| 83 | |
| 84 | // Process positional arguments |
| 85 | for (int i = 0; argparse.out[i]; ++i) |
| 86 | { |
| 87 | char const* arg = argparse.out[i]; |
| 88 | if (!arg[0]) |
| 89 | continue; |
| 90 | g_options.sources.push_back(arg); |
| 91 | } |
| 92 | |
| 93 | if (g_options.sources.size() == 0 || (g_options.sources.size() & 1) != 0) |
no test coverage detected