Commit Graph

596 Commits

Author SHA1 Message Date
Tobim6
1dda8bc23c Lazy write-back: the armed list gets its own short lock; the replay's per-draw check no longer waits for freezes and thaws on other threads.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:43 +01:00
Tobim6
6de2be9ed5 GPU timeline (NX2NAVI_TRACE=perf): every 60 frames, what the GPU's idle time was spent waiting for.
The perf line's "idle with it queued" was the gap before each replay part handed over before the previous one ended:
13-17 ms a frame on an RX 580 in Kokiri Forest on 0.7.1, unexplained. Uploads and presents were not timed, a held
submission (submit batching) counted as handed over while it still waited in vk_sync, and with cuts and pre-pass
command buffers a submission closed more than the four timestamp pairs ts_unsent had room for: the rest went to the
completion queue without a submit time and out of the GPU's order. Now every timed piece of GPU work (replay parts,
mirror prologues, pre-pass command buffers, upload batches, presents) is noted with when it was handed to vk_sync, when
it really went to the queue and its GPU start and end, and every 60 frames two lines split the idle time: starved
(nothing in the queue, and how much of that a held submission waited in the batching) or with work in the queue, by
the kind of piece that started after the gap, with the average delay from hand-over to start on an idle GPU per kind.
ts_unsent has room for every command buffer of a submission, and the pairs are read in queue order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:42 +01:00
Tobim6
78429f4933 Held submissions keep every command buffer they carry: the hold buffer had room for two.
queue_submit copies a held submission's command buffer infos into H.cbi[i], two entries each, the mirror prologue
and the part. Since the mesh emulation's pre-pass command buffers and cuts (vk_sync_pre, vk_sync_cut) a submission
carries up to three plus the cut parts, and the copy ran into the next held submission's entries and past the array:
the next held submission's copy then overwrote them, so a submission could go to the queue without its own last
command buffers and with another's twice. The buffer now has room for SUB_CBS (CHAIN_MAX + 3), and a larger count
stops the run with a message instead of overrunning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:40 +01:00
Tobim6
f6199a4616 Upload batches: their GPU time in the log (NX2NAVI_TRACE=perf), with how many go to the queue per frame.
The replay's GPU time covers only its own parts. Upload batches are submissions of their own, the ASTC decoder's
dispatches in them, so their time showed only as GPU idle "with it queued (untimed work or waits)": 10-16 ms a frame on
an RX 580 in Kokiri Forest on 0.7.1 while the game streamed in about 7 textures a frame, against 0.6-1.2 ms where it
streamed none. Each batch now writes a timestamp at its start and end, read when it retires; every 60 frames a perf line
gives the batches per frame and their GPU time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:39 +01:00
Tobim6
38a3824b8f Mesh emulation: cut the part at a pass's first emulated draw instead of splitting it, so the texture pool set stays.
A split hands the part to the queue and seals its texture pool set; the next part takes another set of the ring and
refreshes its entries first. The splits for the mesh stages made 5 parts a submission and 6 set switches a frame at
2.3 ms of replay each (Kokiri Forest on 0.7.1, an RX 580: replay 32-38 ms a frame, the replay thread blocked on fences
26-35% of the time, 79 waits for a set the GPU still used). A cut (vk_sync_cut) ends the command buffer without
submitting it: the part and its pre-pass command buffer wait in a chain and go to the queue, in order, with the next
part that does, so the set is the same one throughout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:37 +01:00
Tobim6
55ab90c66e Mesh emulation: the stages of a pass's emulated draws run before the pass, in a command buffer of their own.
Each emulated mesh draw ended the pass, ran its stages between four barriers and began the pass again: a pass of 20
emulated draws became 20 passes, and on an RX 580 6 to 7 ms of a frame's 30 ms of GPU time went to the gaps between
passes (gpu_passes in Kokiri Forest: 8.7-10 ms per frame outside the game's passes and dispatches, 6.3-7.7 ms of it in
273-306 gaps with barriers only; 71 emulated draws a frame, 36 of them indirect). Now the first emulated draw of a pass
ends the part there (vk_exec_split_now), so the pass begins a new part, and the stages of every emulated draw of that
pass, the indirect ones' ring entries included, go into the part's pre-pass command buffer (vk_sync_pre), which the
queue runs after the mirror prologue and before the part; the pass is not split again. NX2NAVI_MESH_EMU_BATCH=0 (Lama
patches: Mesh emulation before the pass) brings the split back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:35 +01:00
Tobim6
93e68d57f1 Pool marks: a fragment shader stores its marks where it ends, not between a sample's coordinates and the sample.
On AMD's driver for Polaris (RX 580, 23.10) a store between a pool texture's access chain and its sample left the
quad's helper lanes out of the code in between: derivatives at a triangle's edge were garbage and edge pixels came out
dark, the dotted lines along the paths' triangles since 0.7.0 (frame dump f1714: the colour pass covers every pixel,
the depth test is not what drops them). Each access now notes its slot in a Private variable; before each return of
the entry function and before a kill, terminate or demote every noted slot is marked, an unset one going to a spare
slot past the pool. Accesses in loops or outside the entry function note theirs in a ring of 8, marked in a loop at
the way out. Checked with spirv-val on the 45 marked shaders of the dump.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:34 +01:00
Tobim6
01d81811a1 NX2NAVI_LOG_TEX_NEW: log the textures made from a frame on, with what destroyed the same key before
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:32 +01:00
Tobim6
9259149527 Settings menu: a Lama patches tab with the settings of the RX 580 patches
Released textures kept, top texture levels left out, hot pools in system memory, the heap limit, the upload batch
limit, the kept ASTC buffer, mesh emulation and its arena and task records (greyed where the GPU has mesh shaders),
the overwritten-texture fix, the vector index fix, -O2 game code, pass times and the frame dump key. Each key gets a
row in the settings table; make_game.py reads guest_opt from nx2navi.ini when the environment does not set it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:31 +01:00
Tobim6
f18639e055 Mesh emulation: payloads that are not a multiple of the workgroup size.
Since 0.6.0 a task payload is 32 bytes longer than the program header's size (b6b76b7): Ocarina's foliage task payload
is 776 words, which 32 threads do not divide. The emulation refused those programs ("payload not a multiple of the
workgroup size"), their pipelines failed, and the task draws (grass on the moss, the door) went undrawn again. The
copies of the payload into and out of the task record take a last, partial round, where threads past the payload idle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:29 +01:00
Tobim6
a2656f8501 Mesh emulation: task records hold payloads of up to 776 words.
Since 0.6.0 the translator sizes a task payload 32 bytes past the program header's size, for the header before the
program's data (b6b76b7): Ocarina's foliage task, 3072 bytes, now declares 3104. A record held 768 payload words, so
the emulation refused those programs ("payload too large") and the foliage went undrawn. Records are 780 words.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:26 +01:00
Tobim6
bb654470b2 Crash report: the log names what the crashing thread was building, and a library link names its case.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:24 +01:00
Tobim6
7118dd426d Mesh emulation barriers carry MEMORY_READ/WRITE: the task stage's mesh dispatch was read as zeros on AMD Polaris.
The emulation's barriers named only synchronization2's SHADER_STORAGE_READ/WRITE bits (above bit 31). With AMD's
driver for the RX 580 (23.10.01) the indirect dispatch of the mesh stage, which reads the {groups, task workgroups, 1}
the task stage had just written, launched no workgroup: mesh.txt showed 0 mesh groups started for every draw with a
task stage while its record held 32 x 12 x 1, and Kokiri's moss foliage and Link's door were missing. The masks now
also carry MEMORY_WRITE and MEMORY_READ, as the replay's general barrier does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:22 +01:00
Tobim6
888f4ca17a Mesh emulation: the arena counts mesh workgroups started, past the task-record check and at the output copy.
Draws with a task stage drew nothing on an RX 580 although their task records ask for mesh groups (mesh.txt), and the
same converted stages produce vertices on lavapipe. Header words 4-7 now count, per submission, the emulated mesh
workgroups that started, those whose task record covers them, those that reached the output copy and the primitives
those declared; mesh.txt prints them after each draw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:21 +01:00
Tobim6
bd69291262 Task and mesh stages get their own c0 bank.
c0_info keeps the last bank per stage and reuses it when the inputs (storage and uniform bindings, base instance) are
equal, but task and mesh shared the compute entry and the inputs do not name the stage, while the storage table sits at
0x670 for the task stage and at 0x770 for the mesh stage. When a program's task and mesh stages bind the same storage
buffers, the second stage got the first one's bank and read zero storage addresses. In a Kokiri Forest frame every
draw with a task stage (moss foliage, Link's house door) launched mesh groups that made no vertices, while mesh draws
without a task stage drew.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:19 +01:00
Tobim6
4ed51cf7ff Overwritten textures: swizzle siblings follow the image that gets its own memory; other descriptors keep pool memory.
The game renders through one descriptor and samples through another that differs only in swizzle, and both read the
same pool memory. When one of them got memory of its own (read after an overwrite), the other kept reading the pool
bytes, which the first no longer updated. Now the image and its swizzle siblings become one image in memory of its own:
entry_of hands that image out for any swizzle of its key. If a live descriptor of another format or geometry reads the
same storage, the image stays in pool memory as before. The perf line counts both outcomes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:18 +01:00
Tobim6
703e9fecd9 Textures read after another image drew over their pool memory get memory of their own.
The game overlaps transient render targets in its memory pools, and the replay binds their images into that memory.
An image of another format or size drawn over an image's memory leaves the GPU's tiled, compressed texels of the
other image there. Ocarina's volumetric fog reads its 360x202 RGBA32F fog-volume texture at the start of a frame,
before drawing it again, and the 1440x810 R11G11B10F bloom target had been drawn over that memory at the end of the
previous frame: the fog lighting took those texels as volume distances and types (values from 1e-12 to 3e33 in a
frame dump where the texture holds 9 to 50000), and drew teal splotches in Kokiri Forest's fog on AMD and NVIDIA.

Each pool-bound image the GPU writes marks the pool-bound images of another layout that overlap it; one read while
marked is dropped and comes back with memory of its own from then on, so it keeps what it last drew (the read that
found it gets an empty image once). NX2NAVI_TEX_CLOBBER=0 keeps such images in pool memory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:16 +01:00
Tobim6
3b90353c5b Optional (NX2NAVI_VEC_INDEX_FIX): uniform vector components at computed indices loaded whole and selected.
AMD's Windows drivers can read the wrong component through an access chain into a uniform block vector whose
component index is computed (the translator's c[n][i >> 2][i & 3] for an LDC with a register offset), the bug Ryujinx
works around with HasVectorIndexingBug. With NX2NAVI_VEC_INDEX_FIX=1 (or auto: AMD's own drivers) each shader is
patched in memory as it loads: the chain without its last index loads the whole vector, CompositeExtract takes each
component and OpSelect picks the indexed one. Off by default: it did not change the volumetric fog's teal blotches on an
RX 580, whose per-volume extinction reads its colour this way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:15 +01:00
Tobim6
6169d82385 NX2NAVI_DUMP_KEY takes a key name; Pause by default.
F10 is the performance overlay's key, so a press dumped a frame and changed the overlay. dump_key = 1 or pause now
means the Pause key; scrolllock, insert, home, end, pageup, pagedown, f2-f7, f9 and f12 can be chosen instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:13 +01:00
Tobim6
131ee6f275 NX2NAVI_DUMP_KEY: F10 dumps the next frame.
A frame dump needed its frame number in advance (NX2NAVI_DUMP) or a depth target address (NX2NAVI_DUMP_AFTER); with
dump_key = 1 each press of F10 in the game window dumps the next frame to <dump dir>/f<frame>, as often as wanted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:11 +01:00
Tobim6
2b11e32250 NX2NAVI_PASS_TIMES: write the timestamps straight into the command buffer, not through the recorder.
vk_pass_mark_cmd runs on the recorder thread for a pass mark packet; through vk.h's macro its vkCmdWriteTimestamp
became a packet of its own, put into the ring by the recorder thread while the replay thread was writing it. The ring
broke ("FATAL: vk_rec: unknown packet") on NVIDIA GPUs, where the recorder is on by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:10 +01:00
Tobim6
1768d5f607 Mesh emulation: the vertex shader declares the fragment shader's inputs one for one.
The generated vertex shader wrote one vector per location. A fragment shader that packs two inputs into one location
(Component decorations: a vec2 at component 0 and another at component 2) then had nothing matching its second input,
whose value is undefined: wrong colours on the emulated foliage. The vertex shader now declares an output for every
input variable of the fragment shader, with its Location, Component, type and Flat, filled from those components of
the mesh stage's vector at that location (zero where the mesh stage writes none).

(cherry picked from commit c38eb31889314ebfb164ff9dffad5796eba46ed4)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:08 +01:00
Tobim6
8b78e64539 Mesh emulation: point meshes too, and a warning for draws from a nonzero workgroup.
The 8 point-list mesh programs of Ocarina 1.1.1 (32 points, position and point size) were left unemulated. Their
indices are single uints and the point size goes to an extra vertex slot, which the generated vertex shader writes to
PointSize; the draw asks for a point list (the pipeline key's topology class follows the draw's primitive for mesh
draws), chosen from the mesh stage's OutputPoints. A mesh draw from a nonzero first workgroup is drawn from 0 as
before, now with a warning in the emulated path too. All 1016 programs convert and pass spirv-val.

(cherry picked from commit 8900aeaffa3264e4cc655ffd487cb2d2f3e3dd17)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:07 +01:00
Tobim6
1534dc570a Mesh emulation: size the task records from the arena, and log what each submission asked for.
The task records were a fixed 4096 per submission (3 KiB each): a dense patch of grass that launches more task
workgroups in one submission lost the rest silently. Their count is now a push constant (NX2NAVI_MESH_EMU_TASKS,
default 16384) and the arena defaults to 256 MiB. The header counts what the stages asked for past the capacities too;
before the counters start over they go to a readback ring, and the perf line reports the most one submission used of
the vertex slots, indices and task records, and the mesh workgroups that did not fit. The first draws the emulation
skips are logged with the reason.

(cherry picked from commit 81cfd91bf468f13e4debf287d080f96637a4c382)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:05 +01:00
Tobim6
aec5b5a840 Emulate mesh shaders with compute on GPUs without VK_EXT_mesh_shader (NX2NAVI_MESH_EMULATION, off by default).
Without the extension every mesh draw was skipped ("mesh draws need VK_EXT_mesh_shader: skipped"): on an RX 580 the
game's grass and foliage were missing. The translator already builds each task and mesh program as compute code that
MeshSpirv.cs wraps into TaskEXT / MeshEXT modules; runtime/mesh_emu_spirv.c turns those modules into GLCompute ones:
outputs and payload move to workgroup memory, SetMeshOutputsEXT's counts are kept, and the entry function's end
reserves vertex slots and indices in an arena with atomics and copies the vertices and triangles out (task: the payload
and the mesh group count go to a task record, and the mesh dispatch to the draw record). A generated vertex shader
reads the vertices back for the game's fragment shader. Checked with spirv-val (Vulkan 1.3) on the 1016 task and mesh
programs of Ocarina of Time 1.1.1: 1008 convert and validate; the 8 point-list meshes stay unemulated.

vk_pipeline.c gives an emulated mesh pipeline a layout whose task and mesh bindings are visible to compute, with push
constants and a compute-side descriptor template, builds the generated vertex shader's graphics pipeline and the two
compute pipelines; vk_exec_draw.c prepares each mesh draw as before, then outside the pass zeroes the arena counters
(first emulated draw of a submission), fills a draw record, pushes the same descriptors to the compute bind point,
dispatches the task and mesh stages (direct, or from the indirect ring entry) and draws DrawIndexedIndirect from the
record. mesh_emulation = 1 turns it on; mesh_emu_mb sizes the arena (160 MiB).

(cherry picked from commit efc43b177694d8f8ce5700fcf28d80e889a45589)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:03 +01:00
Tobim6
f3a9d2967f Profiler: name the exe's addresses from its own symbol table, and sample the replay thread alone.
A NX2NAVI_PROFILE profile needed the link map to name its Rips, and the launcher's builds keep none. A MinGW link keeps
the COFF symbol table in the exe, so prof_sampler_write now reads it (runtime/prof_syms.c, plain file reads) and appends
`sym <address> <function>+<offset>` for every exe address in the Rip and chain lists. NX2NAVI_PROFILE_REPLAY=1 samples
only the replay thread: with NX2NAVI_REPLAY_ASYNC=1 the render thread spends 98% of a 37 ms frame waiting, and the
replay thread (22 ms a frame recording Vulkan commands) is the one to look at.

(cherry picked from commit 9d3126ca780d7f0f0b91468d42b8ee70572747c8)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:22:00 +01:00
Tobim6
4ba78a7b31 Add NX2NAVI_MIRROR_HOT: pools copied through their VRAM mirror every frame go back to system memory.
On an RX 580 with the scene at 854x480 the render passes take 11 ms of a 32 ms frame. The rest is the mirrors: 66 MiB
of CPU-written pages up and 76 MiB of compute-shader writes back each frame, mostly through six 6-16 MiB pools the game
refills every frame, with the GPU idle 7.8 ms a frame while those copies wait. With mirror_hot = N a mirrored pool whose
uploads, write-backs and merges average N percent of its size (and at least 1 MiB) a frame over 120 frames leaves the
mirror at the start of a submission: it comes off the mirrored list, the device address table points at the imported
buffer again, and the mirror buffer is freed after the next submission. Default 0, off.

(cherry picked from commit 82e5dcb682375fa48bbaffa1d61f825272544e36)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:21:56 +01:00
Tobim6
1bfe90e3e2 Pass times: log the largest viewport each kind of pass draws with.
A dynamic resolution that keeps its targets at the largest size and draws the scene into part of them shows up as a
viewport smaller than the pass; one that resizes its targets shows up in the pass size. NX2NAVI_SCENE_SCALE=33 left
the handheld scene pass at 1440x810, so this tells which of the two the game does there.

(cherry picked from commit af7abe36b0b15c5a63b354d2870543987d1f4b1a)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:21:54 +01:00
Tobim6
496c163d86 Map the "Nyx Joy-Con" USB HID joystick as a gamepad, and log joysticks SDL cannot use.
A Switch can present its Joy-Con over USB from its boot menu's tools as a plain HID joystick, "Nyx Joy-Con" (VID
0x11EC, PID 0xA7E1): X, Y, Z, Rz for the sticks, a hat for the D-pad and twelve buttons. SDL has no gamepad mapping for
it, so it was a joystick only and input.c, which opens gamepads, did not see it ("input: no gamepad"). scan_pads now
gives every known joystick without a mapping one built from its own GUID (buttons 1-4 B, A, Y, X as south, east, west,
north, then L, R, ZL, ZR, Minus, Plus and the stick clicks), and logs any other unmapped joystick once with its name,
ids and GUID.

(cherry picked from commit ed4c68c3e8460e247bab3ad4f3f02e2672868ddf)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:21:52 +01:00
Tobim6
28d8d47eb3 Add NX2NAVI_FLUSH_SKIP_CLEAN: flushed ranges upload only the pages the CPU wrote.
On 0.6.1 the mirror sync already leaves flush ranges of write-watched pools uncopied (0101a87), which covers what this
did; the key stays known and does nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:21:50 +01:00
Tobim6
3b345c5190 Add NX2NAVI_PASS_TIMES: GPU time per render pass and dispatch in the log.
No vendor profiler covers an RX 580 (RGP supports RDNA only) and RenderDoc cannot capture this program, so nothing
showed where 38 ms of GPU time per frame went. With NX2NAVI_PASS_TIMES=1 every pass mark also writes a timestamp at
its two points into a query slot pair of its ring slot. The replay thread takes in the marks whose submission has
finished, resets their slots on the host (hostQueryReset) and sums their time per kind of pass (size, attachment
formats, first fragment or compute shader); every 600 frames the log lists the 15 with the most GPU time per frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:21:49 +01:00
Tobim6
28d7cdbc51 Limit VMA's use of each device-local heap to its budget where the GPU has another one.
An RX 580 (8 GiB, AMD 23.10) shows its memory as a 6 GiB device-local heap and a 2 GiB device-local, host-visible
one, and Windows granted the game 5.1 GiB of the first. A save load put 5.6 GiB of textures, VRAM mirrors and pools
into the first heap while the second held 69 MiB, and the next submit failed with VK_ERROR_OUT_OF_DEVICE_MEMORY;
budget flags on the texture allocations alone did not change that. VMA now gets heap limits (pHeapSizeLimit) when
the device has two or more device-local heaps: each heap's budget at device creation less a tenth (at least 256 MiB)
for memory VMA does not see. Every allocation past a limit goes to the next memory type that allows it.
NX2NAVI_VRAM_HEAP_LIMIT: auto, 0 (off) or MiB for the largest heap. A physical pool that finds no video memory left
takes any memory type it may live in instead of failing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:21:47 +01:00
Tobim6
3de5577512 Allocate texture images within the heaps' budgets, moving on to the next heap with room.
An RX 580 (8 GiB, AMD 23.10) shows its memory as a 6 GiB device-local heap and a 2 GiB device-local, host-visible
one. Asked for device-local memory without a budget, VMA chose the first heap every time: a save load put 5.6 GiB
there against a budget of 5.1 GiB while the second heap held 69 MiB, and the next submit failed with
VK_ERROR_OUT_OF_DEVICE_MEMORY. create_tex now allocates with VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT: device-local
memory of any heap first, then any memory type the image allows, and only then past the budget as before. The log
names images placed outside the first device-local heap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:21:45 +01:00
Tobim6
96f82791c8 Submit a large upload batch early, and log every heap after an out-of-memory submit.
A save load made thousands of textures between two replay submissions, and all of them went into one upload batch:
about 1.5 GB of raw ASTC blocks plus the decoder's work in a single submission, which AMD's 23.10 driver on an RX 580
refused with VK_ERROR_OUT_OF_DEVICE_MEMORY ("vk: upload submit failed (-2)"). The outermost vk_upload_end now submits
the open batch once its staging holds NX2NAVI_UPLOAD_BATCH_MB (256 by default; 0 = no limit). The batch still precedes
the replay submission that uses its textures, and its staging goes as it retires.

When a submit fails for lack of memory, vk_mem_oom_report logs each heap's use and budget as the driver counts them,
VMA's blocks and allocations there, the open and in-flight upload batches, the VRAM mirrors and pending releases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:21:43 +01:00
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