diff options
| author | AlxcBTW <187763517+AlxcBTW@users.noreply.github.com> | 2026-11-22 17:51:53 +0100 |
|---|---|---|
| committer | AlxcBTW <187763517+AlxcBTW@users.noreply.github.com> | 2026-11-22 17:51:53 +0100 |
| commit | 97daa1aec0e11d9b063b32a5da6c176d55793330 (patch) | |
| tree | b25b47984eb810fea1ae338a8cd4feec34cbe0c4 /runtime/src/main.cpp | |
| parent | 0a3bf1ed91a529cb0ad093262d8b9d5250102763 (diff) | |
| parent | 49475796c226c8511b9470bf97a4daf57b8af323 (diff) | |
Merge origin/main into presentx-planes
Keeps the swapchain_colorspace enable and main's custom border colour extension in
create_vulkan_device_standalone; the present compose path follows main's LayoutPieces.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/main.cpp')
| -rw-r--r-- | runtime/src/main.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp index 560f68349..06baae387 100644 --- a/runtime/src/main.cpp +++ b/runtime/src/main.cpp | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | // gta6rt --init <image> [--game-dir DIR] [--overlay DIR] | 9 | // gta6rt --init <image> [--game-dir DIR] [--overlay DIR] |
| 10 | // The same mapping, then each loaded DLL's TLS callbacks and DllMain(DLL_PROCESS_ATTACH) are run. | 10 | // The same mapping, then each loaded DLL's TLS callbacks and DllMain(DLL_PROCESS_ATTACH) are run. |
| 11 | // | 11 | // |
| 12 | // gta6rt --run <exe> [--game-dir DIR] [--overlay DIR] [--trace-d3d12] [-- game arguments...] | 12 | // gta6rt --run <exe> [--game-dir DIR] [--overlay DIR] [--trace-d3d12] [--trace FILE] [-- game arguments...] |
| 13 | // The same, then the EXE's own TLS callbacks and its entry point, on a game thread. The game's argv and | 13 | // The same, then the EXE's own TLS callbacks and its entry point, on a game thread. The game's argv and |
| 14 | // command line are <exe name> plus the arguments after "--"; exit/ExitProcess from the game end the run | 14 | // command line are <exe name> plus the arguments after "--"; exit/ExitProcess from the game end the run |
| 15 | // (shims/process.cpp). gta6rt prints the binding report first and returns the game's exit code. | 15 | // (shims/process.cpp). gta6rt prints the binding report first and returns the game's exit code. |
| @@ -29,6 +29,7 @@ | |||
| 29 | #include "../shims/file_system.h" | 29 | #include "../shims/file_system.h" |
| 30 | #include "../shims/process_shim.h" | 30 | #include "../shims/process_shim.h" |
| 31 | #include "../shims/shims.h" | 31 | #include "../shims/shims.h" |
| 32 | #include "../shims/startup_trace.h" | ||
| 32 | 33 | ||
| 33 | namespace { | 34 | namespace { |
| 34 | 35 | ||
| @@ -43,9 +44,9 @@ const char* binding_name(rt::Binding b) { | |||
| 43 | 44 | ||
| 44 | int usage() { | 45 | int usage() { |
| 45 | std::fprintf(stderr, | 46 | std::fprintf(stderr, |
| 46 | "usage: gta6rt --dry-run <image> [--game-dir DIR] [--overlay DIR]\n" | 47 | "usage: gta6rt --dry-run <image> [--game-dir DIR] [--overlay DIR] [--trace FILE]\n" |
| 47 | " gta6rt --init <image> [--game-dir DIR] [--overlay DIR] [--trace-d3d12]\n" | 48 | " gta6rt --init <image> [--game-dir DIR] [--overlay DIR] [--trace-d3d12] [--trace FILE]\n" |
| 48 | " gta6rt --run <exe> [--game-dir DIR] [--overlay DIR] [--trace-d3d12] [-- game arguments...]\n"); | 49 | " gta6rt --run <exe> [--game-dir DIR] [--overlay DIR] [--trace-d3d12] [--trace FILE] [-- game arguments...]\n"); |
| 49 | return 2; | 50 | return 2; |
| 50 | } | 51 | } |
| 51 | 52 | ||
| @@ -55,6 +56,7 @@ int wmain(int argc, wchar_t** argv) { | |||
| 55 | std::filesystem::path image, game_dir, overlay_dir; | 56 | std::filesystem::path image, game_dir, overlay_dir; |
| 56 | bool dry_run = false, init = false, run = false, trace_d3d12 = false; | 57 | bool dry_run = false, init = false, run = false, trace_d3d12 = false; |
| 57 | std::vector<std::wstring> game_args; // wide: path::string() throws on a character the code page lacks (RT-84) | 58 | std::vector<std::wstring> game_args; // wide: path::string() throws on a character the code page lacks (RT-84) |
| 59 | std::wstring trace_file; | ||
| 58 | for (int i = 1; i < argc; ++i) { | 60 | for (int i = 1; i < argc; ++i) { |
| 59 | std::wstring a = argv[i]; | 61 | std::wstring a = argv[i]; |
| 60 | if (a == L"--") { | 62 | if (a == L"--") { |
| @@ -65,6 +67,7 @@ int wmain(int argc, wchar_t** argv) { | |||
| 65 | else if (a == L"--init") init = true; | 67 | else if (a == L"--init") init = true; |
| 66 | else if (a == L"--run") run = true; | 68 | else if (a == L"--run") run = true; |
| 67 | else if (a == L"--trace-d3d12") trace_d3d12 = true; | 69 | else if (a == L"--trace-d3d12") trace_d3d12 = true; |
| 70 | else if (a == L"--trace" && i + 1 < argc) trace_file = argv[++i]; | ||
| 68 | else if (a == L"--game-dir" && i + 1 < argc) game_dir = argv[++i]; | 71 | else if (a == L"--game-dir" && i + 1 < argc) game_dir = argv[++i]; |
| 69 | else if (a == L"--overlay" && i + 1 < argc) overlay_dir = argv[++i]; | 72 | else if (a == L"--overlay" && i + 1 < argc) overlay_dir = argv[++i]; |
| 70 | else if (image.empty()) image = a; | 73 | else if (image.empty()) image = a; |
| @@ -82,6 +85,11 @@ int wmain(int argc, wchar_t** argv) { | |||
| 82 | if (overlay_dir.empty()) overlay_dir = game_dir / "overlay"; | 85 | if (overlay_dir.empty()) overlay_dir = game_dir / "overlay"; |
| 83 | rt::fs::configure(game_dir, overlay_dir); | 86 | rt::fs::configure(game_dir, overlay_dir); |
| 84 | rt::d3d12_trace::set_enabled(trace_d3d12); | 87 | rt::d3d12_trace::set_enabled(trace_d3d12); |
| 88 | if (int trace_error = 0; !trace_file.empty() && !rt::startup_trace::open(trace_file.c_str(), &trace_error)) { | ||
| 89 | std::fprintf(stderr, trace_error == EEXIST ? "error: the trace file already exists; --trace only creates a new file\n" | ||
| 90 | : "error: cannot create the trace file\n"); | ||
| 91 | return 2; | ||
| 92 | } | ||
| 85 | 93 | ||
| 86 | try { | 94 | try { |
| 87 | rt::Loader loader(game_dir); | 95 | rt::Loader loader(game_dir); |
| @@ -112,7 +120,10 @@ int wmain(int argc, wchar_t** argv) { | |||
| 112 | std::printf("%zu module(s) mapped, %d unimplemented import(s)\n", loader.modules().size(), unimplemented); | 120 | std::printf("%zu module(s) mapped, %d unimplemented import(s)\n", loader.modules().size(), unimplemented); |
| 113 | std::printf("unimplemented by return policy: hresult=%d other=%d\n", unimplemented_hresult, | 121 | std::printf("unimplemented by return policy: hresult=%d other=%d\n", unimplemented_hresult, |
| 114 | unimplemented - unimplemented_hresult); | 122 | unimplemented - unimplemented_hresult); |
| 115 | if (!run) return 0; | 123 | if (!run) { |
| 124 | rt::startup_trace::event("exit", "\"code\":0"); | ||
| 125 | return 0; | ||
| 126 | } | ||
| 116 | if (!main_module.entry_rva) { | 127 | if (!main_module.entry_rva) { |
| 117 | std::fprintf(stderr, "error: %s has no entry point\n", main_module.name.c_str()); | 128 | std::fprintf(stderr, "error: %s has no entry point\n", main_module.name.c_str()); |
| 118 | return 1; | 129 | return 1; |
| @@ -125,6 +136,7 @@ int wmain(int argc, wchar_t** argv) { | |||
| 125 | std::fflush(stdout); | 136 | std::fflush(stdout); |
| 126 | std::printf("game exited with code %d\n", code); | 137 | std::printf("game exited with code %d\n", code); |
| 127 | rt::shims::report_called_unimplemented(); | 138 | rt::shims::report_called_unimplemented(); |
| 139 | rt::startup_trace::event("exit", "\"code\":" + std::to_string(code)); | ||
| 128 | std::fflush(stdout); | 140 | std::fflush(stdout); |
| 129 | std::fflush(stderr); | 141 | std::fflush(stderr); |
| 130 | // Not `return`: a normal host exit runs the CRT's atexit table, which the game shares with gta6rt (its | 142 | // Not `return`: a normal host exit runs the CRT's atexit table, which the game shares with gta6rt (its |
| @@ -132,6 +144,7 @@ int wmain(int argc, wchar_t** argv) { | |||
| 132 | ExitProcess(static_cast<UINT>(code)); | 144 | ExitProcess(static_cast<UINT>(code)); |
| 133 | } catch (const std::exception& e) { | 145 | } catch (const std::exception& e) { |
| 134 | std::fprintf(stderr, "error: %s\n", e.what()); | 146 | std::fprintf(stderr, "error: %s\n", e.what()); |
| 147 | rt::startup_trace::event("error", "\"what\":" + rt::startup_trace::quote(e.what())); | ||
| 135 | return 1; | 148 | return 1; |
| 136 | } | 149 | } |
| 137 | } | 150 | } |