Commit Graph
163 Commits
Author SHA1 Message Date
Wellington Dias aa030e4e28 Give 1.4.3 the aspect patch, so it draws 16:10 and 21:9 like 1.2.1.
The 1.4.3 sites, found by their code: the camera parameter reader's DefaultAspect default (main+0x1aa0ac4, the default
at main+0x2d06910), the two camera-viewport updates (0x1ff04f4, 0x253fbb0, where the division becomes the page load
because x9 is free after the dirty-flag store) and two of the 2D canvas-size loads (0x2136fa8, 0x213641c). Three of
1.2.1's five canvas loads have no match yet; switching them off on 1.2.1 left the gameplay HUD and the system menu
unchanged at 21:9. At 16:10 and 21:9 the 1.4.3 title and gameplay show a round emblem, an unstretched world and the
HUD at the screen's edges.
2026-10-29 23:05:30 -03:00
Wellington Dias 119884c52e Bias gather coordinates on non-NVIDIA GPUs, so shadows lose the dashed lines along edges.
AMD and Intel round a gather coordinate that sits between two texels the other way from Maxwell, so shadow-map
filtering picked the neighbouring texel and drew dark dashes along wall and floor edges that moved with the camera
(docs/maxwell.md 2.10; BotW had the same on AMD). vk_caps.c passes the device's subTexelPrecisionBits to the translator
for every non-NVIDIA GPU, the job carries it as gather_bias, and totk_xlate answers QueryHostGatherBiasPrecision with
it, which turns on Ryujinx's own coordinate bias (TexturePass.InsertCoordGatherBias). The answer joins the translator
identity, so those shaders get their own cache keys. TOTK_GATHER_BIAS=0 turns it off.
2026-10-29 22:32:40 -03:00
Wellington Dias f3ab1b0e76 Give the camera and interface the output's shape on 1.2.1, so 16:10 and 21:9 are not stretched.
The aspect patch set (recomp/patches-v121.txt) makes the world camera's DefaultAspect parameter default, the two
camera-viewport updates that divide a 16:9 rectangle, and the five loads of the 2D canvas size read the patch page.
resolution.c writes the output's aspect and the canvas factors there (wider than 16:9 the canvas grows in x, narrower
in y) and switches the set on when the game resolution is not 16:9. The sites are those of Fruithapje21's
TOTK-Ultrawide 1.2.1 patch (GPL-3.0, read for behaviour); a heap scan of the live projections confirmed the four world
cameras take the new aspect. The interface keeps its 16:9 layout in the middle of the canvas: the per-layout edits
that move it to the screen's edges are not done.

A version without the set (1.4.3 for now) draws the largest 16:9 size inside the wanted one, letterboxed. The Steam
Deck profile now draws the screen's own 1280x800, and the menu offers 16:10 and 21:9 game resolutions.
2026-10-29 22:20:59 -03:00
Wellington Dias 2f78585b4c Add a Steam Deck profile and keep the picture's proportions on screens of another shape.
The present fits the game's picture into the largest centred rectangle of its own aspect ratio and clears the rest to
black (gfx_fit_rect, through both the blit and FSR), so a 16:9 game on the Deck's 16:10 screen is no longer stretched;
picture_fit = stretch keeps the old fill. probe-window checks the bars as well as the picture.

device_profile = auto|desktop|deck: on a Steam Deck (the firmware's Valve Jupiter or Galileo board, or SteamDeck=1) the
keys totk.ini does not set default to fullscreen, a 1280x800 window, a 1280x720 game resolution, the game's own scene
scale, vsync and a 40 fps limit; the environment and totk.ini still win. These are starting points until measured on
the device (docs/tester-guide.md, Steam Deck).

Both stick clicks (L3 + R3) step the performance overlay as F10 does, for a controller with no keyboard. The menu offers
1280x720 and 1600x900 game resolutions and 40, 45 and 90 fps limits.
2026-10-29 18:14:30 -03:00
Wellington Dias 29a14d69fe Build the setup for Linux as an AppImage.
tools/make_release_linux.py assembles the Linux release folder and packs it with the static type-2 AppImage runtime:
python-build-standalone 3.14 with tkinter, LLVM 23.1.4 (clang, lld, llvm-ar) and the part of the Steam Runtime 3 sniper
SDK sysroot a game build reads, so the game, hostcheck, hactool and the translator need no newer glibc than 2.31 and run
on SteamOS. The game it builds needs only glibc, the system's Vulkan loader and the libSDL3.so.0 beside it; Opus, libvpx,
zstd and libstdc++ are linked in. --prove builds generated/v121 with the folder alone and runs the probes.

The installer runs on Linux: release and dev layouts, temp under the XDG cache (the AppImage mount is read-only), cancel
through the CLI's process group, language from LANG, xdg-open and a PNG icon, texts that name the right executable, and a
warning on kernels older than 6.7. hostcheck reads x86-64-v3 from CPUID, since clang's __builtin_cpu_supports reads it
from libgcc, which before GCC 12 has no level bits. build_game.py takes --sysroot, build_hactool.py --cc and
build_xlate.py --llvm/--sysroot; linux.c carries the Linux 6.7 write-watch definitions for older headers.

Also: shader_census.py and package_build.py use the Linux executable names, and probe-shader writes its shader path with
forward slashes.
2026-10-29 18:00:26 -03:00
Wellington Dias 5a84b19476 Give CPU-visible pools shadow storage on Linux, so the game renders and plays.
On Linux, write-protecting memory the GPU imported costs milliseconds per submit and the import's pinning clears the
write watch, so each CPU-visible pool gets a host-visible copy instead: the pages the CPU wrote since the last sync go in
right before each submit (skipping bytes the GPU still has to write back), and the replay's GPU writes are copied back
into guest memory at their fence (vk_gpu_written). In 1.2.1 play it costs about 0.2 ms a frame. TOTK_SHADOW=1 turns it
on under Windows too.

Also: build_game.py fetches the VMA header the Windows release pins when the system has none; plat_localtime and
plat_gmtime reject the times Windows rejects; the SDL text entry honours TOTK_SWKBD_TEST=cancel; probe-vkmem follows
the replay's protocol for GPU writes and syncs.
2026-10-29 17:29:31 -03:00
Wellington Dias 1d51343ac1 Build and run the runtime natively on Linux.
Shared runtime code now goes through runtime/platform/platform.h, implemented by platform/win32.c and a new
platform/linux.c: futex locks, a userfaultfd and PAGEMAP_SCAN write watch, signal-based async preemption, our own
fiber switch, and a SIGSEGV handler for the thaw and crash hooks. The window, input, menu and software keyboard get
SDL3 back ends beside the Win32 ones, with the swapchain (gfx_present.c) and input merging (input.c) shared. SHA-256
replaces BCrypt, ELF builds get their own override sections, and the build tools gain Linux branches.

On Linux the selftest and the gfx-abi, astc, nvn and window probes pass. probe-vkmem still fails: imported guest
memory cannot be write-watched on Linux, which the shadow buffers in vk_memory.c will address.
2026-10-29 16:56:56 -03:00
Valiantsin DzerakhandClaude Opus 5.5 8691f6d724 Remap keys, mouse buttons and controller buttons from the Controls tab
Every Switch button and the eight stick directions the keys drive get two key cells and a controller cell under the
button layout. A cell takes the next key, mouse button or controller button pressed; a key in use moves over, a
controller button swaps. The tab writes bind_ lines (new: bind_LSTICK_* / bind_RSTICK_*, key:default, pad:default) and
input_win.c builds the tables again when one changes, so remapping applies while the game runs. More keys can be
bound: Enter, Backspace, right Shift and Ctrl, Alt, the numpad, punctuation, F2-F7, F9, F12, mouse buttons 4 and 5.
Alt alone no longer enters the window menu loop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 17:53:57 +03:00
Valiantsin DzerakhandClaude Opus 5.5 ba0f33e044 Pick the gamepad button layout by the pad's labels, with a Button layout row on the Controls tab
The gamepad map was by position only, so on an Xbox pad the button labelled A pressed Switch B. pad_layout = auto
(default) keeps the Nintendo layout for a pad whose east button SDL reports labelled A and uses the Xbox layout (south
A, east B, west X, north Y; cross A on a PlayStation pad) for the others; nintendo and xbox force one. It applies at
once; bind_ lines name physical buttons and apply on top of either layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 17:20:03 +03:00
Valiantsin DzerakhandClaude Opus 5.5 ce150130df Make code comments say what they mean instead of pointing at things a reader cannot follow
Comments cited codes from local notes (port-lessons P1, backlog), task labels (T6c1-T6c3, M4), bare upstream commit
hashes and issue numbers, a file that no longer exists (nvn_api.c, now nvn_api_*.c), a generated file (main_0103.c)
and line numbers into upstream files that refs/ has moved past, so they pointed at unrelated code. Those now name the
file, function or project and say what the cited code does. Attribution of copied code keeps its pinned commits.

Corrected facts: TOTK_REPLAY_ASYNC defaults to 0, and the shader cache, pipeline cache and pipeline keys live next to
totk.exe, not in build/v121.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 12:58:01 +03:00
Valiantsin DzerakhandClaude Opus 5.5 d3fd4c5944 Call the replay "GPU frame prep" in the menu and the overlay, say it adds up to one frame of latency, and name GPU time "GPU busy per frame"; the run_game.py example runs build/v121
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 12:49:34 +03:00
Valiantsin DzerakhandClaude Opus 5.5 c7b290f2b0 Write the log of a game run to logs\totk.log next to totk.exe when stderr is not a file
A player who starts totk.exe from Explorer or a shortcut had no log to attach to a report: the log went only to stderr.
A game run whose stderr is not a file (a console or a pipe) now also writes logs\totk.log, keeps the four earlier
runs as totk.1.log to totk.4.log, and stops the file at 64 MiB. Runs whose stderr is a file (run_game.py, 2> file) and
the tool modes write no extra file. Lines from before the file opens (mem_init comes first so the CRT heap stays out of
the guest address space) wait in a static buffer.

Crash reports, fatal errors, IPC and SVC diagnostics, guest debug output and the boot: lines now go through
rt_logf / rt_log_raw, so they reach the file too. Open log folder in the menu opens the folder of the file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 12:41:12 +03:00
Valiantsin DzerakhandClaude Opus 5.5 f4619f7b45 Add a VERSION file with the port's semver, shown beside the installer title and on the game menu's title line with the game update
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 11:40:01 +03:00
Valiantsin DzerakhandClaude Opus 5.5 4e764cd39a Take world-clock windows in TOTK_PROFILE_FRAMES and TOTK_CRIT: w<lo>-<hi> is seconds of game time since the save loaded, so a profile or critical-path session covers the same play at any frame rate instead of a present range that lands elsewhere on a slow machine
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 08:56:50 +03:00
Valiantsin DzerakhandClaude Opus 5.5 b35f66207f Merge branch 'main' into task/wwatch
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 08:35:10 +03:00
Valiantsin DzerakhandClaude Opus 5.5 1274fb65d8 Read totk.ini in mem_init before the pool size: the size asks resolution.c, which decides output_res and render_scale once on that first call, and main read the file only after mem_init, so both settings from totk.ini and the menu were ignored and only TOTK_* environment variables reached them
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 21:45:48 +03:00
Valiantsin DzerakhandClaude Opus 5.5 1f7d80306e Freeze idle regions that also hold memory outside NVN pools, and freeze after 60 idle submissions instead of 300
Write-watch queries skip frozen 2 MiB regions, but a region was frozen only when it lay wholly in imported pools and
wholly committed. NVN pools are small and not 2 MiB aligned, so most regions also hold other guest memory or reserved
holes: in town 340 of the 436 MiB queried every frame lay in regions nothing had written for 300 submissions. On the
GTX 1050 Ti laptop the queries took up to 2.2 ms a frame, 1.4 ms of it in queries that found no write.

mem_freeze now makes the committed pages of a region read-only when all of them are read-write and leaves reserved
holes alone; thaw_locked already restored such regions run by run. The pool rule is gone: the only kernel writes into
guest memory are file reads, which thaw their buffer first, and every user-mode write faults and thaws as before.
TOTK_FREEZE_IDLE defaults to 60 (in a fight 100 of 257 queried MiB lay in regions idle for 30-299 submissions; a thaw
by a write costs about 60 us on the RX 9070 machine), and import mode freezes too, for the texture checks of APUs.

RX 9070, per frame after load: town 436 -> 96 MiB queried, 0.68 -> 0.38 ms; fight 168 MiB, 0.45 ms (257 MiB, 0.57 ms
with the new rule at 300 submissions), about 20 thaws a second. TOTK_MEMORY=verify in the fight: 3.65 million pages compared, 0 mismatches. The gfx-abi probe
covers a region with reserved holes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 21:22:30 +03:00
Valiantsin DzerakhandClaude Opus 5.5 3af201b43b Bind uniform blocks from a copy taken when the submission starts recording
TotK rewrites per-object uniform blocks on other threads soon after it submits the frame that reads them, and the
replay records for milliseconds after the submit call, so late draws could read another object's matrix (phantom
rocks, a flat far field). The guard in nvn_api_core.c obs_release_read only knows 1.2.1's producer. runtime/vk_usnap.c
copies every uniform range of imported pools that the submission binds into an arena, after MacNativeGames'
TOTK_UBO_SNAPSHOT, and ubo_info binds the copy; ranges a submission still in flight writes are left out, and GPU writes
within the submission drop the copies they touch. TOTK_UBO_SNAPSHOT=0 binds live memory; =ab alternates.

Town on an RX 9070 (in-launch A/B, 70 s): 2235 ranges, 1.9 MiB per submission in 0.49 ms; interval +0.02 ms, replay
+0.19 ms. The sort of the ranges was half of the cost with qsort (0.53 ms for about 10,000 bindings) and is a radix
sort now. fight2 interval within noise. The four probes passed on 1.4.3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 20:25:40 +03:00
Valiantsin DzerakhandClaude Opus 5.5 c2943970cc Merge the spin wait gates: they also end the fight hangs
The generator emits a guest poll such as `ldr w9, [x19]; cmp w9, #1; b.eq` as a plain C load, and clang hoists it out
of the loop: the lock wait in f_7001fa0e2c compiled to `cmp; jne; jmp .`, so a thread that found the lock held spun
forever after its holder released it. A fight run hung this way in 3 of 13 launches on an RX 9070, with the UBO
snapshot on and off; gdb showed the thread on that `jmp` in every sample. The gate is an opaque call on every
back-edge of the 868 loops tools/spin_waits.py lists, so each pass reloads memory: the exe goes from 182 self-jumps to
148, and 144 of those are the game's own `b .` instructions. 8 of 8 fight runs then passed; tests/diff/func.py with
--patches passed 5470 cases on 878 functions, and the four probes passed on 1.4.3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 20:05:44 +03:00
Valiantsin DzerakhandClaude Opus 5.5 1f4c6fcdb5 Decode the game's zstd frames with the host's libzstd: the patch set zstd (TOTK_ZSTD_NATIVE, on by default) sends the calls of ZSTD_decompressMultiFrame and ZSTD_decompress_usingDDict in main to runtime/ov_zstd.c, which makes host dictionaries from the guest DDicts, gives the virtual core up for inputs of 64 KiB and more, and leaves in-place decodes and every error to the guest decoder
The lifted decoder ran its copy loops as chains of small functions. On the island and fight routes TOTK_ZSTD_CHECK=1 decoded every call both ways with no difference; the host took 0.72 s where the guest decoder took 1.99 s. Load time and fps on an RX 9070 and a 7900X did not change: the gain is CPU time on the loading threads, for machines with fewer cores. The caller at main+0x547a04 stays on the guest decoder: it resets a static DCtx with which the game's zstd rejects some frames libzstd decodes, and the game relies on that result.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 18:27:12 +03:00
Valiantsin DzerakhandClaude Opus 5.5 4e9322730d Log the load time with the world clock start: the line now says how many seconds after the guest started the world clock began, so load times compare across runs without the presents count
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 18:27:11 +03:00
Valiantsin DzerakhandClaude Opus 5.5 72253abcc0 Run and measure by game time instead of presents: totk.exe --seconds S ends a run once the world clock passed S seconds (run_game.py --seconds, regress.py routes in world seconds), TOTK_AB blocks are seconds of world clock, the perf line carries the world clock, and TOTK_SHOTS=w<lo>-<hi>:<step> takes shots by it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 16:51:36 +03:00
Valiantsin DzerakhandClaude Opus 5.5 3fb4b8d4b9 Make the replay's Vulkan calls on a recorder thread: each vkCmd* into the replay command buffer becomes a packet in a ring that the recorder makes in order, every other command buffer is called at once, and the submit waits for the ring to empty. Town on an RX 9070: replay 9.98 -> 8.29 ms a frame (in-launch A/B), no new validation messages, same picture
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 16:41:46 +03:00
Valiantsin DzerakhandClaude Opus 5.5 48dfe0cfdf Measure a change within one launch: TOTK_AB=<presents> alternates A and B blocks (A B B A), a switch set to ab is on in the B blocks, and tools/ab_summary.py compares the perf windows of each side; TOTK_ONE_PER_CORE=1 keeps one logical processor per physical core (off: no gain on a 7900X)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 16:41:46 +03:00
Valiantsin DzerakhandClaude Opus 5.5 166e5a7b7d Drop released textures oldest first, one per release past 2048, instead of all of them once the count passed 4096: that sweep destroyed thousands of images in one frame, 333-422 ms frames every 40-50 s on a GTX 1050 Ti, and the textures still in use came back as new images and uploads
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 15:14:11 +03:00
Valiantsin DzerakhandClaude Opus 5.5 01dfe5d5a6 Take staging buffers from a VMA pool of their own that keeps two 64 MiB blocks from boot: in the default pool a block made by the headroom thread or by a burst of uploads held the render thread's staging allocations under the memory type's lock, 47-50 ms for one in the first frame after a save load (that frame 138 -> 70 ms)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 15:06:40 +03:00
Valiantsin DzerakhandClaude Opus 5.5 41f201ad39 Skip full-screen draws while their pipeline builds by default (TOTK_PIPE_SKIP=fullscreen): in a fight a full-screen pass whose stage libraries were cold in the driver cache held three frames in a row at 64-72 ms, each spending the 50 ms wait budget, and some draws were skipped after all
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 15:02:18 +03:00
Valiantsin DzerakhandClaude Opus 5.5 9dc738c045 Count untimed script lines in 60 Hz ticks of game time instead of presents, so the title menus get scripted presses at the same game time at any frame limit; in a recording the untimed lines stop when the world clock starts, and the recorder cuts a button or stick held at that moment and continues it as a timed event
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 14:49:41 +03:00
Valiantsin DzerakhandClaude Opus 5.5 5da6c5bb89 Merge the frame critical path recorder: TOTK_CRIT=<first>-<last frame> with TOTK_TRACE=sched writes the guest threads' state changes and wakes, read by tools/crit_path.py
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 14:13:40 +03:00
Valiantsin DzerakhandClaude Opus 5.5 2fe6a6d4c1 Keep MXCSR in line with FPCR where FPCR changes instead of checking it in every FP op
The FP helpers compared c->fpcr with a cached copy before every operation to resync MXCSR lazily. MXCSR now
follows FPCR.FZ at once: MSR FPCR calls rt_fpcr_sync, and so do rt_call (thread, fiber and host entry into guest
code), fiber resume (FIBER_FLAG_FLOAT_SWITCH fibers keep their own MXCSR) and the differential test harness per
case. op and vop only test FPCR.RMode for the slow path, and their redo check is one ordered-not-equal compare of
|r| with the smallest normal, the same NaN-or-smallest-normal set as before.

Hot guest code shrinks by about a quarter (132 functions holding half the guest cycles, 1.4.3); fight frame time
moves 1-3%, inside the run-to-run spread. lift, simd, func, atomic and flags_check pass on 1.4.3; simd.py fails
without the harness sync.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 12:25:25 +03:00
Valiantsin DzerakhandClaude Opus 5.5 ba52fe6e89 Record the critical path of the frame with TOTK_CRIT
With TOTK_TRACE=sched, TOTK_CRIT=<lo>-<hi> records every state change and wake of the guest threads and every
present over those frames (runtime/kernel.c crit_add from acct() and wake(), crit_frame at the present) and writes
them to TOTK_CRIT_OUT at the last frame. tools/crit_path.py walks back from each present through the waits to the
thread whose signal ended them and splits the frame interval by thread and state; the sums equal the interval.

A 1.4.3 fight: with the replay on the submitting thread the path is 7.3 ms of replay on the render thread and 4.3 ms
of guest code; with TOTK_REPLAY_ASYNC=1 it is 10.1 ms of guest code through the fork-join of the main thread and five
workers, at the same frame interval.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 09:26:07 +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 101f2c8b5e Give the virtual core up in nn::fs host functions and in NVN memory pool setup, as the Switch blocks those threads in IPC: the game's loader threads held a core through CloseFile, CreateCacheStorage and nvnMemoryPoolInitialize (up to 20 ms) while job workers waited. Core diagnostics now also report waits on an owner in a host call, with its module, offset, latest SVC and guest lr, and the AllocateMemoryPages and AllocateAddressRegion lines need TOTK_TRACE=host
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 16:42:14 +03:00
Valiantsin DzerakhandClaude Opus 5.5 5b783728e5 Count NVN calls per thread and add them to the shared counter 1024 at a time: the main thread and the job workers record command buffers, and a locked add per call kept the counter's cache line moving between their cores
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 16:29:32 +03:00
Valiantsin DzerakhandClaude Opus 5.5 8e15d70fd4 Scale the performance counter by a fixed-point multiplier set before main: plat_now_ns and rt_ticks divided a 128-bit product by the counter frequency on every call, and __udivti3 took 5% of the game's running samples
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 16:22:11 +03:00
Valiantsin DzerakhandClaude Opus 5.5 acd550e822 Merge the VRAM headroom: a background thread allocates the next VMA block of each memory type before the render thread needs it (vk_headroom.c, TOTK_VRAM_HEADROOM)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 16:09:38 +03:00
Valiantsin DzerakhandClaude Opus 5.5 d1149e5060 Allocate the next VMA block of each memory type on a background thread: a new block made by another thread wakes vk_headroom.c, which allocates half a block every 500 ms and keeps it as the anchor of a block it had to create, so the render thread finds room instead of calling vkAllocateMemory for 8-19 ms; no headroom above 85% of the VRAM budget (TOTK_VRAM_HEADROOM)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 16:05:24 +03:00
Valiantsin DzerakhandClaude Opus 5.5 bac4d6cf91 The shader memo skips its 1 KiB handle compare while no texture or image was bound
memo_match compared the vertex and fragment stages' 64 texture and 64 image handles on every draw. Every OP_BIND_TEX and now every OP_BIND_IMG bumps tex_serial; a key whose serial is current has the same handles, and a key that matched by the compare takes the current serial. memo_match went from 0.95% to 0.27% of the fight replay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 15:54:00 +03:00
Valiantsin DzerakhandClaude Opus 5.5 c238c341c7 Replay command buffer parts span at least a millisecond of recording
A fight frame of about 2,000 draws made 15 parts on the 7900X at 64 draws a part, each split costing the render thread a submit, a new command buffer and a mirror prologue (vk_sync_split, 7.6% of the replay). maybe_split now also waits until TOTK_SPLIT_US (1000, 0 off) has passed since the part began, so a frame makes 7-9 parts there. A millisecond of recording is well under a millisecond of GPU work, so the GPU still starts early in the frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 15:53:59 +03:00
Valiantsin DzerakhandClaude Opus 5.5 c9c06f2501 Render target views of registered textures live as long as their image
vk_exec_pass_begin created every attachment view again in each submission and freed them at its fence: 2% of the fight replay on the 7900X, more on drivers with a slower vkCreateImageView. view_of now takes the view from vk_exec_target_view, which keeps it in the sampled-view tables under the texture lock, and vk_exec_image_gone releases it with the image. Images that are not registered textures keep the per-submission views.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 15:53:59 +03:00
Valiantsin DzerakhandClaude Opus 5.5 3984344635 Spin wait gates: tools/spin_waits.py (the nxnative search) lists the loops that only another thread can end, the patch tables carry them as spin lines (857 in 1.4.3, 864 in 1.2.1), the generator sends their back-edges through rt_spin_gate, and the gate pauses the core once per pass and hands the virtual core to a waiter after 50 us of polling (TOTK_SPIN, TOTK_SPIN_HANDOFF_US)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 15:51:47 +03:00
Valiantsin DzerakhandClaude Opus 5.5 403606bbcb The settings menu draws over the performance overlay while it is open
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 15:24:14 +03:00
Valiantsin DzerakhandClaude Opus 5.5 89cc960f09 Menu navigation with the left stick and back from the bottom buttons; AMD sensors and the picture lines in the performance overlay
The left stick now moves the menu cursor as the D-pad does (ImGui only scrolled with it). The page's rows are a
direct NavFlattened child of the menu window: behind a second child level ImGui did not clip them, so up from
Continue went to the tabs and down from the tabs to Continue.

The full overlay reads temperature, board power, clock and GPU load from ADL's PM log on AMD GPUs (matched by PCI
bus), and shows the window, game image and 3D scene sizes, the scaling to the window (FSR and its sharpness), the
frame limit and the presentation mode in use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 15:21:41 +03:00
Valiantsin DzerakhandClaude Opus 5.5 eca89641fa Keep 1.2.1's scene at the wanted size, package zstd for the installer
1.2.1 renders the scene size it reads, while 1.4.3 scales it by output width / 1920: on 1.2.1 the scene set is on
whenever the output grows (2560x1440 gave a 1600x900 scene before, 2133x1199 now). An output at or below the shipped
size needs no grown HeapDef. The release deps carry the static libzstd and its header, totk.ini.example the four new
keys, THIRD_PARTY_NOTICES.md the MacNativeGames sites, FSR 1 and zstd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 13:56:28 +03:00
Valiantsin DzerakhandClaude Opus 5.5 7abdbc90ac Render the game above 1080p and scale it to the window with FSR 1
The output and scene patch sets make the game read its output, swapchain and scene sizes from the patch page
(MacNativeGames' sites for 1.2.1 and 1.4.3); resolution.c picks them from TOTK_OUTPUT_RES and TOTK_RENDER_SCALE and
grows the HeapDef texture heap, its parent and the application pool to match. vk_fsr.c runs AMD FSR 1 EASU and RCAS
on the present when the window is larger than the game's output (TOTK_UPSCALER, TOTK_SHARPNESS).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 13:40:34 +03:00
Valiantsin DzerakhandClaude Opus 5.5 97d3762ba1 Strip milestone and task labels from code comments and drop the dead gfx_stubs.c
Comments named the agent task (T1-T7, M2-M5, Task 2.x) that once owned each file or block, and pointed at local
notes the repository does not carry (backlog items, milestone plans, research notes). They now say what the code
does. gfx_stubs.c held weak stand-ins for functions that every build has defined for a long time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 13:12:50 +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 b12bbe7705 Merge the overlay width fix: the full overlay's frame time plot and wait table fill the panel, and the wait numbers end at its right edge
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 12:17:31 +03:00
Valiantsin DzerakhandClaude Opus 5.5 d5d8497825 Stretch the full overlay's frame time plot and wait table to the panel width, with the numbers on the panel's right edge
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 12:17:27 +03:00
Valiantsin DzerakhandClaude Opus 5.5 277c8484e7 Read every shader use mask file on a background thread at start, so the render thread opens none in play
Each draw's first sight of a program opened its <hash>.use file on the render thread (use_find from gfx_shader_get_async). The open takes 0.1 ms alone but took 11-40 ms in play behind the translator's and the pipeline cache's writes and flushes on the same volume (slow-present dumps of a 1.4.3 fight session). The 45131 masks of a prepared 1.4.3 cache load in about 12 s below normal priority, before the first save load ends; until then lookups read the file as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 11:40:33 +03:00