MCPcopy Create free account
hub / github.com/GPUOpen-Tools/GPU-Reshape / main

Function main

Source/Backends/Vulkan/Generator/Source/Generator.cpp:44–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42#include "GenTypes.h"
43
44int main(int argc, char *const argv[]) {
45 argparse::ArgumentParser program("GPUOpen GRS - Vulkan Generator");
46
47 // Setup parameters
48 program.add_argument("-vkxml").help("Path of the vulkan specification xml file").required();
49 program.add_argument("-template").help("The file to template").required();
50 program.add_argument("-spvjson").help("The file to the spv json specification").default_value(std::string(""));
51 program.add_argument("-gentype").help("The generation type, one of [commandbuffer, commandbufferdispatchtable, deepcopyobjects]").required();
52 program.add_argument("-whitelist").help("Whitelist a callback").default_value(std::string(""));
53 program.add_argument("-hook").help("All feature hooks").default_value(std::string(""));
54 program.add_argument("-object").help("All generator objects").default_value(std::string(""));
55 program.add_argument("-o").help("Output of the generated file").required();
56
57 // Attempt to parse the input
58 try {
59 program.parse_args(argc, argv);
60 } catch (const std::runtime_error &err) {
61 std::cerr << err.what() << std::endl;
62 std::cerr << program;
63 return 1;
64 }
65
66 // Arguments
67 auto &&vkxml = program.get<std::string>("-vkxml");
68 auto &&gentype = program.get<std::string>("-gentype");
69 auto &&ftemplate = program.get<std::string>("-template");
70 auto &&spvjson = program.get<std::string>("-spvjson");
71 auto &&output = program.get<std::string>("-o");
72 auto &&whitelist = program.get<std::string>("-whitelist");
73 auto &&object = program.get<std::string>("-object");
74 auto &&hooks = program.get<std::string>("-hook");
75
76 // Generator information
77 GeneratorInfo generatorInfo{};
78
79 if (!spvjson.empty()) {
80 // Open json
81 std::ifstream stream(spvjson);
82 if (!stream.good()) {
83 std::cerr << "Failed to open json file: " << spvjson << std::endl;
84 return 1;
85 }
86
87 // Parse json
88 try {
89 stream >> generatorInfo.spvJson;
90 } catch(nlohmann::json::exception& ex) {
91 std::cerr << "Failed to parse json file: " << spvjson << ", " << ex.what() << std::endl;
92 return 1;
93 }
94 }
95
96 // Parse whitelist
97 std::stringstream whitelistStream(whitelist);
98 while( whitelistStream.good() ) {
99 std::string substr;
100 getline(whitelistStream, substr, ',' );
101 generatorInfo.whitelist.insert(substr);

Callers

nothing calls this directly

Calls 7

FilterRegistryFunction · 0.85
LoadFileMethod · 0.80
CommandBufferClass · 0.50
emptyMethod · 0.45
insertMethod · 0.45
LoadMethod · 0.45
GetStringMethod · 0.45

Tested by

no test coverage detected