Commit Graph
8 Commits
Author SHA1 Message Date
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 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 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 51567ac32a Freeze idle pool regions read-only so write-watch queries skip them
The mirror and the texture checks queried about 930 MiB of write-watched memory per frame (0.96 ms on the RX 9070
machine, about 3 ms on an 8th-gen i7), at about 1 us per MiB, and 770 MiB of it lay in 2 MiB regions nothing had
written for two seconds. In mirror mode a region left unwritten for TOTK_FREEZE_IDLE submissions (300; 0 turns it off)
and lying wholly in imported pools is now made read-only (memory.c mem_freeze), and the snapshot and change queries
skip it. The first write faults and a vectored handler thaws the region before the write retries; file reads into
guest memory, which the kernel would refuse on a read-only page, thaw their buffer first and log a refusal, as do pool
init and finalize, and commits, decommits and protection changes thaw under the same lock. A region stays thawed for
5 s after a file read. Field: 66 queries over 380 MiB, 0.56 ms per frame; 0.38 ms of it are the queries that find
writes. The perf line `mem: write-watch` gives queries, bytes, time, frozen MiB, freezes and thaws. The gfx-abi probe
covers freeze, thaw by a write and the hold after mem_thaw. TOTK_MEMORY, TOTK_MIRROR_GAP and TOTK_FREEZE_IDLE are known
settings now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 08:39:47 +03:00
Valiantsin DzerakhandClaude Opus 5.5 1fe552ae0a Mirror buffer-bound pools in device-local memory on discrete GPUs
Imported pools put vertices, indices, constants and storage buffers in system memory, so discrete GPUs read them over
PCIe on every draw. A pool now gets a device-local mirror on its first use as a vertex, index, uniform, storage or
indirect buffer; bindings, buffer copies, fills and uniform updates use it at the same offsets. The first access of a
submission syncs the pages written since (write-watch snapshots shared with the texture checks, plus
nvnMemoryPoolFlushMappedRange ranges) in a prologue command buffer before the part; what the GPU writes into a mirror
goes back to guest memory at the end of the submission. TOTK_MEMORY=import|mirror|verify overrides the device class;
verify compares sampled mirror pages with guest memory at the fence. The vkexec probe gains a mirror part.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 00:45:56 +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