Commit Graph

562 Commits

Author SHA1 Message Date
Tobim6
8106fdaafd Keep the movie converter's helper threads instead of starting ten new ones per picture.
run_stripes started NSTRIPES - 1 threads for each of its two phases, about 300 new threads a second while a movie
played. Every DLL in the process sets itself up for each new thread; on an RX 580 with AMD's 23.10 driver the process
commit grew by about 300 MB a second during the title movie until Windows ran out of commit (45.7 GB, FATAL "movie:
out of memory for a 1920x1080 frame"). The helpers now start once and wait for each batch; one caller at a time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:21:42 +01:00
chrg6
ef3466ce4f Merge main into the 0.9.1 release: the launcher's Mods screen, the anti-aliasing choices beside FSR and DLSS, and the scene's last row and column filled before an upscaler reads it.
The 0.9.1 notes keep the release branch's text and take main's sections: New, the edge line under Fixed, and Changed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 09:00:37 -05:00
chrg6
baad032500 Keep the fast link's waits at 3 ms a pipeline and 6 ms a frame.
The 8 ms and 16 ms tried in their place left fewer draws out in a scripted walk, but in play a frame that takes 10 to 14 ms longer felt worse to the player than one that is left out, in two sessions on the same install. The wait stays counted once for each pipeline, and a frame that has left a draw out already still waits for nothing more.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 08:49:26 -05:00
chrg6
8a61fcacaf Stop waiting for fast links in a frame that has already left a draw out.
Such a frame is held back or shown without that draw whatever its other pipelines do, and with hundreds of pipelines new at once every frame of an area's load spent its whole 16 ms budget on waits that could not complete it: 49 frames over 25 ms in a walk with no pipeline recorded, against 17 with the earlier 3 ms waits. With the rule the same walk has 15, the picture stands still 15 times instead of 50, and 1 frame is shown incomplete instead of 22.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 08:35:47 -05:00
chrg6
9f7c8ae810 Wait 8 ms once for a pipeline met for the first time, and carry the compute variants in the pipeline list.
A draw that met a new pipeline waited 3 ms for its fast link, in every frame, which is just under what the link takes with the stage libraries in the driver's cache: in a first-visit session on a new install 66 of 87 such draws gave up at the end of the wait and their frame was held back. The wait is now 8 ms for each pipeline, counted from its first miss and shared by all its draws, and 16 ms for a frame, so a pipeline the driver has to compile costs one frame the wait and the frames after it nothing.

The pipeline list tool also takes the compute variants a game folder dispatched, which no pipeline record names and which were translated in the middle of play, and reads a list made before as one of its inputs.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 08:25:42 -05:00
epicmeme546
2d09c220bf Fill the scene's last column or row from the one next to it after a jitter to the left or up, before DLSS or FSR reads the scene.
With FSR 4 or FSR 3.1 a light line flickered along the bottom and right edges of the picture. The jitter moves the scene's viewport by under half a pixel, which keeps every pixel centre inside it. Yet on an RX 7900 XT, a viewport moved up left the last row undrawn in every scene pass, and one moved left the last column. A frame dump showed the depth's last row at its clear value and the light target's last row holding the fog's colour, which the upscaler blended into the edge. NX2NAVI_DLAA_EDGE_FILL=0 turns the fill off for testing.

Hyrule Field, 3416x1440, present screenshots: the outermost rows averaged 40 against 20 just inside without the fill, and within 1 of the inside with it. The same held with FSR 4.1 Native AA and Quality, FSR 3.1, SMAA and HDR. Jitter off, and no upscaler, gave no line either.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 08:23:25 -05:00
epicmeme546
1c654ba0c1 Let the Anti-aliasing row's Game SMAA, Off, FXAA and SMAA run together with FSR 4, FSR 3.1 or DLSS, and show the anti-aliasing in the performance overlay.
Choosing one of them while a temporal upscaler was set turned the upscaler off, and the picture fell back to bilinear scaling. vk_aa.c no longer keeps the game's SMAA while DLSS or FSR runs. The chosen pass replaces the game's composition as without them: in the native modes after the upscaler, and in the scaling modes before it. In the menu, a choice leaves the upscaler and frame generation alone, and the row notes that the upscaler's TAA runs too. Picking DLSS or FSR under Upscaling keeps the Anti-aliasing choice. The TAA entry, listed while no temporal mode is set, now sets FSR 4 Native AA where FSR 4 runs instead of forcing FSR 3.1. The overlay gets an Anti-aliasing line under Upscaling, for example "TAA + SMAA (Ultra)".

Checked on an RX 7900 XT in Hyrule Field with FSR 4.1 Native AA and Quality, and with FSR 3.1. The log has "the game's SMAA replaced by" smaa, off and fxaa while FSR 4.1.2 upscales, and the pictures are right.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 08:23:25 -05:00
chrg6
d31c3a1036 Make the water corrections in the runtime, on by default, instead of loading replacement modules from a folder.
The coordinate pair and the absorption guard needed modules made on each PC by tools/projective_recipe.py and a folder named in NX2NAVI_SPV_OVERRIDE, so no player had them. runtime/spirv_water.c makes the recipe's edits on the translation in memory, in the recipe's order: on the NVIDIA profile its three modules are byte for byte the recipe's (RTX 5090, game 1.1.1). vk_pipeline.c keeps the edited modules in a small table, made at first use, and builds a pair from them only when both of its stages were made; a module of another shape is built as it is, with a log line. NX2NAVI_WATER_PROJECTIVE=0 turns the corrections off. tests/water_projective_check.py compares the runtime's edits with the recipe's on made-up modules.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 07:55:57 -05:00
chrg6
56e142169c Merge main into the 0.9.1 release: the launcher's animations stopped behind another window, the uniform snapshot's copy split over the replay workers, and the replay workers' default of three with its measurements.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 07:29:41 -05:00
Sebastian Choperena
ee46a19ede Raise the limit of released textures by the card's video memory budget, from 2048 to 8192 entries (NX2NAVI_TEX_RELEASED_MAX). 2026-11-12 07:13:16 -05:00
TheShinySylveon
0cb2e6f00a Reserve no core for the recording thread by default
On an i9-14900KF (8 performance and 16 efficiency cores, 32 logical processors), with the replay on its own thread,
the core NX2NAVI_RECORDER_CORE=auto reserved (logical processors 14 and 15) left the woken replay thread unscheduled
for about 200 ms roughly once a second while the game stood in Kakariko. During each stall its queue held 40 to 50
items, its lock was free, the wakes had been sent and it used no CPU time, while a game thread waited on a fence of the
work in that queue: 27 frames a minute had a 150 ms or longer frame. With NX2NAVI_RECORDER_CORE=0 the same minute had
none. The default is now 0; auto and 1 still reserve the core, and the log says when none is reserved.
2026-11-12 07:12:41 -05:00
bct8925
6e87c921a1 Start a new DLSS history on a camera cut, and give frame generation the same new start.
vk_dlaa_fg_inputs handed frame generation a reset of 0 every frame, so it was never told of a new history: across an
area load, another scene size or another target it generated frames between two unrelated pictures. It now gets the
reset DLSS ran with on the same frame.

DLSS itself started a new history only for a lost camera, another scene size or another target, not when the camera
jumped. cam_cut takes a move over 5 m, or a turn over 10 degrees together with a move over 0.5 m, per 60 Hz frame
(scaled by the time since the last camera) for a cut, from camera traces of play in the Fire Temple: a median of
0.05 m and 0.08 degrees a frame, area loads of 5 to 180 m in one frame. NX2NAVI_DLAA_CUT=0 turns it off, and each cut
is logged, up to 24.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 07:12:16 -05:00
bct8925
20a1410023 Take a pass for DLSS's output only when it has the scene's shape.
Ocarina redraws its 2000x2000 area map into an RGBA8 target of its own on a room change and on the pause menu: one
colour target, no depth, larger than the scene both ways, which was all the output pass had to be. DLSS then wrote
the game's picture into the map (the log's "DLSS feature created at 1280x720 -> 2000x2000"), and the minimap showed
that picture behind its room shapes, a close-up of Navi or of Link from the moment of the room change, until the pause
menu drew the map again. A pass whose width over height is more than 3% from the scene's is not the output; the
first eight are logged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 07:12:02 -05:00
bct8925
ca75294126 Let a texture slot follow another texture at its storage only when the two are the same size.
When a slot's own entry was released, slot_resolve took any live entry at the same address, and Ocarina's per-frame
render targets share storage. The half-size ambient occlusion term (640x360 at a 1280x720 scene) followed the bloom
pass's 480x270 target there every frame: the blur that writes the term kept its top-left 480x270, the upsample stretched
that over the screen, and every contact shadow sat 1.33 times further from the top-left corner than its object (doubled
shadows below and right of Link, shadows of terrain out of view). During a hit effect the same slots followed its
1130x86 strip instead, the term read zero over most of the screen, and the right 44% of the scene went black.

Block-compressed formats keep the old rule, as a GPU encoder renders their blocks through a smaller view of the same
storage. The first eight refusals are logged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 07:11:46 -05:00
Leyukaka
0d564a21c0 Clear the stand-in images: sampled ones to mid grey, storage ones to zero.
The 1x1 images bound where a slot has no texture were only moved to GENERAL, so their content was undefined. A material that read its roughness map through one could see roughness near 0, and on Kakariko's distant cliffs at night the specular term reached 3392 in single pixels of the scene target, which bloom and the temporal upscaler spread into bright white spots. Sampled stand-ins now read as opaque mid grey (a middling roughness, a flat two-channel normal), storage stand-ins as zero.
2026-11-12 07:11:46 -05:00
epicmeme546
432b4e4b1c Turn the replay workers on by default: three of them record a frame's large draw groups beside the submitting thread.
On an RX 7900 XT with a Ryzen 7 5800X3D, Hyrule Field standing went from 41.2 to 50.4 fps in one batch, and the
pictures matched those with the workers off there and in Kokiri Forest, Kakariko, Goron City, a graveyard house and
Gerudo Valley. replay_workers = 0 in nx2navi.ini turns them off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 07:10:27 -05:00
epicmeme546
7eee4817f9 Split the uniform snapshot's copy over the replay workers at the start of a submission.
The workers have no chunk to record while the snapshot copies the uniform ranges a submission binds (about 700
regions, 0.7 MiB in Hyrule Field), so the replay thread now hands them slices of it through vk_exec_par, a loop the
workers take between groups. Without workers the copy runs on the replay thread as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 07:10:15 -05:00
chrg6
a13af7a8c2 Replace a water pair's vertex module before the vertex output union's additions, keep pairs with dual-source blending original, and log each replacement.
The paired modules were looked up by the hash of the module as built, so a vertex module that had outputs added for its union (which differs from one install to the next) or a fragment module changed for dual-source blending ended the run. The vertex replacement now stands for the translation itself and takes the added outputs as any module does; a pair with dual-source factors is built from its original modules in both stages.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 06:37:04 -05:00
ChurchOfIlias
37e8e6dbda Guard water absorption distance alongside paired coordinates
Add the exact-material nonnegative distance guard and the recorded NVIDIA translation profiles. Keep generated shaders and the private native patcher out of the repository. Document reported cross-vendor testing and the unresolved origin of invalid absorption distance.
2026-11-12 06:34:27 -05:00
ChurchOfIlias
d0d0112c3a Add an opt-in paired projective coordinate correction for water
Carry clip coordinates through perspective interpolation for the identified water shader pair. Keep generated modules private and document the observed results and remaining portability limits.
2026-11-12 06:34:27 -05:00
chrg6
2f39b27fb6 Record the draw replay on three replay workers by default, and start the draft notes after 0.9.0.
replay_workers = 0 records everything on the submitting thread, as before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 06:20:05 -05:00
chrg6
6ccd1e224d Build the shared pipeline list before play on every start, and build every listed pipeline at install.
A new install met every pipeline in play: in Hyrule Field one 600-frame stretch of a first visit had 1,769 draws wait 461 ms in all for pipelines, the longest frame 88 ms. The boot now reads seed-pipeline-keys.bin, the release's list, as recorded pipelines after the install's own (keys_open_seed, NX2NAVI_PIPE_SEED, default 1): their pairs go into the vertex output unions and the prewarm builds them as it builds the install's. The preparation builds every listed pipeline (NX2NAVI_PREPARE_PIPELINES now defaults to all), with the unions of the same list, so the first boot of a new install finds them in the caches. The list's mesh pipelines are left out at the boot on a GPU without mesh shaders, as the preparation leaves them out. Nothing of the list goes into pipeline-keys.bin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 06:19:39 -05:00
chrg6
4956ef8365 Let a finalized slot sample its own texture's image while that still holds the texture, not the stand-in.
The game finalizes texture objects on its own thread ahead of the replay, which still draws the frame the game recorded
before that; on the console the memory still holds the texels those draws read. Kakariko moves about 30 of its
textures to new addresses every four or five frames, and each move finalized the old descriptors. The replay's draws
of the frame before then met finalized CPU-written slots, and the stale rule gave them the stand-in even when their
own entry was still there with its content. The village's haze dropped out of a frame a few times a minute, and the
haze sprites that met a stand-in left hard-edged clear patches. A play session in Kakariko logged up to 4,805 stand-in
lookups in 60 frames, 1,826 in the 60 frames around one haze dropout, and 612 in the 60 frames after a run of
patched frames.

Such a slot now resolves to its own entry while that entry was uploaded or drawn by the GPU, and was neither superseded
by another descriptor at its address nor overwritten. The lookup samples the image as it is: it neither takes the
entry back nor reads its storage, so freed storage is still never read (the access violation the stale rule was made
for). NX2NAVI_TEX_STALE_KEPT=0 gives the stand-in again. The perf log's finalize line counts these lookups.

In a replay of a recorded Kakariko walk, most 60-frame windows went from stand-ins to the kept image (up to 328 a
window, stand-ins 0). In play, stand-ins remain in short bursts where the entry was already gone (up to about 2,000 in
60 frames, against the kept image in most windows). The tester still sees flicker that the 640x360 frame recorder
does not catch; that is not settled by this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 05:42:43 -05:00
chrg6
4b87606f32 Keep released textures the game takes back intact for as long as their longest release, not 120 presents.
Once the released entries pass RELEASED_MAX, the sweep dropped an entry that comes back intact as soon as its 120
presents were up. Kakariko releases the ASTC textures of its hazy air and takes them back every few hundred frames, so
about 30 of them went each time, and the frame that needed one again sampled its stand-in while it was made and
uploaded anew. Such an entry now waits out GAP_TIMES the longest it stayed released before a take-back, as an entry
whose content lives only in its image does. NX2NAVI_TEX_KEEP_TAKEN=0 goes back to the old rule, and
NX2NAVI_TEX_RELEASED_MAX (a test) lowers the count from which the sweep starts, so a short run reaches it.

The haze still dropped out with this alone: most of those frames came from finalized slots, which the next commit
deals with.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 05:42:42 -05:00
chrg6
c05b2570eb Make the version 0.9.0, and leave the long-wait watch off by default.
The watch's thread takes the kernel lock every two seconds to look at every guest thread; a release does not need it running, and wait_watch_s = 10 turns it on again for a hang report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 05:29:44 -05:00
epicmeme546
eb7072f90a Make NX2NAVI_REPLAY_PIPE the number of groups the submitting thread may have out at once, from 1 to 4.
Hyrule Field, standing, 3 workers: with 1, 2 or 4 groups out the frame rate stayed within one frame per second of
the 50 the mode without pipelining makes, over three batches, though the replay is shorter. A frame there is the
replay and then about 6.6 ms of GPU work after it, which the next frame waits for; the design comment in vk_exec.c
now says so. Sending a part's finished command buffers while later groups record was tried and gained nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 04:39:12 -05:00
epicmeme546
ffa599ef33 Let the submitting thread go on past the replay workers' groups, with up to four groups in flight.
With NX2NAVI_REPLAY_PIPE=1 (off by default) the submitting thread hands a group's chunks to the workers, takes chunks
of it itself until none is left to take, and goes on with the ops after the group in a new command buffer after the
chunks' places in the part (vk_sync_append_later), also into the next group's front pass.
Up to four groups are handed out and not in their part yet; their chunks wait in one queue in the order of the stream.
The submitting thread waits for them only where the order needs it: for room, before a part goes to the GPU, before
copies and texture or buffer clears, where DLAA's run or the contact shadows' hook acts, and where a lookup would make
a texture entry or take back a retired one (the op goes again afterwards, as a chunk's does in turn).

What the chunks read stays as the stream had it while the submitting thread runs ahead: uniform snapshot drops count
from their place in the stream, a chunk reads only the inline uniform updates before its group, the HDR present's
source goes by stream position, the texture pool set syncs under the chunks' lock, each group keeps its own render
conditions, occlusion segments and closed query slots, and the queries after a group's last report go into the next
segment made after it. A group's first chunk runs its pass hooks after the group before began its pass; turns wait
for every earlier chunk, of earlier groups too. Locks the chunks take, the submitting thread takes while it is behind.

Draws keep the sampled-texture descriptors they resolved per draw context and reuse them without the texture lock
while their slot is unchanged; the workers waited for that lock at nearly every draw. Texture lookups that change
nothing no longer wait for their turn. The perf line says where the submitting thread waited, what the chunks took,
and which texture lookups waited; NX2NAVI_GPU_TIMELINE also shows the chunks and the waits.

Off by default because it does not pay yet: in Hyrule Field with 3 workers it shortens the replay (11.5 against 12.1
ms a frame) but not the frame (49.2 against 49.6 fps in the same batch). The GPU gets a group's commands only once its
last chunk is recorded, so the main thread's wait for the GPU after the frame's first submission grew by 0.8 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 04:39:12 -05:00
chrg6
2ac56ecc6f Add NX2NAVI_VRAM_BALLAST_MB, video memory taken for the session, to test a smaller card on a large one.
NX2NAVI_VRAM_BUDGET_MB changes only the number the decisions compare with. The ballast takes that much device-local
memory right after the allocator is made, in dedicated buffers of 256 MiB, and holds it until the allocator goes, so the
driver's own behaviour at its limit (slow allocations, memory moved to system RAM, refusals) shows as on an 8 GB card.

Checked on an RTX 5090: 24000 of 24000 MiB taken and held; through eight reloads of Kakariko the use went past the card
(32,218 MiB at the end) and Kakariko fell from 118-151 fps in the first four rounds to 10-24 fps in the last four. Texture
detail was still chosen as full: the choice reads the driver's budget, which the ballast does not lower.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 03:54:21 -05:00
chrg6
7f7416b38b Log the voices the game holds in the audio renderer every 10 s with NX2NAVI_AUDIO_STATS.
The game's sound engine takes a voice per sound from the renderer's voice count, so sounds that are never let go
would show as a count that climbs from area to area until new sounds are refused. The line gives the voices in use,
those playing, the renderer's voice count and the most a census found so far.

Used to check whether the sound engine leaks voices above 60 fps: through eight reloads of Kakariko the most was 30 of
96 at a 60 fps limit and 31 at 144, and every return to the title brought the count back to 12 at both rates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 03:54:21 -05:00
chrg6
bd32077e54 Sample a flat texture that a shader reads as a 3D one through a one-slice 3D copy instead of a stand-in.
Maxwell samples a texture by its own descriptor, so a 2D texture under a 3D sample gives its texel at (u, v). Vulkan
has no 3D view of a 2D image, and get_view found no view for such a binding: the draw sampled a stand-in. Such a
texture (plain colour, one sample, up to 1024 x 1024 texels) now gets a 3D image of one slice with all of its levels,
made in the upload batch and copied again when the texture was uploaded or drawn into since, or another layer is
asked for (vk_texture.c vk_texture_flat3d_locked). NX2NAVI_TEX_FLAT3D=0 gives the stand-in as before.

Seen in Kakariko: two of the game's 4 x 4 RGBA8 textures are sampled as 3D textures, and each got its copy; the runs
through eight reloads at 60 and 144 fps ended without errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 03:54:21 -05:00
chrg6
7dcfb72b70 Keep the time of day at the game's pace under the real-time step, its fraction carried from frame to frame.
The day's update (main+0x3cdf70) adds trunc(2 x frames per update) game seconds a frame. With the set ostep's step,
the display interval in 60 Hz frames, that sum lost its fraction every frame: 1 a frame from 61 to 119 fps, 0 above
120 (the clock stood still), and at 60 fps a step a little under one frame dropped a second now and then. Its convert
now calls the patch page's +0xf60 (runtime/frame_rate.c frame_rate_day_host), which keeps the fraction per counter and
hands out the whole seconds. NX2NAVI_TRACE=perf logs, every 10 s, the seconds given beside those the cut would have
given.

Measured in Kakariko, 10 s windows: at a 60 fps limit 998 game seconds against 881 from the cut alone; at 144 fps
1,201 against 219 to 972 (the steady 1,200 a 10 s window should have).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 03:54:21 -05:00
chrg6
0c343e04a4 Record the game's time step at every present in the flight recorder: the patch page's step, the time manager's and the game's present count.
frames.tsv gains step_frames, game_step_frames and guest_presents. The game writes its step at its own present, a frame or two before the replay presents that frame, so the present count is there to line the two up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 02:54:32 -05:00
chrg6
7f5906c121 Keep the texture events of the recorded frames in the flight recorder and write them with each dump as events.tsv, before the thumbnails.
Each texture made (with how its content started), uploaded, uploaded again, released, taken back or destroyed is one line with its frame, address, format, size, layers and flags, so a one-frame flicker in the thumbnails can be matched to the textures of that frame. events.tsv is written first: the thumbnails take about five seconds, and a game closed meanwhile kept no frames.tsv.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 02:42:22 -05:00
chrg6
fe1c2d8b3b Give the draw context to the code the replay workers' change did not see: the compute bindings log, the movie stand-in's image count and the anti-aliasing pass's pipeline reset, and look a program's compute stage up directly for its guest hash.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 02:17:19 -05:00
epicmeme546
9fe3dd3331 Replay workers record mesh draws, and stop waiting for each other at queries and per-object motion.
Mesh draws ended a group and stayed on the submitting thread: 119 a frame in Hyrule Field at about 13 us each, and the
groups around them were cut short. They are recorded in the chunks now: the entries filled ahead for the indirect ones
are the draw context's, the ring index is taken atomically and the ring is made before the chunks record, each chunk
counts the ops that break a run of them on its own, and the lazy lookups of the mesh and shading-rate entry points store
their pointer before the flag that says it is there. With the mesh fallback, and while NX2NAVI_GPU_PASSES copies the
workgroup counts, they stay on the submitting thread.

A chunk's closed occlusion query slots go into a list of its own and into their segments once the group is done, in
chunk order, instead of under a lock per query. The per-object motion check decides alone per draw context (its
variant memo is per context) and takes its lock only to list a draw. The occlusion query ring has 16384 slots: the
chunks' blocks are sized to their draws, and with 4096 the ring came round to slots not reset yet.

The perf line splits the submitting thread's time with workers on: ops outside groups by kind, the front pass, its own
chunks and the wait for the others, and which ops ended the groups.

Hyrule Field, RX 7900 XT, 3440x1440, FSR 4 Native AA, same batch: standing 51.7 fps with 3 workers against 43.6 with
the workers off (replay 11.2 against 15.1 ms); along the field route 48.9 against 44.7. Screenshots standing and along
the route match the replay without workers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 02:15:35 -05:00
epicmeme546
a0a7548d30 Replay workers take their occlusion query slots in the order of the stream.
The chunks of a parallel group took query slots from the ring as they recorded, so the slots of the group's chunks
interleaved. The completion thread reads and resets slots in runs that follow the ring, and with interleaved slots it
made four times the result calls and a reset per slot: the wait after a frame's first submission ended 3.5 ms after
the GPU had run it instead of 0.6 ms, and the replay time the workers saved went into that wait (44 fps with 3 workers
as without). The front pass now gives each chunk a block of slots, as many as its draws that count samples and render,
in the order of the stream; a segment's slots are taken in ring order. Standing in Hyrule Field, 3 workers: 49.8 fps
against 43.7 with the workers off.

NX2NAVI_GPU_TIMELINE=<frame> writes four frames from that present on to the log: each replay, each timed part's submit
and GPU run, the waits for the GPU and the workers' groups, so a run shows whether the GPU waits for the replay, a wait,
or the CPU behind one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 02:15:35 -05:00
epicmeme546
77ae0f658e Keep samples-passed counters inside parallel groups, and lock the shared tables only while a chunk records.
Samples-passed resets and reports ended most groups in Hyrule Field (the game reports twice without a reset there, so
counting stays on): the front pass now replays them in the order of the stream, makes each occlusion segment and
queues its completion callback in that order, and each worker follows the counting from its chunk's first op and adds
the queries it closes to the segment the stream gives them. Per-object motion takes a lock instead of waiting for the
earlier chunks: its list's order does not change the picture. The locks the chunks share are taken only inside a
chunk, as outside groups the submitting thread alone replays; taken always, they cost the replay about 1 ms a frame.
The perf line counts the draws by what ended their group.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 02:14:37 -05:00
epicmeme546
7534193b62 Record the large draw groups of a submission on several replay workers at once.
Stage 2 of NX2NAVI_REPLAY_WORKERS (default 0, the replay as before). A run of draws is cut into groups: a group ends
where the render targets change after its first draw or clear, and before an inline uniform update, a mesh draw and a
samples-passed counter op, which the submitting thread replays itself in the order of the stream. A group of 64 draws
or more is first walked by a front pass on the submitting thread: it applies the state and binds, settles the CPU side
of the timestamp reports and decides the render conditions in the order of the stream, and copies the replay state at
the first op of each chunk. The workers and the submitting thread then take the chunks in order and record each into a
command buffer of its own, which vk_sync_append puts into the part in the order of the stream.

The frame's pass hooks (contact shadows, DLSS) run in a group's first chunk, which the others start after. What still
depends on the order between chunks waits until every earlier chunk of the group is done: a texture lookup that would
make or take back an entry returns nothing and the chunk replays the op again in turn, and so do the contact shadows'
pass, per-object motion and the HDR pass's source. The tables the chunks share take locks (the shader table, the
descriptor lists, mirror use and GPU write notes, uniform snapshot drops, target frames, the DLAA camera votes and the
previous-frame motion notes); each chunk keeps its own occlusion query open, its own feedback memo and no pass marks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 02:14:37 -05:00
epicmeme546
4fc32e8d84 Hand the draw context down in the replay state instead of reading it from a thread-local at every call.
Reading the thread-local pointer in the functions that run per binding and per descriptor cost about 0.3 ms of
replay a frame in Hyrule Field (45.0 against 45.8 fps). VkExec.dc now names the context; the draw and look-ahead
entry points fill it from the calling thread's on first use, the functions that hold the state read it from there and
the few helpers without it take it as a parameter. A replay worker's copy of the state carries the worker's context.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 02:14:37 -05:00
epicmeme546
3010a637bf Let one replay worker record each long run of draws from a copy of the replay state, behind NX2NAVI_REPLAY_WORKERS.
Stage 1 of recording a submission on several threads. A submission's draws come in runs between ops that have to
stay in the replay's order on its own thread (dispatches, copies, texture and buffer clears, events, the game's
barriers, calls). With NX2NAVI_REPLAY_WORKERS=1 a run of 16 draws or more is recorded by a worker thread: it takes a
copy of the replay state, records the run into a command buffer of its own pool with a draw context of its own, ends
it behind a full barrier and hands the state back. vk_sync_append puts that command buffer into the part between the
replay's own pieces before and after it, so the GPU runs everything in the op stream's order. The submitting thread
waits for each run, so every side effect keeps the replay's order; this stage checks that a run recorded apart from
a copy of the state gives the same pictures. The default, 0, replays as before.

walk's handling of the ops that do not steer it moves into op_one, which the worker uses too. NX2NAVI_REPLAY_RUNS=1
logs every 600 frames how the draws fall into such runs and which ops break them. The draw replay's hot functions load
their recording context once instead of at every use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 02:14:36 -05:00
epicmeme546
85af8a8f7f Keep the draw replay's per-recording state in one context a thread reaches through a thread-local pointer.
vk_exec_draw.c kept what a draw, bind or dispatch carries to the next one in file statics: the state the command
buffer holds, the descriptor signatures and skips, the per-binding reuse, the shader and pipeline memos, the shader
lookup's caches and the submission's transient resources. They now live in one DrawCtx, and every thread starts with
the replay's own, so the replay behaves as before. A later stage can give each recording thread a context of its own.

vk_exec.c's inline commands (vk_exec_inline_begin) find the replay state the calling thread records with through a
thread-local pointer too, instead of the file's single state and a flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 02:14:36 -05:00
epicmeme546
4c5855ce43 Hold ASTC textures whose every block decodes opaque as BC1 instead of BC3: the same texels in half the video memory.
The BC3 encoder's colour half is a four-colour BC1 block (c0 above c1, or every index 0 when they are equal), so a BC1 image of an opaque texture decodes to exactly the texels the BC3 one did. The encoder writes that half alone with its specialization constant BC1 set; its push constants are as before, so the BC3 pipeline is unchanged.

Every ASTC texture the CPU provides is made BC3, and its first upload checks its blocks while it copies them into staging: when all decode with alpha 255 (tex_astc.c astc_blocks_opaque, from the block header for all but the endpoint modes with alpha, which are decoded), the entry gets a BC1 image in place of the BC3 one before the decode. Later uploads into a BC1 image check again and go back to BC3 for content with alpha. A large texture's copy and check run on the ASTC decode workers, so its first upload copies faster than before. A check of its own where the texture is made cost 1.7 s of the render thread over a seven-minute teleport tour.

On that tour (Kakariko Village, the Graveyard, Death Mountain Trail, Kokiri Forest, Hyrule Field, RX 7900 XT), against BC3 alone in the same batch: the ASTC textures in Hyrule Field at the end 2,568 instead of 3,104 MiB, video memory at its peak 11,814 instead of 12,374 MiB, process commit at its peak 25,539 instead of 26,139 MiB; the first 7,200 frames in 93.7 instead of 101.3 s and the run's slowest 1 % at 24.1 instead of 21.1 fps. --probe-astc checks the header test against a decode of every generated block, the loop, its copy and the worker pool against it, and each BC1 block against the colour half of its BC3 block. NX2NAVI_ASTC_BC1=0 (astc_bc1 = 0) keeps every ASTC texture BC3; the sampling probe NX2NAVI_ASTC_BC_PROBE it replaces is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 02:11:46 -05:00
chrg6
8a980e4fd5 Add NX2NAVI_WB_SKIP_MB: without the lazy write-back, large written ranges go back to guest memory for their first 64 KiB only.
Where the lazy write-back is off (AMD's driver, outside Windows), what a binding written by a shader or a copy holds goes
back to guest memory at the end of every submission. With NX2NAVI_WB_SKIP_MB=n a written range of n MiB or more goes
back for its first 64 KiB, which carries the few words the CPU reads at the start of such buffers, and the rest stays
in the mirror, whose pool is then never evicted. A CPU read further in would see older bytes, and a CPU write further
in would have the next sync copy that page's older guest bytes over the GPU's, so it is a test switch, default 0.

Measured with NX2NAVI_WB_LAZY=0 on an RTX 5090, 75 s runs with warm caches, off against NX2NAVI_WB_SKIP_MB=1:
Kakariko walk GPU median 6.60 against 4.20 ms a frame, 98 against 132 fps; Hyrule Field walk GPU 10.09 against
4.88 ms, 76 against 132 fps, 1% low 61 against 98 fps. 78 to 94 MiB a frame stayed in the mirrors. The last frames
of both runs in each area show the same picture, and the logs have no errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 19:38:18 -05:00
chrg6
10dd325dbe Copy the pages the CPU wrote into a VRAM mirror when their part is handed to the queue, behind NX2NAVI_MIRROR_CAPTURE_KB.
The prologue of a part copies the pages the CPU wrote since a mirror's last sync from guest memory into the mirror when
the GPU runs it, a frame or more after the game's submit when the GPU is behind: the GPU then reads what the game
wrote there meanwhile, values meant for a later frame. With NX2NAVI_MIRROR_CAPTURE_KB=n the CPU copies up to n KiB of
those pages per part into a host buffer of the submission when the part is handed over, and the prologue copies them
from there. A pool keeps the GPU-time copy while a write-back of its mirror into guest memory is still on the GPU (its
fence, now kept per pool), when it has a twin (the device address table's writes reach guest memory unrecorded), and
for a range with a page that cannot be read without a fault (memory.c mem_copy_readable, under the freeze lock, so a
lazily armed range stays with the GPU). With the default of every mirror twinned (NX2NAVI_GPA_TWIN_MAX_KB=0) it
copies nothing; it is a test switch for the replay's late reads, default 0.

Measured on an RTX 5090 with NX2NAVI_GPA_TWIN_MAX_KB=64 (mirrors of pools over 64 KiB without a twin), 75 s runs
with warm caches, NX2NAVI_MIRROR_CAPTURE_KB 0 against 8192: Kakariko 0.95 MiB a frame copied in 149 ranges for
0.21 ms of the replay thread, 116.7 against 118.4 fps (interval median 6.26 against 6.46 ms); Hyrule Field walk
1.38 MiB in 224 ranges, 0.37 ms, 110.2 against 107.2 fps, 1% low 83.3 against 78.1. 0.08 MiB a frame stayed with the
GPU-time copy. A first version that took the freeze lock and asked the system for each range's pages cost 2.9 to 4.3
ms a frame. A Kakariko run with NX2NAVI_REPLAY_ASYNC=1 and the copy on played through without errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 19:38:18 -05:00
chrg6
74b7449518 Give back the kept staging and snapshot buffers and the spare blocks when an allocation is refused, then try once more.
A staging buffer, a transient buffer of the replay or a descriptor pool that the driver refuses for memory used to end
the game at once. Now the buffers kept for reuse go back to the driver first: the staging cache, the staging arena's
free chunks, the write-back snapshot pool and the headroom's spare blocks (no new spare block for 30 s after that), and
the allocation is tried once more; only a second refusal ends the game. On integrated GPUs the device-local heap is the
machine's RAM and fills before the commit checks see anything: staging buffers of 11 KiB to 16 MiB refused there ended
the game in Hyrule Field and on the first scene of play (#465, #567).

NX2NAVI_STAGING_FAIL_AT=n (diagnostics) takes the n-th staging buffer as refused once, to test the path.

Check: a Kakariko run with NX2NAVI_STAGING_FAIL_AT=300 logged "staging buffer of 524288 bytes refused (-2): 348.2 MiB of kept buffers and spare
blocks given back, made at the second try" and played on to the end of its script. The transient buffer and descriptor
pool paths call the same give-back and were not forced.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 19:38:18 -05:00
chrg6
14fbc6a0ea Make the mesh fallback's programs on up to four worker threads instead of one.
A place's task and mesh programs all arrive in its first frames, and each one's draws are left out until its compute
pipelines are built, so with one thread the foliage of a first visit filled in one program at a time.
NX2NAVI_MESH_FALLBACK_WORKERS (auto: one thread for each 4 logical processors, 1 to 4) sets how many threads make
them, and the log says how long the queue took to empty the first time.

Measured with the fallback forced on, no pipeline cache and new exe names (cold driver cache), the adult save's
first 75 s: with 1 worker the first 5 programs were ready after 420 ms, 3,266 draws were skipped while a pipeline or
program was pending, 1% low 16.1 fps and 145 frames over 50 ms; with 4 workers 256 ms, 956 draws, 55.7 fps and 35.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 19:38:18 -05:00
chrg6
677a69378f Fill the fragment inputs a mesh program does not write, with the point sprite's coordinate for point meshes.
A mesh pipeline whose fragment stage reads a location the mesh program never writes now gets a fragment module where
that input is a private variable set to (0, 0, 0, 1) at entry, or to (s, t, 0, 1) of gl_PointCoord when the mesh
program draws points. The fragment shaders recorded with two of the game's point-drawing mesh programs read location
5, which those programs never write; Vulkan leaves such an input undefined.

Checks: tests/fs_fill_inputs_check.py passes; 237 recorded fragment modules rewritten offline pass spirv-val; a
60 s Kakariko run with the change shows the area as before with no Vulkan errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 19:38:18 -05:00
chrg6
12d81ade9c Write a GPU-drawn texture back to its storage before dropping it, when the fence write-back would have.
An entry the GPU drew into since its last write-back holds texels its storage lacks; the fence write-back
(vk_texture_write_back_small) sends such targets back when the CPU waits, about once a frame. An entry dropped before
that, for a budget, a commit or video memory squeeze, its release or a replacement at its address, went without, and a
texture the game then made again from that storage started from what the storage held before the GPU drew. drop_tex
now writes such an entry back first when the fence write-back would take it (wb_wanted) and the CPU has not rewritten
the storage since. An entry another target drew over (its storage is the newer one's) and drops at shutdown are left
as they are. The commit drop pause counts the drop either way (comment beside commit_drop_note). The perf line of
texture origins counts the write-backs.

Checked: the runtime compiles; --probe-vkmem passes (164 GPU checks, 0 validation errors; it needs a writable TEMP).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 19:38:18 -05:00
chrg6
ef64f341a0 Retry a graphics pipeline the driver refuses with VK_ERROR_UNKNOWN without its optimiser, and add VK_NOOPT=mesh.
AMD's Windows driver answers VK_ERROR_UNKNOWN for some pipelines its compiler gives up on, and the draws that need
such a pipeline were left out for good. create_graphics now tries once more with VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT
(slower shaders for that pipeline instead of a missing draw) and logs the first such retry. NX2NAVI_VK_NOOPT gains a
value, mesh: only pipelines with task and mesh stages, the foliage's, are built without the optimiser, whose
optimisation is a suspect in device losses some minutes into a forest on AMD GPUs; with it a report can be narrowed
without slowing every pipeline.

Checked: the runtime compiles. A 60 s run with VK_NOOPT=mesh on an RTX GPU logs the mesh-only line, has no error and
the same GPU time as the default (4.09 ms a frame against 4.09), 134.5 fps. The retry cannot be triggered on this
GPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 19:38:18 -05:00
chrg6
1771775e3c Log a game thread that waits 10 s for a lock or for another thread to end, with what the other thread is doing.
A game that stops with nothing in its log leaves no clue to which threads wait for which. A thread of its own now
looks every 2 s for guest threads blocked that long on a lock (ArbitrateLock) or on another thread's end
(WaitSynchronization on a thread handle) and logs each such wait once: the waiter, the lock's holder or the thread
waited for, and whether that one is itself waiting and on what. Waits on condition variables, events and addresses
are left out, since idle worker threads wait on them for good. At most 24 lines a run. NX2NAVI_WAIT_WATCH_S sets the
threshold (10; 0 off). The wait's start is now kept for every blocking wait, not only under the sched trace.

Checked: the runtime compiles and tests/sync_wake_check.py passes. A 90 s run with WAIT_WATCH_S=1 logged one chain
during an area load ("thread 0x102d has waited 3 s for the lock ... held by thread 0x105a, itself waiting 2.6 s"),
and nothing in steady play; with the default of 10 s, earlier runs log nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 19:38:18 -05:00