|
7 | 7 |
|
8 | 8 | using namespace D3d12infoGUI; |
9 | 9 |
|
| 10 | +// Command line flags |
| 11 | +static bool g_OpenLicenses = false; |
| 12 | +static bool g_OpenHelp = false; |
| 13 | +static bool g_AutoSubmit = false; |
| 14 | +static std::wstring g_CustomWarpPath; |
| 15 | +static bool g_CLIArgumentsError = false; |
| 16 | + |
10 | 17 | int RunGUI(HINSTANCE hInstance) |
11 | 18 | { |
12 | 19 | Window window(hInstance, L"Extracting files"); |
@@ -40,11 +47,22 @@ int RunGUI(HINSTANCE hInstance) |
40 | 47 | std::vector<std::vector<char>> validReports; |
41 | 48 |
|
42 | 49 | std::wstring d3d12infoCmdLine = std::format( |
43 | | - L"\"{}\" --OutputFile=\"{}\" --AllAdapters --JSON --MinimizeJson --Formats --EnableExperimental=OFF", |
| 50 | + L"\"{}\" --OutputFile=\"{}\" --JSON --MinimizeJson --Formats --EnableExperimental=OFF", |
44 | 51 | d3d12infoPath.wstring(), d3d12infoReport.wstring()); |
45 | 52 | std::wstring d3d12infoPreviewCmdLine = |
46 | | - std::format(L"\"{}\" --OutputFile=\"{}\" --AllAdapters --JSON --MinimizeJson --Formats --EnableExperimental=ON", |
| 53 | + std::format(L"\"{}\" --OutputFile=\"{}\" --JSON --MinimizeJson --Formats --EnableExperimental=ON", |
47 | 54 | d3d12infoPreviewPath.wstring(), d3d12infoPreviewReport.wstring()); |
| 55 | + if(g_CustomWarpPath.empty()) |
| 56 | + { |
| 57 | + d3d12infoCmdLine += L" --AllAdapters"; |
| 58 | + d3d12infoPreviewCmdLine += L" --AllAdapters"; |
| 59 | + } |
| 60 | + else |
| 61 | + { |
| 62 | + std::filesystem::copy_file(g_CustomWarpPath, rootPath / "d3d10warp.dll", std::filesystem::copy_options::overwrite_existing); |
| 63 | + d3d12infoCmdLine += L" --WARP"; |
| 64 | + d3d12infoPreviewCmdLine += L" --WARP"; |
| 65 | + } |
48 | 66 |
|
49 | 67 | Subprocess d3d12infoProcess(d3d12infoCmdLine.data()); |
50 | 68 | Subprocess d3d12infoPreviewProcess(d3d12infoPreviewCmdLine.data()); |
@@ -74,7 +92,10 @@ int RunGUI(HINSTANCE hInstance) |
74 | 92 |
|
75 | 93 | window.ReportProgress(L"Generating report"); |
76 | 94 |
|
77 | | - ReportGenerator::GenerateHTML(rootPath, validReports); |
| 95 | + OpenOptions options{}; |
| 96 | + options.AutoSubmit = g_AutoSubmit; |
| 97 | + |
| 98 | + ReportGenerator::GenerateHTML(rootPath, validReports, options); |
78 | 99 | if(window.IsExitRequested()) |
79 | 100 | return 1; |
80 | 101 | window.ReportProgress(L"Opening report"); |
@@ -146,43 +167,107 @@ void OpenLicenses() |
146 | 167 | #endif |
147 | 168 | } |
148 | 169 |
|
149 | | -int ProcessCommandLine(LPWSTR lpCmdLine) |
| 170 | +void ParseCommandLine() |
150 | 171 | { |
151 | | - if(std::wcscmp(lpCmdLine, L"--licenses") == 0 || std::wcscmp(lpCmdLine, L"-l") == 0) |
152 | | - { |
153 | | - OpenLicenses(); |
154 | | - return 0; |
155 | | - } |
| 172 | + int argc = 0; |
| 173 | + LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); |
| 174 | + if(!argv) |
| 175 | + return; |
156 | 176 |
|
157 | | - if(std::wcscmp(lpCmdLine, L"--help") == 0 || std::wcscmp(lpCmdLine, L"-h") == 0) |
| 177 | + for(int i = 1; i < argc; ++i) |
158 | 178 | { |
159 | | - PrintHelp(); |
160 | | - return 0; |
161 | | - } |
| 179 | + LPWSTR arg = argv[i]; |
| 180 | + if(std::wcscmp(arg, L"--license") == 0 || std::wcscmp(arg, L"-l") == 0) |
| 181 | + { |
| 182 | + g_OpenLicenses = true; |
| 183 | + continue; |
| 184 | + } |
162 | 185 |
|
163 | | - PrintHelp(); |
164 | | - return 1; |
165 | | -} |
| 186 | + if(std::wcscmp(arg, L"--help") == 0 || std::wcscmp(arg, L"-h") == 0) |
| 187 | + { |
| 188 | + g_OpenHelp = true; |
| 189 | + continue; |
| 190 | + } |
166 | 191 |
|
167 | | -int RunCommandLine(LPWSTR lpCmdLine) |
168 | | -{ |
169 | | - InitializeConsole(); |
| 192 | + if(std::wcscmp(arg, L"--auto-submit") == 0 || std::wcscmp(arg, L"-a") == 0) |
| 193 | + { |
| 194 | + g_AutoSubmit = true; |
| 195 | + continue; |
| 196 | + } |
| 197 | + |
| 198 | + // --custom-warp=PATH |
| 199 | + constexpr wchar_t warpLongArgPrefix[] = L"--custom-warp="; |
| 200 | + constexpr size_t warpLongArgLen = sizeof(warpLongArgPrefix) / sizeof(wchar_t) - 1; |
| 201 | + if(std::wcsncmp(arg, warpLongArgPrefix, warpLongArgLen) == 0) |
| 202 | + { |
| 203 | + g_CustomWarpPath = std::wstring(arg + warpLongArgLen); |
| 204 | + continue; |
| 205 | + } |
170 | 206 |
|
171 | | - int result = ProcessCommandLine(lpCmdLine); |
| 207 | + // -w=PATH |
| 208 | + constexpr wchar_t warpShortArgPrefix[] = L"-w="; |
| 209 | + constexpr size_t warpShortArgLen = sizeof(warpShortArgPrefix) / sizeof(wchar_t) - 1; |
| 210 | + if(std::wcsncmp(arg, warpShortArgPrefix, warpShortArgLen) == 0) |
| 211 | + { |
| 212 | + g_CustomWarpPath = std::wstring(arg + warpShortArgLen); |
| 213 | + continue; |
| 214 | + } |
| 215 | + |
| 216 | + // --custom-warp PATH / -w PATH |
| 217 | + if(std::wcscmp(arg, L"--custom-warp") == 0 || std::wcscmp(arg, L"-w") == 0) |
| 218 | + { |
| 219 | + if(i + 1 >= argc) |
| 220 | + { |
| 221 | + g_CLIArgumentsError = true; |
| 222 | + break; |
| 223 | + } |
| 224 | + |
| 225 | + g_CustomWarpPath = std::wstring(argv[++i]); |
| 226 | + continue; |
| 227 | + } |
172 | 228 |
|
173 | | - ::FreeConsole(); |
| 229 | + g_CLIArgumentsError = true; |
| 230 | + break; |
| 231 | + } |
174 | 232 |
|
175 | | - return result; |
| 233 | + if (g_CustomWarpPath.size() > 2) |
| 234 | + { |
| 235 | + size_t beginPos = 0; |
| 236 | + size_t endPos = g_CustomWarpPath.size(); |
| 237 | + if (g_CustomWarpPath[beginPos] == L'"') |
| 238 | + { |
| 239 | + ++beginPos; |
| 240 | + } |
| 241 | + if (g_CustomWarpPath[endPos - 1] == L'"') |
| 242 | + { |
| 243 | + --endPos; |
| 244 | + } |
| 245 | + g_CustomWarpPath = g_CustomWarpPath.substr(beginPos, endPos - beginPos); |
| 246 | + } |
| 247 | + |
| 248 | + LocalFree(argv); |
176 | 249 | } |
177 | 250 |
|
178 | 251 | int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) |
179 | 252 | { |
180 | 253 | try |
181 | 254 | { |
182 | | - if(*lpCmdLine != L'\0') |
| 255 | + ParseCommandLine(); |
| 256 | + |
| 257 | + if(g_CLIArgumentsError || g_OpenHelp) |
183 | 258 | { |
184 | | - return RunCommandLine(lpCmdLine); |
| 259 | + InitializeConsole(); |
| 260 | + PrintHelp(); |
| 261 | + ::FreeConsole(); |
| 262 | + return g_CLIArgumentsError ? 1 : 0; |
185 | 263 | } |
| 264 | + |
| 265 | + if(g_OpenLicenses) |
| 266 | + { |
| 267 | + OpenLicenses(); |
| 268 | + return 0; |
| 269 | + } |
| 270 | + |
186 | 271 | return RunGUI(hInstance); |
187 | 272 | } |
188 | 273 | catch(const std::exception& e) |
|
0 commit comments