diff options
| author | Charles Giessen <charles@lunarg.com> | 2021-06-21 10:16:38 -0600 |
|---|---|---|
| committer | Charles Giessen <46324611+charles-lunarg@users.noreply.github.com> | 2021-11-29 13:03:31 -0700 |
| commit | db7ac7a7a7d01ad4ee88aa3e3e6d2efb9ed7f4df (patch) | |
| tree | 17758d5b53aff1627e361dcddb361dc820635bf2 /vulkaninfo | |
| parent | 181bcce094cefd4df30861b760ff1779bfb65fce (diff) | |
| download | usermoji-db7ac7a7a7d01ad4ee88aa3e3e6d2efb9ed7f4df.tar.xz | |
vulkaninfo: Allow specifying file output
Use `-o <filename>` or `--output <filename>` to specify the filename of which
vulkaninfo will write to in the current directory.
Diffstat (limited to 'vulkaninfo')
| -rw-r--r-- | vulkaninfo/vulkaninfo.cpp | 24 | ||||
| -rw-r--r-- | vulkaninfo/vulkaninfo.md | 3 |
2 files changed, 23 insertions, 4 deletions
diff --git a/vulkaninfo/vulkaninfo.cpp b/vulkaninfo/vulkaninfo.cpp index 70cb30f7..8be482e9 100644 --- a/vulkaninfo/vulkaninfo.cpp +++ b/vulkaninfo/vulkaninfo.cpp @@ -838,6 +838,9 @@ void print_usage(const char *argv0) { std::cout << "--show-formats Display the format properties of each physical device.\n"; std::cout << " Note: This option does not affect html or json output;\n"; std::cout << " they will always print format properties.\n\n"; + std::cout << "-o <filename>, --output<filename>\n"; + std::cout << " Print output to a new file whose name is specified by filename.\n"; + std::cout << " File will be written to the current working directory.\n"; std::cout << "--summary Show a summary of the instance and GPU's on a system.\n\n"; } @@ -847,7 +850,9 @@ struct ParsedResults { bool has_selected_gpu; // differentiate between selecting the 0th gpu and using the default 0th value bool show_tool_props; bool show_formats; + bool use_custom_filename; char *output_path; + char *custom_filename; }; util::trivial_optional<ParsedResults> parse_arguments(int argc, char **argv) { @@ -878,6 +883,12 @@ util::trivial_optional<ParsedResults> parse_arguments(int argc, char **argv) { } else if (strcmp(argv[i], "--show-tool-props") == 0) { results.show_tool_props = true; } else if (strcmp(argv[i], "--show-formats") == 0) { + results.show_formats = true; + } else if ((strcmp(argv[i], "--output") == 0 || strcmp(argv[i], "-o") == 0) && argc > (i + 1)) { + results.use_custom_filename = true; + results.custom_filename = argv[i + 1]; + ++i; + } else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) { print_usage(argv[0]); return {}; } else { @@ -1075,10 +1086,15 @@ int main(int argc, char **argv) { #endif auto printer_data = get_printer_create_details(parse_data, instance, *gpus.at(parse_data.selected_gpu)); - if (printer_data.use_file_output) { - file_out = std::ofstream(printer_data.file_name); + if (printer_data.use_file_output || (parse_data.use_custom_filename && parse_data.custom_filename)) { + if (parse_data.use_custom_filename) { + file_out = std::ofstream(parse_data.custom_filename); + } else { + file_out = std::ofstream(printer_data.file_name); + } } - printer = std::unique_ptr<Printer>(new Printer(printer_data.output_type, printer_data.use_file_output ? file_out : out, + bool use_file_out = parse_data.use_custom_filename || printer_data.use_file_output; + printer = std::unique_ptr<Printer>(new Printer(printer_data.output_type, use_file_out ? file_out : out, parse_data.selected_gpu, instance.vk_version, printer_data.start_string)); RunPrinter(*(printer.get()), parse_data, instance, gpus, surfaces); @@ -1098,7 +1114,7 @@ int main(int argc, char **argv) { printer.reset(nullptr); #ifdef _WIN32 - if (parse_data.output_category == OutputCategory::text) wait_for_console_destroy(); + if (parse_data.output_category == OutputCategory::text && !parse_data.use_custom_filename) wait_for_console_destroy(); #endif return 0; diff --git a/vulkaninfo/vulkaninfo.md b/vulkaninfo/vulkaninfo.md index 04207995..0f7b9298 100644 --- a/vulkaninfo/vulkaninfo.md +++ b/vulkaninfo/vulkaninfo.md @@ -71,6 +71,9 @@ OPTIONS: --show-formats Display the format properties of each physical device. Note: This option does not affect html or json output; they will always print format properties. +-o <filename>, --output<filename> + Print output to a new file whose name is specified by filename. + File will be written to the current working directory. --summary Show a summary of the instance and GPU's on a system. ``` |
