diff options
| author | Mumogg <104529023+Mumogg@users.noreply.github.com> | 2026-11-23 20:42:04 -0600 |
|---|---|---|
| committer | Mumogg <104529023+Mumogg@users.noreply.github.com> | 2026-11-23 20:42:04 -0600 |
| commit | 1a04df0b1b8f8592009a3049948bdd057badcad9 (patch) | |
| tree | effbe9d1db2b2ca979e89a8c372c25cbe777b83c /runtime/src/main.cpp | |
| parent | 902d594127bd7355ebe9fb0aad84dcca5acd4dd7 (diff) | |
| parent | 9ec34cdff41b19d7671bc260e5f40dc69790d905 (diff) | |
Merge main (9ec34cdff) into the frame-loop boot stack
The stack is ladder-frame (ASTROWwwW's integration of the retail boot pull requests) with the old pull requests
7604, 7286, 7584, 6446, 8591, 7384, 7535, 7448, 9137 and 9419 and local fixes on top. main carries many of those
commits as ancestors without their content, so the merge was made against main's tree, not its history: nothing
main dropped is dropped again here.
Resolved by hand:
- d3d12_xs_device.cpp and frame_pacer.h: the stack's Xbox-ABI layer, plus main's uncapped pacer and its two new
registration hooks (set_placed_at_va_pages_hook is called before slot 133's handler; the console descriptor
heap handler is stored but slot 14 still uses the title-backed heaps of old PR 7021).
- xmem.cpp, xmem_test.cpp: the stack's run-mapped physical pages. main's commit-on-touch xmem with the two
view-protection fixes it lost (7e8e3c1db, 954fcb106) boots to 50,468 pipelines and then fails a submit with an
unknown resource, so it is not used here yet.
- acphal.cpp, acphal_test.cpp, vulkan_replay.h (acceleration structure copy), README: main's.
- CMakeLists.txt, build_runtime.ps1, d3d12_com.cpp, d3d12_vulkan_device.cpp, shader_library.h, docs: both sides.
Measured (Linux, Wine 11.21 staging, RTX 5070 Ti, driver 615.78.08, clang-cl 22.1.8 + xwin, own 1.0.2.1 copy,
network off, LEONIDA_GRAPHICS_STAGE_LAYOUT=1, 300 s): 50,470 pipeline states created, 197,998 ExecuteCommandLists
with none failed, 148,467 DrawInstanced, 99,008 PresentX.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
Diffstat (limited to 'runtime/src/main.cpp')
| -rw-r--r-- | runtime/src/main.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp index 11da727b8..7d0dbfd88 100644 --- a/runtime/src/main.cpp +++ b/runtime/src/main.cpp | |||
| @@ -30,13 +30,16 @@ | |||
| 30 | #include "base_reservation.h" | 30 | #include "base_reservation.h" |
| 31 | #include "code_hooks.h" | 31 | #include "code_hooks.h" |
| 32 | #include "cpu_emulation.h" | 32 | #include "cpu_emulation.h" |
| 33 | #include "host_cpu.h" | ||
| 33 | #include "mods.h" | 34 | #include "mods.h" |
| 34 | #include "pe_loader.h" | 35 | #include "pe_loader.h" |
| 35 | #include "../shims/d3d12_trace.h" | 36 | #include "../shims/d3d12_trace.h" |
| 37 | #include "../shims/d3d12_xs_device.h" | ||
| 36 | #include "../shims/file_system.h" | 38 | #include "../shims/file_system.h" |
| 37 | #include "../shims/process_shim.h" | 39 | #include "../shims/process_shim.h" |
| 38 | #include "../shims/shims.h" | 40 | #include "../shims/shims.h" |
| 39 | #include "../shims/startup_trace.h" | 41 | #include "../shims/startup_trace.h" |
| 42 | #include "../shims/xmem.h" | ||
| 40 | 43 | ||
| 41 | namespace { | 44 | namespace { |
| 42 | 45 | ||
| @@ -112,6 +115,12 @@ int wmain(int argc, wchar_t** argv) { | |||
| 112 | if (image.empty()) return usage(); | 115 | if (image.empty()) return usage(); |
| 113 | // Exactly one mode: --dry-run --run would otherwise initialise the modules and call the entry point. | 116 | // Exactly one mode: --dry-run --run would otherwise initialise the modules and call the entry point. |
| 114 | if (dry_run + init + run != 1) return usage(); | 117 | if (dry_run + init + run != 1) return usage(); |
| 118 | // The game runs AVX code from its TLS callbacks on; without AVX that is a bare 0xC000001D (src/host_cpu.h). | ||
| 119 | if ((init || run) && !rt::host_cpu::check_skipped()) | ||
| 120 | if (const auto missing = rt::host_cpu::missing_host_features(); !missing.empty()) { | ||
| 121 | std::fprintf(stderr, "%s\n", rt::host_cpu::message(missing).c_str()); | ||
| 122 | return rt::host_cpu::kExitCode; | ||
| 123 | } | ||
| 115 | // The console folders are fixed once, as absolute paths. A bare image name (`gta6rt --run game.exe` from the | 124 | // The console folders are fixed once, as absolute paths. A bare image name (`gta6rt --run game.exe` from the |
| 116 | // game folder) has an empty parent path, which left GAME: with no root; and a relative --game-dir or --overlay | 125 | // game folder) has an empty parent path, which left GAME: with no root; and a relative --game-dir or --overlay |
| 117 | // would follow the title's later SetCurrentDirectory. If absolute() fails the path stays as given. | 126 | // would follow the title's later SetCurrentDirectory. If absolute() fails the path stays as given. |
| @@ -122,6 +131,15 @@ int wmain(int argc, wchar_t** argv) { | |||
| 122 | }; | 131 | }; |
| 123 | game_dir = game_dir.empty() ? absolute_or_same(image).parent_path() : absolute_or_same(game_dir); | 132 | game_dir = game_dir.empty() ? absolute_or_same(image).parent_path() : absolute_or_same(game_dir); |
| 124 | if (!overlay_dir.empty()) overlay_dir = absolute_or_same(overlay_dir); | 133 | if (!overlay_dir.empty()) overlay_dir = absolute_or_same(overlay_dir); |
| 134 | // LEONIDA_SHADERS too: the D3D12 device reads it at the title's first pipeline state, after it may have moved. | ||
| 135 | if (const DWORD size = GetEnvironmentVariableW(L"LEONIDA_SHADERS", nullptr, 0)) { | ||
| 136 | std::wstring shaders(size, L'\0'); | ||
| 137 | const DWORD n = GetEnvironmentVariableW(L"LEONIDA_SHADERS", shaders.data(), size); | ||
| 138 | if (n && n < size) { | ||
| 139 | shaders.resize(n); | ||
| 140 | SetEnvironmentVariableW(L"LEONIDA_SHADERS", absolute_or_same(shaders).c_str()); | ||
| 141 | } | ||
| 142 | } | ||
| 125 | // An image without relocations whose range this process already uses (arm64 Wine on macOS) runs in a new | 143 | // An image without relocations whose range this process already uses (arm64 Wine on macOS) runs in a new |
| 126 | // process that has the range reserved from the start (base_reservation.h); that process does not do this again. | 144 | // process that has the range reserved from the start (base_reservation.h); that process does not do this again. |
| 127 | if (!rt::base_reservation::inherited()) | 145 | if (!rt::base_reservation::inherited()) |
| @@ -158,6 +176,9 @@ int wmain(int argc, wchar_t** argv) { | |||
| 158 | "this executable (docs/modding.md)\n", leonida::mods::active().size()); | 176 | "this executable (docs/modding.md)\n", leonida::mods::active().size()); |
| 159 | } | 177 | } |
| 160 | rt::d3d12_trace::set_enabled(trace_d3d12); | 178 | rt::d3d12_trace::set_enabled(trace_d3d12); |
| 179 | // Slot 133 imports the title's pages; xmem commits them on first touch, so they are committed first. | ||
| 180 | // MERGE NOTE: main registers rt::xmem::commit_physical_range here for its commit-on-touch xmem. This branch keeps | ||
| 181 | // the run-mapped xmem (pages are committed when allocated), so there is nothing to commit before slot 133. | ||
| 161 | if (int trace_error = 0; !trace_file.empty() && !rt::startup_trace::open(trace_file.c_str(), &trace_error)) { | 182 | if (int trace_error = 0; !trace_file.empty() && !rt::startup_trace::open(trace_file.c_str(), &trace_error)) { |
| 162 | std::fprintf(stderr, trace_error == EEXIST ? "error: the trace file already exists; --trace only creates a new file\n" | 183 | std::fprintf(stderr, trace_error == EEXIST ? "error: the trace file already exists; --trace only creates a new file\n" |
| 163 | : "error: cannot create the trace file\n"); | 184 | : "error: cannot create the trace file\n"); |