Commit Graph
43 Commits
Author SHA1 Message Date
Valiantsin DzerakhandClaude Opus 5.5 0ca11dfba2 Keep the six most used general registers of each generated function in C locals
Every lifted instruction read and wrote c->x[n] and c->sp, so each register passed from one guest instruction to the
next went through a store and a load, and clang could not keep it in a host register across a guest store.
recomp/regs.py now copies the six most used X registers and SP of a function into locals at its entry. A forward pass
over the function's flow tracks which locals changed since the last sync, and only those are stored back before a
call, an SVC, a trap, a return or a tail exit. After an SVC every local reloads; after a call only X0-X18 and X30,
since AAPCS64 has the callee preserve X19-X29 and SP. TotK does not break that: main and subsdk0 import neither
longjmp nor the unwinder, sdk's have no direct callers, and the runtime writes no register above X3 except X30.
gen.py --no-callee-saved-trust reloads them too, --reg-locals sets the count. Functions with an unresolved computed br
keep their registers in the Cpu, as they keep NZCV.

All registers in locals was slower than none: clang spills them to the stack and the syncs stay. Over 300 hot
functions, 4-6 locals gave the fewest instructions and memory operands.

1.4.3 .text 299 -> 266 MiB. Fight bench (bench-fight2-2026-10-27b, frames 5400-7500, uncapped): 11.30 and 11.92 ms vs
13.5-13.9 on main; frames 2400-5300 11.24 and 11.36 vs 13.25. Without the callee-saved trust 12.58 ms.
tests/diff/func.py: 0 failing on 1.4.3 (889 functions, 583 with calls) and 1.2.1 (810); a plan with no spills fails
at once. Probes kernel, vkexec, nvn-tex and shader pass in both versions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 22:21:18 +03:00
Valiantsin DzerakhandClaude Opus 5.5 fae0faf6dc List tests/flags_check.py among the lifter checks in docs/building.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 18:08:11 +03:00
Valiantsin DzerakhandClaude Opus 5.5 27056b212a Keep NZCV in a local of each generated function instead of c->nzcv
Every flag-setting instruction packed N, Z, C and V into c->nzcv and every reader unpacked them. recomp/flags.py
now runs a reaching-definitions pass per function: a compare stores its operands in a local Flags F, and a reader
whose definitions are all of one kind computes its condition from them, so cmp and b.cond become one host compare.
CCMP, FCMP, MSR NZCV and ADCS write the packed form, which readers reached by several kinds also use. Calls and
returns publish nothing (AAPCS64 neither passes nor preserves NZCV); tail branches, falls into the next function and
br through rt_dispatch publish c->nzcv, since discovery can start a function inside another one. Functions with an
unresolved computed br keep flags in c->nzcv.

1.4.3 main: 492k direct and 89k packed flag reads, .text 342 -> 299 MiB. Fight bench (bench-fight2-2026-10-27b,
frames 5400-7500, uncapped) 13.15 and 13.63 ms vs 13.9 before. tests/flags_check.py checks the new helpers against
the packed ones; tests/diff/func.py no longer compares NZCV, which generated code leaves untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 18:07:58 +03:00
Valiantsin DzerakhandClaude Opus 5.5 ad70afaee0 Build hactool from the repository: tools/build_hactool.py fetches the pinned commit, applies tools/hactool/*.patch and links a static exe
The MacNativeGames BKTR and title-key changes and our UTF-8 manifest lived only in the maintainer's toolchain folder, so
nobody else could build the hactool that extraction and the installer need. The script's exe matches the one in use
byte for byte apart from its build time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 13:18:23 +03:00
Valiantsin DzerakhandClaude Opus 5.5 e3e72dfb44 Keep the repository to what players and contributors use; move the agent setup and working notes out of git
docs/building.md merges the two toolchain docs and the README build steps, and lists the developer checks. The
Maxwell reference moves to docs/maxwell.md. architecture.md loses the milestone table, controls.md describes timed
script lines and input recording, and the tester guide includes shader preparation.

The agent skills, hooks, playbook, backlog and the study notes on upstream projects are the maintainer's local setup:
.claude/, notes/ and CLAUDE.local.md are ignored now, and tools/worktree.py links them into task worktrees. AGENTS.md
keeps the project rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 13:12:50 +03:00
Valiantsin DzerakhandClaude Opus 5.5 fb51973fa3 Collect what the Windows host costs into docs/research/windows-host.md: timer overshoot, counter conversion, small-file opens and flushes behind other writers, thread sampling pitfalls, the three virtual cores, VMA block allocation, run-to-run spread and bit flips; AGENTS.md points to it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 13:01:22 +03:00
Valiantsin DzerakhandClaude Opus 5.5 42b73c4098 Note what each 2026-10 frame time fix needs on a Linux host: the SleepThread spin is for the Windows timer only, the file I/O moved off the game and render threads is portable with fsync in place of FlushFileBuffers, the slow-present profiler is Windows-only
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 13:01:22 +03:00
Valiantsin DzerakhandClaude Opus 5.5 a653f4cdd1 Merge the driver cache correction: a relink keeps the AMD driver's pipeline cache, so build_game no longer re-warms it after every relink; the cold libraries came from preparing another build dir, and --warm-shaders stays for that case
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 09:54:28 +03:00
Valiantsin DzerakhandClaude Opus 5.5 7fefa86fe3 Compile patches.c per install instead of into the prebuilt runtime library
The release built libtotkrt.a against generated/v121, so patches.c baked in 1.2.1's patch page (0x700472b000, the page
after 1.2.1's main). A 1.4.3 install lifts its code with the 1.4.3 patch table, whose patched sites read the page after
1.4.3's main (0x7003adf000): the runtime never committed it and the game faulted there soon after mounting the save, while
frame_rate.c wrote its frame step into sdk memory at the 1.2.1 address. patches.c now joins romfs.c in INSTALL_SIDE and
the release ships its source, so it compiles against the player's patches.h.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 09:12:15 +03:00
Valiantsin DzerakhandClaude Opus 5.5 5784084590 Drop the driver cache warm after every relink: a relink keeps the AMD cache (29,587 variants re-warmed in 1.8 s), the cold libraries in play came from preparing another build dir, which evicted this one's; --warm-shaders stays for that case
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 09:10:43 +03:00
Valiantsin DzerakhandClaude Opus 5.5 a3bbeac08a Record in backlog item 20 what holds device-local memory, the released texture entries as the grower, machine B at its budget and the plan for an age-ordered drop under pressure
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 07:51:12 +03:00
Valiantsin DzerakhandClaude Opus 5.5 10113e1857 Record in backlog item 38 that the Advanced tab and the full performance overlay are in, and what is left of the menu
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 20:57:21 +03:00
Valiantsin DzerakhandClaude Opus 5.5 bc3ea82c3d Record in backlog item 39 that the user played 1.4.3 from their own saves, and fold the done shader work into its summary
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 20:03:30 +03:00
Valiantsin DzerakhandClaude Opus 5.5 d6e5b78252 Prepare every game shader's default variant and the shader list rows MacNativeGames pruned
MacNativeGames now translates each shader's default bind state when it builds and keeps only other variants in its
shared list, so the list at origin/HEAD has 134 rows of 1.4.3 shaders. prepare_shaders.py seeds the default variant of
every shader it finds and reads the list through tools/shader_list.py, which adds the V rows older revisions held. On
1.4.3 that prepares 29,587 variants in 7 min with 0 translation failures, and every one of the 1,095 variants the field
and intro runs met in play is among them. The installer's dev path and make_release.py read the list the same way.

Also record that 1.2.1 loads saves 1.4.3 wrote.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 19:53:16 +03:00
Valiantsin DzerakhandClaude Opus 5.5 20ee7152ad Document 1.4.3 as a second build target: AGENTS.md commands, backlog item 39 with what is open, architecture
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 19:30:24 +03:00
Valiantsin DzerakhandClaude Opus 5.5 b245b07722 Let the installer build from the 1.2.1 or the 1.4.3 update
The check identifies the update by hash among layout.SUPPORTED and records it in totk-install.json; an install that
records none is 1.2.1. Extraction, lifting, compiling and preparing take the version from there: the patch table and
expected hashes per version, build_game.py --version (rt_game_version), make_romfs_patches.py and prepare_shaders.py
--version. Step keys of a 1.2.1 install stay as they were, so updating such an install does not extract again. Another
update file than the recorded one plans the extraction again (a copy of the same file is recognised by its hash), and
an identified version change re-plans every step after the check. The disk space estimate takes the larger RomFS.
Catalog strings name both versions and take the version as a parameter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 18:18:20 +03:00
Valiantsin DzerakhandClaude Opus 5.5 c757a42798 Add the frame rate overlay: TOTK_PERF_OVERLAY fps shows the frame rate in the top right corner, full adds the mean and longest frame time of the last half second, F10 cycles the modes and saves the choice
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 10:50:45 +03:00
Valiantsin DzerakhandClaude Opus 5.5 f2db724631 Grey out the performance overlay row until the overlay exists, and list what the menu still lacks in the backlog
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 10:31:45 +03:00
Valiantsin DzerakhandClaude Opus 5.5 7d33982123 Drop the UHD 630 ASTC remark and the guess that image aliasing causes the black patches, which no code, commit or log confirms
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 09:00:09 +03:00
Valiantsin DzerakhandClaude Opus 5.5 ac75fecc41 Trim the README to a front page: short status, features and build steps, with bug lists, measurements and design detail left to the backlog and the architecture doc, and mark the UHD 630 ASTC path as unverified
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 08:59:18 +03:00
Valiantsin DzerakhandClaude Opus 5.5 283e1f18cf Bring the published docs up to date for the public repository
The README now names the three test machines, the installer, remapping and the mouse camera, and lists the open bugs. The backlog drops the dated diary, finished steps and local paths and keeps every open item with its evidence. Citations into our code name functions instead of line numbers that had drifted, build/ notes are no longer cited, and the toolchain doc lists opus and libvpx.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 08:53:19 +03:00
Valiantsin DzerakhandClaude Opus 5.5 31b864380f Keep the replay on the submitting thread unless TOTK_REPLAY_ASYNC=1, since no timing showed a gain yet, and list async_preempt and replay_async in totk.ini.example
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 08:23:27 +03:00
Valiantsin DzerakhandClaude Opus 5.5 dd4b28b400 Merge main into task/preempt
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 08:19:18 +03:00
Valiantsin DzerakhandClaude Opus 5.5 a220b89459 Collect the open work in one list in docs/backlog.md, read the shared shader list's "*" texture kind as 2D, and record measurements from the other test machines
The backlog gets one "Open work" section: freezes, bugs (the Yunobo fade with its repro), machine items and paused
branches. prepare_shaders.py no longer stops on the "*" and "*_depth" texture kinds of the newer list revisions.
The playbook records the GTX 1050 Ti, RTX 3090 Ti and 8th-gen i7 numbers and how to get a perf log from those
machines; port-lessons gains the MacNativeGames virtual-core preemption row; totk.ini.example lists mouse_sens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 08:16:10 +03:00
Valiantsin DzerakhandClaude Opus 5.5 5eb60404a2 Describe the asynchronous preemption of virtual cores in docs/architecture.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 08:01:21 +03:00
Valiantsin DzerakhandClaude Opus 5.5 dc3a0e906a Reserve one pipeline worker for waiting draws' libraries only at the default TOTK_PIPE_WAIT, so TOTK_PIPE_WAIT=draw restores the old scheduling
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 19:00:06 +03:00
Valiantsin DzerakhandClaude Opus 5.5 2790f7d0e2 Keep render-thread call chains in the sampling profile and report inclusive time and driver callers from them
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 12:40:49 +03:00
Valiantsin DzerakhandClaude Opus 5.5 b8ecf1d937 Document the mem: class and mem: dirty lines in the agent playbook
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 00:17:27 +03:00
Valiantsin DzerakhandClaude Opus 5.5 02158f3f46 Quote paths with spaces on the Ninja command lines of build_game.py
An install folder with a space in its name (or a user name with one) made the compile step fail: clang split
-I temp/Игра TotK-<hash>/gen at the space. Include, library and tool paths and the link map path are now quoted when
they hold a space.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 19:59:02 +03:00
Valiantsin DzerakhandClaude Opus 5.5 7880790b91 Merge main into task/unicode
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 19:42:42 +03:00
Valiantsin DzerakhandClaude Opus 5.5 a4bb2d5355 Document the UTF-8 manifests of hactool and totk.exe and the damaged file message
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 19:35:41 +03:00
Valiantsin DzerakhandClaude Opus 5.5 94d5367040 Log GPU time per frame, VRAM, process RAM and a bound verdict in the perf line, and a pool census
Each submission part writes a timestamp pair under TOTK_TRACE=perf; the completion thread reads it and sums the busy
time without double-counting overlap. A second 60-frame perf line carries GPU ms per frame, fence waits of the render
thread and of other threads, VRAM usage and budget (VK_EXT_memory_budget, else the allocator's own blocks against the
heap size), working set and private bytes, and bound: gpu, cpu or pace. Devices without timestamp bits or a timestamp
period log one line and show gpu n/a.

vk_mem_resolve now reports the pool class of a span. The replay counts bytes bound or copied per class and use, and
vk_mem_census logs the live pools by kind and flags with that traffic at frame 1800 (every 1800 frames with perf).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 19:17:24 +03:00
Valiantsin DzerakhandClaude Opus 5.5 0beafeb066 Write GPU-rendered textures back when the CPU invalidates a pool range or waits for a fence
nvn_pool_invalidate was a weak no-op, so nvnMemoryPoolInvalidateMappedRange never wrote anything back. TotK
invalidates its 260x260 R16 grass maps and 1x1 targets before reading them; they now go through guest_read.

The grass system also renders a 128x128 RGBA8 cut map into a CPU-cached pool every frame and reads it with no
invalidate. Without its texels the CPU saw no cut: swings left the grass standing, with no blades and no insects.
After nvnSyncWait or nvnQueueFinish, dirty mirrored targets up to 64 KiB rendered in a submission up to the waited
fence go back to storage (cpu_synced, vk_texture_write_back_small), unless the CPU rewrote it since.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 10:41:54 +03:00
Valiantsin DzerakhandClaude Opus 5.5 3505258a06 Merge the installer: setup steps, window, launcher and release bundle
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 10:04:19 +03:00
Valiantsin DzerakhandClaude Opus 5.5 5c1626e7ac Build TotK-Setup.exe, write VERSION, copy installer/ and totk.ini.example into the release and run a check-only installer pass and the window selftest on the bundle
clean_env compared the upper-cased os.environ keys with mixed-case names and dropped SystemRoot, which crashed Tk in the bundled python.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 09:19:02 +03:00
Valiantsin DzerakhandClaude Opus 5.5 e8697659ac Remap gamepad buttons and keys with bind_<button> lines in totk.ini, one data-driven table for the pad and one for keys
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 08:50:48 +03:00
Valiantsin DzerakhandClaude Opus 5.5 9151cef0f5 Map the release's deps to runtime/deps and document the installer command line, events and the real peak disk space
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 08:41:50 +03:00
Valiantsin DzerakhandClaude Opus 5.5 cb9ea1ae05 Release the mouse cursor with Esc, recapture on a client click and skip capture when a title bar click activates the window
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 08:29:49 +03:00
Valiantsin DzerakhandClaude Opus 5.5 227ed0f680 Plan the installer that builds the game from the player's own files
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 08:06:04 +03:00
Valiantsin DzerakhandClaude Opus 5.5 dc80c88490 Add the PC keyboard and mouse layout with a data-driven binding table and a raw-input mouse camera
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 23:26:45 +03:00
Valiantsin DzerakhandClaude Opus 5.5 dda22f6e01 Add rumble strength, curve and trigger settings for Xbox pads
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 23:12:15 +03:00
Valiantsin DzerakhandClaude Opus 5.5 2d714537e7 Run agent tasks in git worktrees
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 23:08:22 +03:00
Valiantsin DzerakhandClaude Opus 5.5 19c9b648d1 Add the recompiler, Windows runtime, tools and docs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 22:27:54 +03:00