Commit Graph

505 Commits

Author SHA1 Message Date
chrg6
2cccdb8823 Keep the game on the largest-L3 die only when that die has 8 cores, and reserve no recorder core there.
cache_die moved the process to the logical processors of the largest L3 cache whenever the L3 sizes differed. That is
right for a two-die X3D desktop part with 8 cores a die, but it also held the game to the 4 large cores of a mobile
part whose 8 small cores share a smaller L3, and to the 6 cores of a 12-core X3D part, where the recording thread's
reserved core then left the game 5. The die is now used only when it has 8 or more physical cores (perf.c
cpu_placement logs when one is passed over). And while the process runs on that die alone, RECORDER_CORE=auto
reserves no core for the recording thread, since the game's threads already have the die to themselves; =1 still
reserves one.

Checked: all runtime files compile. This PC has a single-die processor (one L3), where neither rule applies: a run
still reserves the recording core (logical processors 14 and 15 of 16) and logs no cache die.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 19:38:18 -05:00
chrg6
01164679d4 Give Mesa's shader cache beside the game a limit of 8 GB instead of its default 1 GB.
On Linux with RADV (and the Steam Deck) the game points MESA_SHADER_CACHE_DIR at mesa-cache beside the exe, a folder
nothing else writes, but left Mesa's limit of 1 GB. The stage libraries the library warm builds in play are kept only
in the driver's cache, and a preparation of every shader variant is larger than that limit, so what did not fit was
compiled again in play. The limit is now 8 GB in that folder unless MESA_SHADER_CACHE_MAX_SIZE is set, as NVIDIA's
cache beside the game already has.

Checked: all runtime files compile. Not run on Linux.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 19:38:18 -05:00
chrg6
276c886143 Prepare every pipeline of the shared list where the driver has no graphics pipeline library.
NX2NAVI_PREPARE_PIPELINES=mesh, the default, builds only the list's mesh pipelines, because a vertex pipeline is
fast-linked from its stage libraries in a few milliseconds and its vertex module depends on the output union this
install has recorded. Neither holds where the library is off (vk_caps_gpl: AMD's Windows driver for RDNA 2 and older,
or gpl = 0): a vertex pipeline a draw misses is compiled whole while that draw is left out, and its vertex outputs come
from its own fragment shader, since independent layouts need the library, so the listed pipeline is the one the draw
asks for. There mesh now builds every record, and the summary line says so.

Checked: all runtime files compile. Not run: no install on this PC holds the shared list, and the case is a GPU without
the library (NX2NAVI_GPL=0 would show it on any GPU).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 19:38:18 -05:00
chrg6
ab8734d1f6 Make the engine's second time step follow the display interval too, so held buttons repeat at the right rate.
Besides the per-frame update that the set ostep patches, the graphics system's update (main+0x3b4ea90) divides 60.0 by
the engine's nominal rate and stores the result as a global (main+0x4d41fc8): the 60 Hz frames of an update. Its one
reader is the buttons' hold-to-repeat timer (main+0x3483680), which adds it to each held button's time and repeats the
button once that passes the button's delay and period. Above 60 fps the global stayed 1.0 a rendered frame, so a held
button repeated fps / 60 times too often. Two more ostep sites load frames per update from the patch page there, so the
two steps are the same number. NX2NAVI_SPEED_PROBE=1 adds the global to the fps line.

Checked: the generator's check passes for all 34 main sites against the 1.1.1 module, and the generated C differs from
before only in the patched function. Two 60 s runs of an adult save at about 135 fps, uncapped: before, the global
step read 1.000 frames while the game's step was 0.42-0.50; after, it read 0.43-0.46, inside the game's step range;
frame rate unchanged (132-138 fps in both).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 19:38:18 -05:00
chrg6
d02220f578 Give NVN2 compute programs the local memory their control section asks for, and put spills after it.
An NVN2 compute program's control section gives its local memory in bytes a thread at +0x68, beside the shared memory
size at +0x64 that the job already carried. Without it the translator declared its default of 0x1000 bytes: one of the
game's compute programs needs 4,752 bytes a thread, and its translation declared a 1,024-word local array that it
indexed up to word 1,187, outside the array. The job now carries "local_mem" from +0x68, and the lowering starts a
compute program's spill area after its own local memory (at least 0x1000 bytes) instead of always at 0x1000, where a
larger program's own memory would have overlapped it.

Checked: that program's translation now declares 1,188 words (indices up to 1,187) and passes spirv-val; two programs
of 3,456 bytes a thread translate as before. All 266 compute programs whose stored input id starts with 0 in an
installed shader cache translate and pass spirv-val (vulkan1.3), and tools/xlate_smoke.py passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 19:38:17 -05:00
chrg6
b5c9a9b38e Answer NVN getters asked of no object with 0, and map a buffer with no pool to memory of its own.
The game's scene-loading thread makes a few NVN calls with a null object while an area loads or Kakariko's time of day
changes: a memory pool's flags (and the other pool getters), a texture builder's storage size or alignment, and the
mapping of a buffer that has no pool, into which it then writes 0x3d0 bytes. Each read the object at address 0 plus a
field's offset, an access violation. The pool getters, nvnMemoryPoolInvalidateMappedRange and the two builder queries
now answer 0 for a null object (nvn_no_object), and nvnBufferMap of a buffer with no pool returns a block of scratch
memory (64 KiB, or the buffer's size when it records a larger one) instead of 0. The first such calls are logged with
their caller. These fit the crash reports in Castle Town and in Kakariko before Death Mountain (#605, #602), which have
not been confirmed to be this.

Checked: --probe-nvn gains three checks (pool getters of no pool, builder queries of no builder, a 0x3d0-byte write
through the mapping of a buffer with no pool) and they pass; its four other failures are the same on the baseline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 19:38:17 -05:00
chrg6
e8b4d29f91 Give mesh output components outside the program's output map Maxwell's default of (0, 0, 0, 1).
A mesh program's header lists the components of each output vector it has; the fragment stage may read the others.
The native mesh entry function never wrote them, so they read as whatever the output held, and the fallback's vertex
stage wrote 0 for all of them, w included. Maxwell gives an unwritten component (0, 0, 0, 1), as the pipeline code
already pads a missing vertex output. Both paths now write that default: MeshSpirv.cs after copying each vertex's lines,
mesh_fb.c meshfb_vs with w as the bits of 1.0f whatever the type.

Checked: all 520 task and mesh programs of an installed shader cache translate and pass spirv-val (vulkan1.3); 500
mesh modules gained about 730 bytes each on average, so many of the game's mesh programs have partly listed vectors.
--probe-meshfb passes (fallback pictures equal the mesh pipeline's), and its module part converts all 520 new
translations with 0 failures, all 1,020 modules pass spirv-val and their compute pipelines build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 19:38:17 -05:00
chrg6
e92f0ae3f1 Clear the whole stage buffer in the mesh fallback too, before the mesh program runs.
On a GPU without mesh shaders the fallback replaces the translated module's entry function with its own, which cleared
only the primitive count and then copied the whole slot (vertex lines, count, index bytes) out of workgroup memory to
be drawn. Lines and index bytes the program did not write kept what an earlier workgroup left there and were drawn as
vertices and primitives. The fallback's entry function now sets every word of the slot to zero in a loop over the
workgroup's threads before the payload copy and the barrier, as the translator's own entry function does.

Checked: --probe-meshfb passes before and after (the fallback's pictures match the mesh pipeline's texel for texel on
an RTX GPU); its module part converts all 520 task and mesh programs of an installed shader cache with 0 failures, all
1,020 resulting modules pass spirv-val (vulkan1.3) and their 520 compute pipelines build on the device.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 19:38:17 -05:00
chrg6
15bd64f4b8 Hold new pipeline builds back during the save at exit on every driver, instead of copying the cache while NVIDIA's builds run.
The save at exit now copies the cache only once the builds already in the driver have finished, with new ones held back meanwhile, as it already did on other drivers. Intel's driver crashed copying a cache while builds ran into it, and when the window closes the game's save is written after the pipeline cache, so a crash in that copy would lose it. The case the save at exit missed, a window closed while the boot's prewarm workers built pipelines back to back, is covered by holding new builds back: a build from the file takes about half a millisecond. The prebuild's comment keeps why its default is two threads, with the measurements of one thread for the rest of the list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 18:12:47 -05:00
automata.
27f93a314a Save completed pipeline cache data during NVIDIA background builds 2026-11-11 18:10:38 -05:00
automata.
60ac5f5982 Prioritize recent compute pipelines before reducing background concurrency 2026-11-11 18:10:37 -05:00
chrg6
ebb37689cf Thaw a frozen region's pages outside the freeze lock, from the runs its freeze kept, so a thaw slowed by the driver's pinning no longer holds the replay and the game's other threads.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:35:25 -05:00
chrg6
fa9dcbca5c Freeze a memory region only after 1,800 submissions without a write, so the game's streaming buffers stop being frozen and thawed while it streams an area.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:09:45 -05:00
chrg6
90e41c13d3 Pause the drops for a low commit while most of the textures they drop are made again within seconds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:09:16 -05:00
chrg6
bfe88e503a Add one anti-aliasing setting: the game's SMAA, off, FXAA, SMAA at its Ultra preset, or TAA.
Ocarina anti-aliases every frame with its own SMAA in three compute passes after the bloom composite. The new aa
setting (nx2navi.ini aa, the Screen tab's Anti-aliasing row) keeps that by default. off, fxaa and smaa leave out the
game's edge and weight passes and replace its composition with a pass of our own that writes the same square-rooted
RGB9E5 words into the scene target: a plain copy, an edge smoothing written here, or the SMAA reference implementation
with its area and search textures (MIT). taa is DLSS or FSR 3.1 at the scene's size, which the row sets through the
upscaler; while either runs, the game's SMAA stays whatever aa says. The game's passes are known by a hash of their
guest code. The shader build now also rebuilds a header when a file its source includes changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:09:16 -05:00
chrg6
d3e50328bf Keep movies with their sound at any frame rate: one movie frame per update, and the pacer keeps the movie's slots through a late frame.
The game's movie player adds the time manager's step to an accumulator at each update and advances the movie by whole
pictures of it, at most the player's limit per update, which is one for the Triforce movie. While a movie plays the
game is held at 60 updates a second, but every late frame cost an update, the pacer started its slots again from the
late one, and the steady step's payback of the lost time came as steps over one frame, which the player cannot turn
into more than one picture. So each late frame put the picture further behind the sound, which plays by the clock, and
it never caught up.

While a movie plays the step is now exactly one movie frame, and the pacer keeps the movie's slots through a lateness
of up to a second, presenting the frames after a late one at once until the game is back on them. The updates then
average the movie's rate, and the picture, the event's update count and the game's clock all stay with the sound.
movie_clock = 0 gives the earlier behaviour. The movie log now measures the picture on screen against real time where
the game releases it (the game fetches pictures ahead into a list of its own) and reports it at the end of each movie.
test_hitch = <every>:<ms> makes a frame that much late every so many presents, for test runs.

Measured on the Triforce movie (event Dm_Kokiri_0095, 7,040 pictures, 117 s), one exe with movie_clock = 0 against 1,
and a 70 ms late frame every two seconds (test_hitch = 120:70), as a run with natural hitches had shown a drift of 40 ms
every ten seconds. Drift of the picture on screen behind real time, from the movie's first 10 s to its end:

  fps_limit   before (updates/s, drift at the end)   after (updates/s, drift over the movie)
  unlimited   58.86, 2,187 ms behind                  60.22, flat at 53 to 55 ms
  144         58.86, 2,196 ms behind                  60.04, flat at -11 to -15 ms
  120         58.98, 2,257 ms behind                  60.20, flat at -1 to 0 ms
  60          58.88, 2,220 ms behind                  59.98, flat at -21 to -22 ms

Without the late frames both kept time (unlimited: before flat at 21 ms, after flat at -13 ms). The selftest,
--probe-cfg, --probe-kernel, --probe-movie and tests/frame_step_check.py pass; the check now plays a movie started at
240 fps with late and short frames and needs exactly one frame every update.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:09:16 -05:00
tangerineturtle1
1fb2877f56 Add the -1 texture LOD bias NVIDIA asks for while DLSS or FSR runs with jitter.
The bias on the scene's tiled material textures was log2(render / output) alone, so DLAA got 0 and Quality -0.58. NVIDIA's DLSS guide asks for log2(render / output) - 1 on top of the game's own bias: the jittered frames the upscaler accumulates resolve detail a level finer than one frame shows. The -1 now comes with the jitter (dlaa_jitter, on by default): DLAA gets -1, Quality -1.58, Performance -2, for DLSS and FSR 3.1 and 4 alike, which share the bias. Without jitter it stays as it was, where a sharper level would shimmer. Which samplers take it, and the clamp to the device's limit, are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:09:16 -05:00
tangerineturtle1
48b71a630d Jitter DLSS's scene on Ocarina's frame, with the shading draws against the copied depth jittered too.
Jitter was off on Ocarina because with it the ground and characters went white within seconds. The cause: the game draws its depth pre-pass into the scene depth, copies it into a second image of the same size, and shades the same geometry into the light target against the copy with the depth test EQUAL. Only the draws into the first image took the jitter, so the shading draws compared unjittered depth with jittered depth, EQUAL failed on nearly every pixel, and the light target kept its clear colour. Frame dumps with and without jitter show the shading passes darkening the light target from a mean of 133 to 13 without it and leaving it at 112 with it.

On Ocarina's frame every draw that projects through the camera (it binds the scene context at c3) into a D32F depth of the scene's size now takes the jitter, and full-screen passes drawn with a scene depth attached do not: the bloom composite DLSS reads would otherwise move the picture by the jitter a second time. The viewport is recorded again whenever a draw's jitter differs from the last one recorded. Jitter is on for Ocarina by default (dlaa_jitter = 0 still turns it off), and the DLAA log line counts jittered frames and draws.

Checked in Hyrule Field with the camera turning: the picture's brightness matches the run without jitter (mean 33 to 63 against 35 to 60; 144 to 188 before the fix), and in 20 motion-vector checks the warp error is lowest with the jitter applied as DLSS is told it (0.032 to 0.077), against 0.076 to 0.141 with its sign flipped and 0.059 to 0.106 left out, still cameras included: the scene moves by the jitter of that frame, in render pixels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:09:16 -05:00
tangerineturtle1
e1cb6301ab Give frame generation and FSR the scene's own near and far planes, field of view and units.
DLSS frame generation (Streamline and the NGX path) and FSR 3.1 and 4 upscaling and frame generation were told the depth came from a camera with near 0.1 and no far plane. Ocarina's projection has a finite far plane that changes with the camera: in Hyrule Field its z row is (-1.00001, -0.200001), near 0.1 and far about 25,000; the camera before it had far about 1,000. With the far plane taken as missing, a surface 10,000 units away was read as 16,650. The planes, and whether the depth is inverted, now come from the frame's projection and the device's depth mode every frame (vk_dlaa.c proj_planes), with one log line when they change. The stored depth is already 0 near and 1 far: the -w..w clip depth the pipelines keep maps to exactly what a 0..w projection with the same planes stores, and a frame dump's scene depth spans 0.975 to 1.0.

FSR's contexts lose their infinite-depth flag and take the far plane from each dispatch. FSR frame generation now gets the camera's field of view instead of a fixed 1 radian, and the upscaler gets it too (its caller passed 0). The view's units are metres, not the centimetres FSR was told: the camera orbits Link about 4 units behind him at about 3 units a second.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:09:15 -05:00
chrg6
6a011d2adf Blit the movie upscaler's stand-in into an image slot its program uses, so the Triforce movie after Gohma plays at 4K.
The stand-in for the game's tensor-core upscalers wrote the largest image bound to the dispatch. Image slots keep
their bindings from earlier dispatches, and with a 3840x2160 picture the scene upscaler leaves its 3840x2160 RGB9E5
target in slot 2, larger than the movie network's real 2560x1440 output in slot 1. The output kept stale bits for the
whole movie, which showed as frozen coloured stripes (issue #520). The output is now looked for only among the image
entries the program's NVN2 control section counts (at least slot 0). The binding log of NX2NAVI_LOG_CS_BINDS also
prints those counts.

Checked with Dm_Kokiri_0095 at game_res 2160 with DLAA (stripes before, the movie after), at 1440 with DLSS
performance (unchanged), and in Goron City gameplay at 1440 (same picture, 164.9 against 159.8 fps).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:09:15 -05:00
chrg6
e501ded816 Keep the ASTC decoder's scratch across upload batches and stage its blocks in the staging arena by default.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:09:15 -05:00
chrg6
5d51933969 Arm a written-back range only while its mirror is still the pool's, and give back an armed range of another mirror instead of marking it stale.
A write-back finishing on the completion thread could arm its range between a mirror's eviction and the drop of its
buffer, naming the freed buffer; a later write into the new mirror then marked that range stale and its next touch
copied from the freed buffer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:09:15 -05:00
chrg6
6b73d85d19 Name the game's own HDR Native in the menu, without the note after it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:06:30 -05:00
chrg6
3529eff949 Offer both kinds of HDR in the menu again: the tone mapped picture and the game's own.
The HDR row lists Off, RenoDX (the game's picture tone mapped to the display, the one fixed look) and Native (the game's own HDR, taken up at the next start), with the peak, game and HUD whites under either.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:06:30 -05:00
chrg6
309e412f1f Make HDR one fixed look with true blacks, and keep only its on switch and the three whites as settings.
HDR on is the game's scene through the observer-response mapper, anchored to the game's own mid grey and tone slope, with half of the hue bend of the game's clamp: the defaults the menu had. The tone mapper choice, the mid grey, the tone slope and its match, the hue clip, exposure, highlights, shadows, contrast, saturation, highlight saturation, blowout, flare, hue, grade and gamma are gone from the menu, the settings table and the example ini; a file that still sets them works as before, the keys read by nothing and logging nothing. The menu's HDR row is Off and On, with the peak, game and HUD whites under it. The game's own HDR is still there for a file that sets hdr = native, and the row lists it only then. The luminance mapper and its grading code, which no setting reaches any more, are removed from the tonemap library, and the support buffer carries one vec4 for it.

The dark tones of a dark scene sat far above black: the present showed the game's sRGB-encoded picture as that encode decodes, linear near black, while the game is graded for a display of gamma about 2.2, and since the observer-response mapper became the default the 2.2 correction ran with the luminance mapper only. A scene value of 0.003 came out at 0.29 nits at a white of 350 nits, where a 2.2 display shows the game at 0.015. The present now always shows the picture as a 2.2 display would, and the tonemap aims its peak lower by that correction's inverse, so the brightest light still reaches the display's peak; the same value comes out at 0.017 nits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:06:30 -05:00
chrg6
358ad54105 Log the luminance of HDR10 shots and keep their raw pixels, and show an HDR shot as a 2.2 display would.
A shot taken from an HDR10 swapchain (the menu's test hook, NX2NAVI_SHOT_EVERY) now writes the picture's luminance in nits to the log, the darkest pixel, four percentiles and the brightest, and its pixels as the swapchain holds them beside the PNG. The PNG of such a shot shows the HDR display's light at the HUD's white through the power 2.2, not the sRGB curve, so a dark tone the HDR display lifts looks lifted in it too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:06:30 -05:00
ordinarybob
c51ac7c877 Keep released render targets between the limit of released textures and a hard limit: only stale entries that come back intact or were overwritten go there.
Past 2048 released entries the oldest one that nothing sampled lately went. A render target can be used again long after anything sampled it: in Kokiri Forest two targets released at the area's load went about two minutes later, were used again after that and made again empty. On an 85 s route there a frame came out black in 1 of 12 runs, with the two targets dropped in 7 of them; with such entries kept, in 0 of 18. The sampled-lately rule holds from 16384 released entries on.

Co-Authored-By: Claude Fable 5.2 <[EMAIL]>
2026-11-11 14:37:11 -05:00
epicmeme546
bd7d52611b Merge the menu's Window size and Resolution rows into one Resolution row, and name FSR 4 by the version the driver runs.
The Resolution row lists each picture height as the size of the game's shape at it (21:9: 2560 x 1080, 3440 x 1440, 4300 x 1800, ...; the window's own shape where the picture follows the window) and sets both the picture's height and the window outside fullscreen, which follows at once within the monitor; the picture's height takes effect after a restart as before, and Native leaves the window as it is. A build without the widescreen patch sets, which draws the game's own size, keeps the Window size row.

The Upscaling rows and the overlay name FSR 4 by the major and minor version of the provider the driver lists (AMD FSR 4.1 for 4.1.2), and AMD FSR 4 until the library was asked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 14:06:16 -05:00
epicmeme546
760a7aaaf9 Hold a memory region thawed after a write thaws it soon after its freeze, so the game's streaming buffers stop going back and forth between frozen and thawed.
Regions the game has not written for a while are write-protected so that the per-submission write-watch queries can skip them, and the first write thaws them. The game's loaders keep writing the buffers they stream an area into, so those regions were frozen again as soon as they had been idle a moment and thawed again moments later: running from the Kakariko Village gate across Hyrule Field froze 31,004 regions and thawed 28,918 by a write in nine minutes. While the loaders wrote and the driver locked new memory, each thaw's VirtualQuery took 15 to 20 ms: a loader thread stalled 78 to 111 ms in thaws in every one of the hitches of 125 to 140 ms of that walk, with the game's main thread waiting for it.

A write that thaws a region within a minute of its freeze now holds it thawed for 4 seconds, doubled at each such thaw up to 10 minutes; a region that stayed frozen longer starts again from nothing. On the same walk: 8,284 freezes and 6,355 thaws, no frame over 100 ms while Link ran where 29 and 52 a minute had been, the slowest 1 % of frames at 19 and 24 fps instead of 9 and 7, and at the walk's end, Link standing at the edge of Lake Hylia, 60 fps instead of 38 with the slowest 1 % at 43 instead of 20. The perf trace's write-watch line counts the holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 14:06:16 -05:00
epicmeme546
9fee9c781f Let a test route's sidesteps go three times to the same side before the other, so Link goes round a wall instead of rocking against it.
Turned to alternate sides every time, he stayed pressed against the cliff face south of the Kakariko Village gate for ten sidesteps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 13:19:24 -05:00
epicmeme546
8c239ee4b5 Merge main: its fix for the see-through ground with its finalize counters, which take the place of the counter of this line, and the AppImage runner fixes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 12:55:32 -05:00
epicmeme546
4e3280c2a7 Make debug-menu teleports always use a start position the area lists, move Link on when he falls through the ground after arriving, and keep the free camera above the ground.
A teleport without a start position, or with one the area does not list, put Link where nothing held him: in Kakariko Village he fell for good, and the game refuses events, teleports included, while Link is in the air. The game's list has an empty name in 45 areas, which the Teleport tab listed as a default start; those entries are left out, and such a request takes the area's first listed position. For a few seconds after arriving, Link falling 25 m below where he arrived is taken for a fall through the ground, and the area's next start position is asked for, up to three times.

The free camera's left stick moved it along its view, so a camera looking down flew into the ground, and below it the picture showed the void under the map, which looks like ground the game failed to draw. The stick now moves it level, only ZR and ZL change its height, and with DLSS, DLAA or FSR 3.1 or 4 on, nine of the view distances the upscaler's motion pass works out (vk_dlaa.c fcam_probe) come back each frame and the camera rises where the ground ahead or below is within a clearance that grows with its speed. Flown at 25 m/s two metres above Hyrule Field, it went over every hill.

For test runs, NX2NAVI_DBG_TEST gains route and routeto: Link is steered through points, or through the area's own start positions, from the way he moves, and sidesteps where he stops gaining ground. The start positions' coordinates are read from the same file as their names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 12:53:59 -05:00
epicmeme546
7b201d868e Drop only stale released textures under VRAM pressure, let textures give way only when the system's commit runs low, and count the heightmap slots a finalize now leaves current.
Above the VRAM pressure threshold the released textures that come back intact were dropped oldest first, however recently released. The game releases and takes back hundreds a frame in towns, so the list is mostly those, and each drop was made and uploaded again within frames and freed nothing. With the budget taken as 7.5 GiB (NX2NAVI_VRAM_BUDGET_MB), seven minutes of teleports between Hyrule Field, Kakariko Village, the Graveyard, Death Mountain Trail and Kokiri Forest dropped 82,288 and stayed over the budget throughout; with 11 GiB, 178 draws met a texture that was gone. They now go by the rule drop_stale keeps (released STALE_FRAMES ago and idle): on the same tour 34,699 drops, a fifth fewer textures made again, a third less time the render thread waited on textures, 4 draws of a missing texture instead of 11, and the slowest 1 % of frames in Hyrule Field afterwards at 32 fps instead of 22.

Past the process's own commit bound (tex_proc_commit_mb), textures were dropped and idle live ones evicted as under a low system commit. The bound compares the commit less the video memory in use, and a dropped texture lowers both sides alike, so nothing a drop did could bring the process back under it: textures went one after the other for as long as the rest of the process stayed large, and the ground flickered white with the system's commit to spare (#434). The bound now only writes its line into the log.

The perf trace's texture origins line counts the slots a finalize leaves current because another texture of the same parameters was registered at the storage since (the terrain heightmaps of pull request #535): 173 at the load of a Hyrule Field save, and between 40 and 365 every 60 frames while Link runs through the field, each of which the old rule left stale.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 12:53:58 -05:00
epicmeme546
b5789c6bec Keep one FSR 4 and one FSR 3.1 context per output size, free the ones no upscale used for 90 seconds, and let FSR 4 recover from failed creations.
Each upscaling mode made a context of its own (about 217 MiB of video memory for FSR 4 at 3440x1440, 50 to 70 ms each), up to six were kept beside FSR 3.1's, and three FSR 4 creations that failed in a row turned FSR 4 off for the run: the menu then showed FSR 3.1 and no longer listed FSR 4. A player's log had the third failure (error 3) right after stepping through the modes with ten contexts alive. A context now takes every render size up to its output size, which the API allows at each dispatch; a creation that fails frees every context not in use, FSR 3.1's idle ones too, and is tried again; FSR 3.1 serves the frames between tries two seconds apart; only four failures in a row turn FSR 4 off, and choosing it in the menu again tries it anew.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 12:33:36 -05:00
chrg6
ae0c8140a2 Finalize only the slots a texture object registered itself, so the next streamed piece of ground keeps its heightmap.
Ocarina streams its terrain heightmaps (R32F, 260x260) through a fixed set of storage. It initializes the next piece's texture at the storage of the one before, registers it in the texture pool, and only then finalizes the old texture object, which has the same parameters. vk_texture.c vk_texture_release marked every slot at the storage with the same parameters as finalized, the new registration too. A finalized CPU-written slot takes no image made from its storage again (slot_resolve's stale rule), so the new piece drew the zero stand-in and was drawn at height zero, far below the ground around it: the holes and stretched ground of issues #453 and #569, through which the sky shows. A finalize now marks only the slots registered with its own texture object (the initialization serial); a slot registered with another texture object at the same storage names that one, which is still live.

From pull request #535 by MartinIsla, in its final form, which no longer skips the whole release while another texture with the same parameters is live (that kept textures the game had released and drew dark lines in Kakariko's fog). --probe-vkmem gets the pull request's check: a release leaves another live texture's slot current and marks its own; it fails on the old rule and passes with this one, with and without shadow storage.

Added here: under the perf trace a line every 60 frames counts the slots a finalize marked, the slots of another live texture it left current and the lookups the stale rule answered with the stand-in, the terrain's heightmaps counted apart, so a run shows whether the case comes up and whether stand-ins are still drawn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 12:18:52 -05:00
epicmeme546
8afca0922a Merge the fix for sunken terrain chunks from pull request #535: a finalize marks stale only the slots its own texture object registered, so a streamed heightmap registered at the storage of the one before it keeps its slot.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 11:28:41 -05:00
chrg6
d55f7e763d Make co-op a hidden beta in 0.8.0: the menu shows its Co-op tab only with coop_beta = 1.
No menu row sets coop_beta; it lives in nx2navi.ini under [coop] (NX2NAVI_COOP_BETA) and takes effect at once. Co-op
itself is unchanged: coop = 1 still runs a session with or without the tab. The notes and the co-op guide say how to
show the tab.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 09:47:42 -05:00
chrg6
4f85f3d59a Leave the pools as imports for NVIDIA's own driver on Linux in the game itself.
On Linux every driver got shadow storage (copies of guest memory beside it), which exists for amdgpu, where importing guest memory costs the write protection of its pages. NVIDIA's own driver imports without that cost, so there the copies are only the slower path: in Kokiri Forest on 0.7.1 (RTX 4090) imports ran at 51.9 frames a second and the copies at 27.4. Until now only the AppImage's play.sh knew, by setting NX2NAVI_SHADOW=0 when NVIDIA's kernel driver was present at build time, so a game started any other way got the copies, and a PC with that kernel driver whose game ran on another card got imports where it should not. The game now chooses by the driver of the device it runs on, play.sh no longer sets the variable, and NX2NAVI_SHADOW=1 or 0 still decides. The driver is asked when the device is picked, before the storage is chosen.

Windows is unchanged: the device probe here reads "mem: mode mirror" with no shadow storage line, and the shadow line with NX2NAVI_SHADOW=1. The Linux path itself was not run: there is no Linux machine here.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-11 08:58:48 -05:00
chrg6
c308ee6510 Past the limit of released textures, drop one that nothing sampled lately, not one that no lookup reached.
The rule that spares a released entry the game still uses went by lookups, and the texture pool's refresh looks up
every registered slot in each submission that draws through the pool. With the game's own upscaler in use
(upscaler = fsr) its render targets move to new addresses in every frame and each leaves a released entry behind
whose descriptor stays registered: all 2,049 entries counted as looked up, the sweep fell back to the oldest lookup,
which among entries stamped in the same submission is no order, and took entries still drawn, 200 to 450 per 60
frames over a town, with buildings black or wrongly lit for single frames in a player's captures.
The entry that goes is now the oldest release that is overwritten or that nothing sampled or drew into for 120
presents (samp_frame: the pool marks and every lookup that is not the pool refresh), and only when all were sampled
within that time the one sampled longest ago.
Checked: it builds, and a player's hand test of 30,000 frames through eight areas with that upscaler kept the list at
its limit, dropped 50,182 entries past it and showed none of those frames. No scripted run was made, and which
entries pile up in a town was not traced to their kinds.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-11 08:58:13 -05:00
chrg6
ff3bfd1a4a Let the wait after a frame's first submission write the results the game reads before it returns.
That wait ends when the GPU has run the submission's own commands (wb_split = 1). The completion thread was then still
at the last frame's submissions, so the occlusion counts, counter reports and event values the game reads next reached
its memory after it had gone on. A player's capture in Hyrule Field shows the result: trees, ground and walls lose
their direct light for single frames about every 36 frames, 57 of 1,800 frames, and with the fence's wait
(wb_split = 0) the same place showed none.
The fence's wait also covers the rest of what the completion thread does for those submissions, 0.23 to 0.40 ms a
frame of page stamps the game does not read. So those results now have a queue of their own
(vk_completion_add_result), and the waiter runs the ones due for its submission and the ones before it as soon as
the GPU's signal is there; the completion thread runs them the same way, ahead of its other callbacks, one runner at
a time and in the order they were queued. wb_split = 3 is the bare wait as it was, to measure against.
Checked: it builds, the launcher tests and the address table check pass, and the player's hand test of this wait at
that place showed no such frame. Not measured: no scripted run of it was made (the one scripted run with the bare
wait in that field shows 1,170 occlusion counts a frame written late and no dark frame, so the script does not
reproduce the fault), and its cost against the bare wait is not known.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-11 08:58:00 -05:00
chrg6
bdc67cebfc Take out the GPU address history of a lost device's report.
The author of the pull request it was ported from closed that request on 2026-11-11 with the words that they give no
permission to use its code. The history (NX2NAVI_VA_REPORT, runtime/vk_vaddr.c, the stack walk it used and its notes
in the docs and the example settings) goes; the lost device's report keeps the breadcrumbs, the pass marks, the video
memory and the driver's fault information.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-11 08:18:55 -05:00
chrg6
3d394dd84e Merge the fixes line: the stutter, memory, flicker and crash fixes, co-op, the mesh shader fallback and the launcher fixes.
Brought onto the line with FSR 4, its frame generation and the debug menu. Where both sides had added to the same
place, both stay: the patch table keeps the pickup count and the free camera, the settings list keeps both sides'
names, the menu includes the co-op page and the debug menu, and the launcher builder takes the pipeline list and the
FSR 4 folder. Both sides had added the menu's typed-character event; one definition stays, with the window code that
passes characters outside the basic plane.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-11 08:18:01 -05:00
epicmeme546
b59c0d40a8 Add a free camera to the debug menu.
With it on, the game draws from a camera of the menu's instead of its own, in play and in cutscenes. The left stick moves it along its view and sideways, the right stick turns it, ZR and ZL raise and lower it, R makes it faster and L slower, and Link stands meanwhile; or the camera stays where it is and the pad plays the game.

It works inside the game's own camera update: a new patch site sends the instruction at which the frame's position, target and up vector are final to a host function, which replaces them for the camera that follows Link and the one the events direct, so the game draws, culls and loads detail for what the free camera sees. The camera of the interface's 3D models and the one the sound follows stay the game's. The set is off unless the menu switches it on. A teleport's arrival starts the free camera again from the game's view.

Tested in Hyrule Field with scripted stick input (turn, rise, strafe, with Link's position unchanged), with the pad playing while the camera stays, across a teleport to Kakariko Village, during the Kakariko arrival cutscene, and switched on by a click in the menu.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-11 08:04:19 -05:00
chrg6
6a8ebe7241 Give the freezing of idle memory regions a time budget and back off when a freeze is slow.
A freeze (a VirtualQuery and a VirtualProtect of 2 MiB) takes microseconds as a rule, but in the second after an area
load each took 8 to 17 ms. The newly loaded regions all go idle together, so 32 came up in one submission: its mirror
begin took 70.5 ms and the frame 78 ms, and a 9 ms freeze followed in each of the next 20 frames. In a play session
363 regions were frozen in the second after Kakariko loaded and 70 to 120 a second for the next 20 seconds, with the
frames over 50 ms in the same windows. A pass now stops once it has spent NX2NAVI_FREEZE_BUDGET_US (default 1000;
0 as before), and a freeze over 2 ms holds the passes for 250 ms, doubled for each slow one in a row up to 2 s. On the
Kakariko route the time in slow memory calls after the load went from 1374 ms in 170 calls to 115 ms in 18, the 78 ms
frame is gone, and the regions freeze some three seconds later, once the calls are fast again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 08:00:36 -05:00
chrg6
3ecede66f7 Log write-watch queries, freezes and mirror begins that take over 4 ms.
A frame some ten frames after an area load took 51.6 ms of replay with 1.2 ms of it in the replay's ops; the replaying
thread's samples sat in GetWriteWatch under vk_mem_mirror_begin and in the freeze's VirtualProtect. The lines say which
call and how much memory, under NX2NAVI_TRACE=perf.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 07:47:09 -05:00
chrg6
0f1885f9fd Count the game's GPU waits that return while event-ordered work is still held.
A submission stopped at an event wait returns its value with its remainder held for a later replay, so the game may
take its wait as the whole submission done. The log now says how often that happens, which decides whether the value
should be signalled only after the remainder. Audit finding F-2-05, first step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 07:47:08 -05:00
chrg6
2d48afb052 Open the menu when the gamepad in use goes away and no other is connected.
The game is always told one controller is connected, so a disconnect read as nothing pressed and play went on without
the player noticing; the console would stop and ask for a controller. Audit finding F-8-04.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 07:47:08 -05:00
chrg6
83faa1daca Let a pool's finalize wait for the submissions issued so far instead of the idle queue.
The finalize of a used pool flushed and waited for every upload batch and then for the idle queue. During an area load
the queue also holds the load's texture uploads, which name no pool's storage: entering Kokiri Forest, one finalize
waited 418 ms and the frame took 462 ms. The game finalizes a pool once its own work with it is done, so the finalize
now waits for the submissions issued so far and returns; the pool's buffer and memory go once the upload batches handed
out by then and the submission being recorded are through. NX2NAVI_POOL_FINI_IDLE=1 keeps the old wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 07:37:38 -05:00
Martin
2765a752b0 Finalize only the slots a texture object registered itself, so a finalize no longer touches another live texture's slots at the same storage, and drop the early return that skipped the whole release when such a texture was live, which also kept textures the game expected released (Kakariko fog lines).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 09:30:37 -03:00
epicmeme546
fe3126e9a7 Add teleporting and cutscene starting to the debug menu.
The Teleport tab lists every area of the game with its named start positions, read from the player's own game files: the warp songs' pads, both sides of the loading zones and the boss rooms among them. A click changes area the way the game's own doors do: during a short event of the game that only waits, the menu reserves the next area and start position in the game's data and asks the game's sequence for the change, so the area unloads and loads as in play, a first visit's cutscene plays and a boss room starts its fight.

The Cutscenes tab lists the game's event scripts by name and starts one through the game's event manager.

Tested from Hyrule Field to Kakariko Village, the Forest Temple, Kokiri Forest in the child's time, the bottom of Lake Hylia, Volvagia's room, and the pads of two warp songs, four of them in one run, with Link walking afterwards; the Kakariko arrival cutscene started by name.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-11 07:29:17 -05:00