Commit Graph

71 Commits

Author SHA1 Message Date
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
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
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
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
295922c224 Sync the device address table's shadows once per guest submission that binds the table, and take out the port of pull request #353.
The author of pull request #353 closed it on 2026-11-11 with the words that they give no permission to use its code. Its port (3134f524) goes: the mark of a pipeline that declares the table (VkPipeInfo.gpa, vk_pipeline.c pipe_add) and of the part that draws with it (vk_mem_gpa_use in vk_exec_draw.c bind_resources and mo_emit), the sync of the table's pools in every such part's prologue (vk_mem_gpa_sync), the submission with a callback in the replay's place as it stood (vk_sync_probe_submit), and --probe-vkmem's read through the table with its shader (test_gpa_read, runtime/shaders/gpa_read.spvasm).

In its place, after pull request #551, which was written without that code: a shadow pool goes into the table and onto a list of the table's shadows (vk_memory.c shadow_table_add); the record of a binding of the table notes the guest submission (vk_exec_draw.c ssbo_info, vk_mem_shadow_table_read); and vk_mem_shadow_sync brings the CPU's writes into every shadow on the list once for that guest submission, before the part is submitted. Once is enough, because the copy-ins read the guest submission's write-watch snapshots, which a second sync would find unchanged. Measured by #551's author on Linux (RTX 4090, Kokiri Forest): 113 and 76 frames over 25 ms in 75 s against 217 and 429 with the port, 43 against 41 fps, the picture complete in both.

What this line had built on the port stays, on the new sync: the test that passes over a pool with nothing written (shadow_pool_clean), the upload of the same pages into a table pool's VRAM mirror, the write-back of stores through the table (NX2NAVI_SHADOW_TABLE_STORES, table_wb_cb, now asked once per guest submission that binds the table) and the counts of NX2NAVI_SHADOW_CHECK. The probes that record their own commands (the lost-device probe, --probe-vkmem's table parts) call vk_sync_submit_own, written anew. vk_mem_shadow_storage stays: one line that returns the mode. Finalized pools in the table were already kept for vk_mem_shutdown here.

--probe-vkmem has a check of its own for the sync (test_table_sync): the shadow of a pool that is never bound keeps its old word through a CPU write and a guest submission that does not bind the table, and holds the new one after a guest submission that does. It passes with NX2NAVI_SHADOW=1 on Windows (RTX 5090), as do the store check with NX2NAVI_SHADOW_TABLE_STORES=1 and the probe without shadow storage; --probe-devlost ends as before. Not run: the game, with or without shadow storage, and anything on Linux.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-11 06:10:09 -05:00
chrg6
a8c6e992ee Draw task and mesh programs through compute passes when the mesh fallback is on.
A mesh draw becomes its record (the workgroup count, copied on the GPU for an indirect draw), the task dispatch, a
scan that lists the mesh workgroups the tasks started, the mesh dispatch, and an instanced indirect draw with a
generated vertex stage and the program's fragment stage. The compute modules bind the resources of the task and mesh
stages, and their pipelines are made on a thread of their own while the program's draws are skipped.

The indirect mesh ring and the texture pool marks are released at a probe's shutdown.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-11 05:58:42 -05:00
chrg6
fc1a50f0db Merge the audit: its map and ledger, the perf-trace markers and size lines, and the fixes of its Phase 4.
Verified by runs in the audit: the Market's periodic stall (a pool slot was listed once per refresh pass instead of once; the list fell from 160,385 entries to at most 3,192 and no frame over 20 ms remained while standing), orderly exits delete the pipeline prebuild's running marker (left behind, the next start wrote a skip file and every later start skipped the prebuild), the log and crash report name an area a save asks for that the game does not have, and the menu atlas hash no longer overflows a signed multiply. The other fixes compile and pass the regression route but their faults were never reproduced: see AUDIT.md section 13 for each.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-11 00:39:08 -05:00
chrg6
b933e3d996 List a texture pool slot without an entry once, so the walk over those slots no longer stalls every 8th frame in the Market.
A slot that resolved kept its place in the list until the next walk, and when it stopped resolving before that walk it was listed again. The list reached 160,000 entries for the 32,768 slots after a minute in the adult Market, and each walk over it held the texture lock for 15 to 30 ms.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 23:21:39 -05:00
chrg6
f29e34e7a0 Make the observer-response scene mapper the default HDR tone mapper, anchored to the game's mid grey and tone slope.
The HDR tonemap gains a mapper built on a finite cone response in LMS: scene grey 0.18 lands where the game's curve puts it and rises through it with the slope of the game's curve, and the hue bend of the game's clamp is given back to bright colours. It takes the scene before the game's exposure gain and the gain itself, which the splice now finds in the game's shader. The luminance mapper stays selectable and the game's own curve stays the third choice. The mapper fits the Rec. 709 gamut here, as the game's scene target holds no negative component. New settings: the tone mapper's mid grey, tone slope match, tone slope and hue clip emulation. The gamma correction on the present applies with the luminance mapper only.

Not part of this: eye adaptation, the anti-aliasing and reconstruction shaders, bloom and local exposure sliders, the output colour space choice and a 16-bit float scene target. Checked by build and numerically against the source of the port; the picture on an HDR display has not been judged. THIRD_PARTY_NOTICES.md names the source.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 23:20:31 -05:00
chrg6
ded13958de Log the sizes of the caches, pools and tables under the perf trace, every 600 presents and with each memory snapshot.
Four "mem: sizes" lines give the entries and bytes of what no other line counted: the guest heap, physical maps, kernel region, lazily written ranges and the fixed kernel, setjmp, save-file, RomFS and zstd tables; pool records, mirrors, deferred destructions, upload and staging buffers, the device address table and the texture, sampler and slot caches; image views, descriptor spares, the completion queue, uniform snapshot arenas, recording copies and pins; and pipelines, layouts, stage libraries, job queues, the shader memory cache and the translator processes. Each subsystem reads its own counters under its lock; settings now count the replaced values they keep. Segment and scene lines say "-" for the world clock before it starts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:51:36 -05:00
chrg6
892859cad0 Fill the records of a run of indirect mesh draws in one gap, so their pass is not cut at each of them.
An indirect mesh draw reads its workgroup count through a ring entry that a buffer copy fills, and a copy cannot be
recorded inside a pass: every such draw ended its pass, 45 times a frame in a village. The first draw of a run now
fills the entries of the mesh draws that follow it with only state, draws, counter reports and render conditions
between them, and those draws stay in the pass (mesh_ahead, default 1; 0 is the old way, ab switches in A/B blocks).
An entry is taken only by the draw it was filled for, at the same record address, while no other op was replayed
since. Counter reports count as staying in the pass because the replay closes their query inside it and writes the
value from the completion thread; the game reports one after most of these draws, and without that only 38% of the
draws were served.

Measured in the village: 42 of the 45 draws a frame are served by an entry filled ahead; gaps with these copies
41 to 3 a frame (0.22 to 0.04 ms of GPU time); passes and dispatches 248 to 208 a frame (302 to 254 in Hyrule
Field). With the piece release of the commit before, one run each: village 142.6 fps and GPU busy 3.87 ms (138.0
and 135.4 fps, 4.15 ms without this change), Hyrule Field 136.8 fps and 4.34 ms (131.5 and 131.3, 4.70 ms). In A/B
blocks of one run with the narrower rule (counter reports still ending a run) the GPU's busy time went from 4.81 to
4.64 ms.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 16:44:02 -05:00
chrg6
682d9c5c50 A draw does not wait for the fast link of a mesh pipeline that is known to be compiling.
A draw whose pipeline is missing waits up to 3 ms for its fast link before it is skipped, 6 ms a frame in all. A mesh pipeline has no stage libraries and gets no fast link, so for the 0.2 to 1.1 s of its compile every frame that drew with it lost those milliseconds and skipped the draw all the same. Once such a pipeline has been building for longer than the 8 ms a cached one needs, its draws are skipped at once, as the one-shot mesh draws already are.

Not run in the game yet.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 14:52:25 -05:00
chrg6
61c4c873d5 Merge branch 'claude/pipeline-stutter-110e1b' into test-all-fixes
# Conflicts:
#	docs/building.md
2026-11-10 14:18:29 -05:00
ordinarybob
4a954a1c6d Refresh the texture pool from a list of its entries instead of walking every slot, for about 7 % more frames a second where the replay thread is the limit.
Each submission's first sync of the bindless texture pool walked every registered slot, 33,000 in Kokiri Forest, to find the few textures the CPU wrote and the few slots that changed. Three parts of that walk change, each with its own switch (pool_fast, pool_presnap, pool_group; on by default, 0 and ab accepted):

- The freshness check goes through a list of the entries the slots resolved to, with a check by 2 MiB region first; slots that resolved to nothing are looked up again when the game's memory map changes and every eighth submission. The use stamps the idle eviction reads are left from a count of the slots that hold each entry.
- The check takes the write-watch snapshots of its regions first, so unchanged entries pass the region test.
- The GPU-written slots of one address bucket with one descriptor form a group, which the dirty walk leaves alone while its first member is unchanged.

Measured on an RTX 5090 at 2560x1440, standing in Kokiri Forest, in-run A/B over five runs with all three switched (three of them with the barrier change switched too): 93.6 to 100.7, 96.4 to 103.1, 95.8 to 102.6, 99.3 to 107.1 and 91.9 to 99.9 frames a second, the replay thread 0.7 to 0.8 ms a frame shorter; a control's blocks differ by 0.4 %. On a walk with NX2NAVI_POOL_GROUP_CHECK=1 no group that was left alone had missed a write, and screenshots across the A and B blocks show the same picture.

From pull request #390. Not tried: the texture eviction under memory pressure (a 9 GiB budget was never reached on the walk), AMD and Intel drivers, Linux. One of the nine runs with it on ended by itself with exit code 0 and nothing in its log two seconds after the window lost the focus; three repeats of that run did not.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 14:09:21 -05:00
ordinarybob
ce206a9239 Order passes and dispatches by the game's own barriers on NVIDIA graphics cards, which takes about a tenth off the GPU's time for a frame.
Every pass begin and every compute dispatch recorded a full barrier, which makes the GPU finish everything before each of them. With barrier_game = 1 (NX2NAVI_BARRIER_GAME) a pass after an earlier pass gets a barrier for its attachments only and a dispatch after other dispatches gets none; a change between drawing and compute keeps the full barrier, and so do the game's own barriers and the replay's copies, clears, fills and uniform updates. On an RTX 5090 at 2560x1440 the GPU's time for a frame fell from 5.4 to 4.9 ms standing in Kokiri Forest (two in-run A/B runs, the control's blocks differ by 0.7 %) and from 5.1 to 4.4 ms on a walk through it. The frame rate did not change there, because the replay thread is the limit on that machine; it should rise where the GPU is.

The default is 1 on NVIDIA graphics cards only, and 0 on every other vendor's: the game placed its barriers for an NVIDIA GPU, Vulkan asks for more of them than the game recorded, and no AMD or Intel driver has run this. 34 screenshots across the A and B blocks of one run show the same picture on NVIDIA. NX2NAVI_TRACE=perf logs the barriers a frame by kind.

From pull request #389, which had it on for every vendor; the default by vendor and the settings text are added here. The validation layer's synchronization check could not be run on this machine.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 14:08:48 -05:00
chrg6
e9ec6de6bc A render target's frame count follows its storage, not the guest's texture object, and a mesh draw no longer waits for a pipeline that is known to be compiling.
Found in the first run of the previous two commits (a first visit of Kokiri Forest from a state that had only seen Hyrule Field):

- The count of frames a target was rendered in started again whenever the guest's texture object changed, and the game initializes its render target objects anew every frame at the same storage: the log showed `seen 2129/2128 in 1 frames`, so no target ever became steady and the rule did nothing. The owner of an image is now the storage address the texture cache keys it by. An image handed on to a texture elsewhere still starts at none.
- A one-shot mesh draw waited its 8 ms in every frame that met the same pipeline while it compiled for 150 to 1100 ms: 17 waits, 170 ms, every draw skipped at the end, up to four in one frame. A mesh pipeline that has been building for longer than that wait is a compile, and the draws after the first do not wait for it (vk_pipeline_building_ms).
- The last wait of a full-screen draw with no picture to hold was 40 ms a draw, and two such draws made 86 ms in one frame. It is 40 ms a frame now.
- A one-shot vertex draw skipped at the end of its wait gets its log line however short the wait was (seven were skipped with no line, so their targets could not be named).

That run against the same cell of the earlier comparison (same exe path, cache state, route and settings; one run each): the load's worst wait of the draws in one frame 99 ms against 735 ms, no mesh wait over 13 ms against 524 and 206 ms. Two long frames remain in both runs (628 and 862 ms here, 660 and 854 ms there): two compute pipelines built at their first dispatch, about 395 and 397 ms.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 12:14:29 -05:00
chrg6
bfcefe6fa2 A frame no longer stops for the pipelines of an area's first frame: passes the game renders frame after frame stay per-frame through a loading screen, and the waits that remain share 50 ms a frame.
A draw whose pipeline is still building is skipped when its pass is rendered every frame and waits otherwise, so that a lookup table or a volume generated once is not left empty. "Every frame" meant "in the last four frames", so after a loading screen or a full-screen menu every pass of the first frame read as new: each draw with a new pipeline waited on the replay thread, up to 30 s each, and a mesh draw, whose pipeline has no fast link, for its whole compile. A player's 0.7.1 log shows it at three area changes: frames of 954, 1015 and 684 ms with 853, 960 and 663 ms of pipeline wait, six mesh draws waiting 52 to 660 ms in passes whose targets had been rendered in thousands of frames.

The target history (now runtime/vk_target_frames.h) also counts the frames each target was rendered in, for as long as it is the same guest texture. From eight frames on its pass is per-frame however long ago the last one was, and its draws are skipped and built by the workers like any other (pipe_skip_steady, on by default). A target rendered for the first time still waits, now from one pool of 50 ms a presented frame that the full-screen draws share (pipe_frame_wait_ms; oneshot_budget = 0 gives the old wait back), a mesh draw 8 ms at most, and the wait for a one-shot draw's shader comes from the same pool (gfx_shader_await takes a limit). A full-screen draw with no picture left to hold waits 40 ms more instead of 500. One frame so waits under 100 ms for pipelines in all.

Every 600 frames with a miss the log says how many draws found a shader or pipeline missing, how long they held the replay thread in all and in the worst frame, by the kind of wait, and how many were skipped at its end.

tests/target_frames_check.py replays the area change of that log against the header. Not yet run in the game.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 12:02:12 -05:00
chrg6
0e16e58cf3 Merge the shader stutter fixes into the combined test line.
Eight commits: a draw that misses its pipeline has the rest of its submission read ahead, the library workers link
the pipelines of skipped draws, a pipeline whose fragment shader reads a target of its own pass is fast-linked like
any other, and diagnostics. The merge was clean. Their before and after matrix had not finished when this was merged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 11:05:17 -05:00
chrg6
22cff8f1f9 The program lead diagnostic covers compute programs too: the time between a compute program's creation and its first dispatch.
A large compute shader is built at its first dispatch, on the replay thread (470 to 720 ms each on a first visit to
Kokiri Forest), so whether its program exists long before that dispatch says whether the build could start earlier.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 10:11:32 -05:00
chrg6
ca843507e9 A diagnostic says how long before its first draw the game made each program (NX2NAVI_PROG_LEAD=1).
Shaders are looked up and pipelines built when a draw first needs them. The time between nvnProgramSetShaders and a
program's first draw is the head start a build begun at the program's creation would have; the line gives it as
counts under 17 ms, 100 ms, 1 s, 5 s, 30 s and over, mesh programs apart (vk_exec_draw.c prog_lead,
nvn_api_obj.c nvn_prog_made_ns). Off unless asked for.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 10:03:54 -05:00
chrg6
a38a902702 The longest wait of one draw for its fast link is a setting (NX2NAVI_PIPE_LINK_DRAW_MS), 3 ms as before.
It was a constant beside the per-frame budget (pipe_link_ms). With the stage libraries in the driver's cache a fast
link takes 4 to 17 ms for a third of the pipelines a draw misses, so both values decide how many such draws are left
out of a frame; the setting lets that be measured.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 10:00:20 -05:00
chrg6
fdf2fb89d3 A draw that misses its pipeline has the rest of its submission read ahead, and the stage libraries of the pipelines the later draws need are queued at once.
The next draw with a new pipeline was only found when the replay reached it, so the draws of an area's first frame,
or of a turn that brings several new materials into view, paid for their pipelines one after another while the
workers that could have built them together sat idle. The submission is recorded before it is replayed: the first
draw of a submission that finds a shader or pipeline missing now has the ops after it read (vk_exec.c vk_exec_ahead)
with the binds that decide a draw's shaders and shader libraries applied to a copy of the replay state. Each draw
there looks its shaders up as the real draw will, which also queues a shader that is not in memory, and names its
state to vk_pipeline_hint, which queues the pre-rasterization and fragment shader libraries that are missing. No
pipeline is entered and no key recorded, so a wrong guess costs two libraries at most. The draw's own lookup then
links on its thread when both libraries are there.

On a first visit to Kokiri Forest a scan read 6,900 ops in 0.78 ms on average (the longest 5.5 ms; a scan ends
after 3 ms), and the scans of the load and the walk named 377 states without a pipeline and queued 104 libraries
for them.

pipe_ahead = 0 (NX2NAVI_PIPE_AHEAD) turns it off.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 10:00:20 -05:00
chrg6
eeeeec683b The pipeline statistics say how long a missed pipeline took to become usable and which stage libraries were slow, and a draw counts as skipped for its pipeline only when it was skipped.
- Every pipeline a draw missed is timed from the miss to its first usable pipeline, the fast link or, without one,
  the build itself (vk_pipeline.c ready_note): the gpl lines of a save give the counts under 4, 8, 17, 50 and 150 ms
  and over, the average, the longest, and how many had no fast link. That time is how long the pipeline's draws were
  missing from the picture or waited.
- The stage library lines add the libraries of 25 ms or more and their sum, and the pre-rasterization libraries that
  had outputs added for their fragment shaders: those are another module than the one the preparation built, so the
  driver's cache has none of them.
- "a draw waited" lines name a pipeline with a feedback loop.
- The "draws skipped for a pipeline" counter (overlay, perf lines, flight records) was raised by every lookup that
  found the pipeline building, also when the draw then waited for its link and was drawn. It is raised where the draw
  is skipped now (vk_exec_draw.c draw_skipped).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 10:00:18 -05:00
chrg6
8603b0e1e9 Add the texture_detail setting, which makes large ASTC textures without their largest one or two mip levels on cards with little video memory.
The textures of a loaded area are what fills a 6 GiB card: with the budget taken as 4,730 MiB a walk through Castle Town held 6,907 MiB of device memory, 4,302 MiB of it textures, 201 pools were refused their mirrors and the game ran at 20 fps. With texture_detail = reduced a mipmapped 2D or 2D-array ASTC texture of 256x256 and more that the game's CPU fills is made without its largest level, with low without its two largest when it is 1024x1024 or more. The same walk then held 5,472 MiB (textures 2,357) and 4,987 MiB (textures 1,997), and the ASTC texels decoded fell from 2,589 M to 826 M and 503 M. auto, the default, picks full from 8,192 MiB of device-local budget, low under 6,144 MiB and reduced between. full changes nothing.

The image holds the game's levels from the one it starts at (VkTexImage.skip), and the upload with its ASTC regions and BC3 encoding, WriteTexels, the write-back, the views and the sampler LOD clamp of combined bindings count from there. Render targets, storage images, 3D and cube textures, small and unmipped textures and textures the device samples as ASTC itself are left whole, as is a texture made over a live one that holds GPU-written content. A shader that fetches texels by position or uses a texture's size gets the texture whole: gfx_shader.c marks such bindings from the SPIR-V (the layer count of an array, which the translator's layer clamp asks for, does not count), and the replay makes a reduced texture bound there again with every level.

Not run on a card with 6 GiB: the figures come from an RTX 5090 with NX2NAVI_VRAM_BUDGET_MB=4730.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 09:38:07 -05:00
chrg6
449b5f73b0 Merge the Linux pull requests into the 0.7.0 release line.
Eighteen commits, one per Linux pull request that was not in yet: the build fix for a source checkout, NVIDIA's shader
disk cache only with NVIDIA's driver, tools/run_game.py for a Linux game folder, a memory limit the low-memory handling
can read, the recording thread's core on Linux, shadow storage on Linux and Proton, the Steam Deck profile and prompts,
FSR 3.1 offered only where its library loads, DLSS frame generation through NGX on Linux, the AppImage with its window
and its workflow, and the processor level from /proc/cpuinfo. Two conflicts: the settings table keeps the area-load
settings under the new comment, and the example file keeps the lazy write-back as off by default and adds that it
stays off with shadow storage.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 07:31:55 -05:00
chrg6
71eb5fbe26 Make an area's textures at once after a load instead of over the first seconds, which showed the ground and walls black.
The texture pool creates 16 entries a refresh and stops after 6 ms a frame, so that textures streaming in do not make
long frames. An area load leaves thousands of slots at once (4,936 loading the test save), and at that rate they came
in over the frames after the load screen: the scene's first frames showed a quarter of the picture as black stand-ins,
for 22 presented frames on a free machine and for about three seconds with the CPU busy.

While a refresh leaves pool_load_backlog slots or more (512; 0 never), the pool is loading: the count limit is off, a
frame's refreshes may take pool_load_ms (50), and frame_hold leaves out the presents of frames drawn meanwhile (up to
2 s), so the picture before the load stays until fewer than 64 slots are left. Measured with the flight recorder's
thumbnails of every present: the 4,847 textures are made in one frame of 345 ms, 30 frames before the scene fades in,
and the black share of the picture goes from the fade straight to its final value. The streaming limits are as before
below the backlog.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 06:55:13 -05:00
chrg6
3134f52475 Let shaders follow guest pointers into shadow copies, and keep those copies current for the device address table's readers.
With shadow storage (Linux, and Windows builds under Wine) a CPU-visible pool is a host-visible copy with
no memory object of its own, and only pools that owned one went into the device address table: pointers
the game's shaders read from memory reached nothing. Shadow copies are now in the table. A shader that
reads through the table resolves no pool, so nothing queued the pool it reaches for the copy-in: the part
is marked where its pipeline is drawn or dispatched (VkPipeInfo.gpa, vk_mem_gpa_use), and its prologue
brings the shadow of every pool in the table up to date with the CPU's writes and queues the same pages
for those pools' VRAM mirrors (vk_memory.c vk_mem_gpa_sync). --probe-vkmem reads a word through the table
from a pool that is never bound, before and after a plain CPU write.

Pull request #353 by TophC7, ported onto the base copies of the black-world fix:
- taken as it is: the table registration, the mark in vk_exec_draw.c and vk_pipeline.c, the prologue
  call and vk_sync_probe_submit in vk_sync.c (two hunks merged by hand), the probe's test;
- written again: vk_mem_gpa_sync, on top of the snapshot-based shadow_sync_pool; a lookup no longer
  queues a pool for being in the table, which every shadow pool now is;
- narrowed: the sync runs only with shadow storage. Without it (Windows) a mirrored pool stays unsynced
  for the table's readers as before, so the frame there is unchanged, and the probe makes the source's
  mirror only with shadow storage and skips when the device has no address table;
- the probe's shader was an array of SPIR-V words in tex_probe.c; it is now the source
  runtime/shaders/gpa_read.spvasm, built like the other runtime shaders;
- the exact re-upload count in the texture probe stays checked on Windows.
Files other sessions are changing: runtime/vk_memory.c (vk_pool_init's registration, mem_resolve's touch,
the new section before vk_mem_use).

The Windows files compile and the shader assembles and validates; no probe was run, and nothing was run on
Linux here.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 06:30:06 -05:00
chrg6
f740e95a62 Fix the black 3D world under shadow storage on Linux and Proton, and copy only what each side wrote.
Shadow storage noted a GPU write with the whole range its binding names: the copy-in skipped that range and
the fence copied all of it back, so CPU writes to other fields of the same records never reached the GPU.
Ocarina's lighting parameter is such a field: the lighting came out NaN and the fog pass drew the scene
black. Each page a noted range covers now keeps a base copy, the copy-in moves only the bytes the CPU
changed and the write-back only those the GPU changed (vk_memory.c merge_page). The mirror's merge shader
marks the 4 KiB pages it changed, and one job per submission copies only those back (shadow_wb_cb); the
copy-in reads the CPU-side generation tables through the shared write-watch snapshots; and a caller that
reads guest memory itself resolves with vk_mem_lookup, which does not queue the pool for the copy-in.

Pull request #394 by jacc. Its changes are taken as they are; one hunk met the lazy write-back that came
later (vk_gpu_written_back) and is merged by hand. Added here: the lazy write-back stays off with shadow
storage, because its fetch copies the mirror into the pool's buffer, which is guest memory only for an
imported pool. Files other sessions are changing: runtime/vk_memory.c (the shadow section, the merge
record, vk_gpu_written_back, wb_lazy) and three one-word call changes in runtime/vk_usnap.c.

Without shadow storage (Windows outside Wine) the merge pipeline gains an unused fifth binding and two
push constants and nothing else changes. The Windows files compile; nothing was run, on Windows, Wine or
Linux.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 06:24:18 -05:00
epicmeme546
d1bebd34cd Keep the previous picture on screen instead of showing a frame that lacks draws, and show the game's own VRAM in the overlay.
A draw whose shader or pipeline is still building is left out of its frame, and the frame was shown without it: a black or unlit picture with the interface intact when it was a lighting pass, a light going out, or ground missing for a frame. In a player's session a full-screen draw was skipped after its 50 ms and the frame came out black as a boulder hit.

The frame's present is now left out when draws were skipped (vk_backend.c frame_hold, NX2NAVI_FRAME_HOLD_MS, 120 by default, 0 off). The game runs on, so nothing waits. The hold comes from an allowance that fills again at an eighth of the clock's rate, so a long build or a run of them shows its frames as before and does not freeze the picture; a full-screen draw that would be skipped with the allowance spent waits on instead, 500 ms at most. Not with DLSS Frame Generation.

On a first walk through a village with no pipeline recorded, 21 of the 23 frames with skipped draws were held back; in the Lost Woods, 7 of 8.

The performance overlay: the VRAM line is the card's dedicated memory in use, which counts every program on it: a player read 14.5 GB as the game's while the game held 7.3 GB. The line's third cell now gives what this process holds on the device-local heaps (the driver's budget figure), in place of the GPU clock, which stays where the driver gives no budget.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 04:39:19 -05:00
chrg6
9a22bea0f0 Merge the shader headers branch: the runtime keeps its shaders as source and builds the SPIR-V headers when the game is built.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 03:33:21 -05:00
chrg6
2a9efee4c5 Merge GitHub main into the test line: the launcher's customisation, the settings and sound changes, and the warm stage-library cache.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 03:32:30 -05:00
chrg6
d15d4e2fbd Keep the runtime's shaders in the repository as source only, and compile them when the game is built.
The fifteen headers of SPIR-V words under runtime/ are no longer tracked. tools/build_shaders.py builds all of them:
the GLSL with glslc, the SPIR-V assembly with spirv-as, and the two shaders assembled in Python from their scripts.
build_game.py builds the missing and the stale ones before it compiles the runtime, and the build kit, the launcher
release and the AppImage build them before they copy runtime/, so a player's PC still needs no shader compiler.
git ignores the headers and check_content.py refuses a compiled shader in a commit. The headers built this way are
byte for byte the ones removed here. vk_mvobj_fs.h is now mvobj_fs_spv.h, named like the others.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 01:53:41 -05:00
epicmeme546
e10ef60fd5 Keep the driver's cache of stage libraries warm, link a missing pipeline instead of skipping its draw, and count the texture cache's waits in time.
The preparation builds every stage library once so the driver's disk cache holds it and a library a draw needs later takes under a millisecond. Turning dynamic vertex input off for AMD's RDNA 3 and newer driver changed the dynamic states every library lists, which gave each one another entry in the driver's cache, and nothing built them again: an update carried the prepared shaders over without the driver step. On an RX 7900 XT (26.10.1) all 42,142 prepared libraries were cold, 93 ms a vertex and 242 ms a fragment library on average. With no pipeline recorded, a walk through a village skipped 11,180 draws while their pipelines built and made 94 draws wait 5.5 s in all, four of them 1.0 to 2.0 s; a player's session log shows up to 114,834 draws skipped in 600 frames and 181 waits of 251 ms on average. Skipped ground and walls appear and disappear, and a skipped lighting pass is a black frame with the interface intact.

- The game checks the driver's cache at every start (vk_pipeline.c lw_start): a sample of the prepared fragment libraries is built, and when their median time says the cache is cold the whole prepared list is built into it again on idle-priority threads while the game runs. shader-warm.txt records a warm in progress, so the next start goes on with one a run ended, and stops the tries on a driver that does not keep the libraries. This also covers a driver update and a cache the driver emptied.
- An update that carries the prepared shaders over runs the game's --warm-shaders (tools/make_game.py warm_driver_cache): 11 s with the libraries there, about 8 minutes with all of them cold on that card.
- A draw whose pipeline is missing waits for its fast link from a budget of 6 ms a presented frame, 3 ms at most each (NX2NAVI_PIPE_LINK_MS), before it is skipped: with warm libraries the link is done within that.
- Full-screen draws wait from their 50 ms budget again instead of being skipped (NX2NAVI_PIPE_SKIP = any is the default; fullscreen stays selectable). With warm libraries the wait is a millisecond.

The same walk afterwards: libraries 0.3 and 0.7 ms on average, 1,605 draws skipped, 1,473 of them in the scene's first 600 frames and 8 to 80 in each 600 after, and 19 waits of 60 ms in all. First visits to four other saves (a mountain pass, the Lost Woods, Kokiri Forest, a river) waited 12 to 84 ms in all except the Lost Woods, where mesh shader pipelines, which have no stage libraries, and vertex libraries that need added outputs still compiled once: 23 waits, 2.1 s in all, the longest 776 ms.

The texture cache counted its waits in presents chosen at 60 a second: at 165 presents a second the 1800 that stood for thirty seconds were 11 s, so a released render target went sooner than meant and a texture out of view for 11 s was retired and showed its stand-in for some frames when it came back. The counts are now taken times the present rate over 60 (presents_for), and a texture is retired after two minutes without a sample instead of thirty seconds.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 01:36:29 -05:00
epicmeme546
9ae7764ab5 Change a setting with the mouse only on the two framed arrows beside its value, and switch HDR without a restart.
In the settings menu a click anywhere on a row stepped its setting to the next value, and the left arrow stood left of the value's text, so it moved whenever a value of another width came up: clicking the left arrow through a list landed on the row at the second click and stepped the other way. Each stepper now has its arrows in white frames at fixed places, the left one the width of the row's widest value from the right one, and the mouse changes the value on those frames only; a click on the rest of the row selects it. On and off rows have the same arrows. An arrow at the end of its values is drawn faint and does nothing, and a button held on an arrow repeats as a held key does. A, Enter and left and right work as before.

NX2NAVI_MENU_TEST_CLICK clicks rows by their setting's name during a menu test run. On an RX 7900 XT at 3232x1352 the arrows stepped the performance overlay one value a click and stopped at both ends, and clicks on the body of four rows changed nothing.

HDR between off and the tone mapper now follows the menu. The HDR path is set up at every start (vk_hdr_armed): the swapchain colour space and metadata extensions, the tonemap splice and the settings in the support buffer, with the spliced tonemap returning the game's own SDR result while the swapchain is SDR. A change of the setting makes the swapchain again in the other format. On the same card a run that started with HDR off went to an HDR10 swapchain and back, and one that started with HDR on went to SDR and back, with the picture right in each state. The game's native HDR still waits for a restart, as the game asks about the display once, and the row says so. NX2NAVI_HDR_LIVE = 0 leaves the HDR path out of a run that starts with HDR off.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-09 23:27:02 -05:00
chrg6
00f06e669e Fix nine runtime faults a tester's report named: a stack overrun on mesh draws, lost YMM halves on preemption, and seven more.
- The mesh stage's storage table starts 0x90 bytes before the end of the 2 KiB constant bank, and all sixteen slots
  were written: 0x6C bytes past a stack buffer on every mesh draw. It holds the nine slots that fit.
- The prebuilt runtime is compiled without AVX, so its preemption stub saved only XMM0-15 while the lifted code of
  an AVX2 processor keeps data in the upper YMM halves, which the stub's callees may clear. Both bodies are built
  now and the one for the processor is chosen at the start.
- After an FSR 3.1 frame generation error the window's swapchain was still AMD's object but went to the plain Vulkan
  calls. Swapchain calls follow whose swapchain it is, and a failure takes it down as a switch in the menu does.
- A movie is paced at its own 60 fps under a lower limit too: at 40 fps it ended 25 s behind its sound.
- A lost device left the wait for an upload spinning for good; it ends the run with the device's report.
- The compute pipeline key had four bytes of padding that were hashed and compared, so a prebuilt pipeline could be
  missed and built again.
- A thread's TLS pointer was published before the TLS was allocated, so the slot was always 0.
- A fatal exit puts RivaTuner Statistics Server's profile back, and an ini saved as UTF-16 is read.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-09 21:54:40 -05:00
chrg6
78b3bc5a80 Clear a texture pool slot's left-this-frame note when it is filled, so a skipped slot only ever holds the stand-ins.
pool_refill notes a slot it could not fill (pool_defer), and once the frame's creation time is spent it skips slots
noted in that frame. A fill did not clear the note. So a slot left and then filled in the same frame was skipped later
in that frame with the filled texture's view still in the set, also after that texture was destroyed: a released
texture dropped past the size limit, or one evicted. A shader sampling the slot would then read freed memory. A left
slot holds the stand-ins (its lookup resolved to nothing), so with the note cleared on a fill, a skipped slot can only
hold those.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 8d04e17a954e640a9ff06baedc3e7614dc978798)
2026-11-09 21:34:53 -05:00
chrg6
49dd6639f1 Count a texture pool take only when its sync left no slot behind, so a retired texture is not freed while a set still holds its view.
Once the frame's creation time is spent, pool_refill skips a slot it left earlier in the frame, and pool_sync_entries
may return before the walk. Such a slot keeps its old view in the current set with nothing in the change log, so the
takes after it do not carry the change into the other sets. vk_pool_takes counted those takes all the same, and at
about six submissions a frame, more than VK_POOL_SETS of them could pass within one frame while a retired texture's slot
was skipped every time. retire_sweep would then free the image while every set still named it. A take now counts only
when its sync left no slot behind (PL.retry clear): after it, every slot change made before it is in that set and in
the log, and the takes after it bring it into the others. A sealed second take inside one submission still goes
uncounted, which only delays the free.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5cd431f792e00ca3b9a03657cd4aab64fc38dae7)
2026-11-09 21:34:53 -05:00
chrg6
a87f6e1bd6 Merge the test line's texture retirement fix into the combined branch.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-09 21:27:08 -05:00
chrg6
22103a57bf Merge main into the test line: the pull requests taken there and two render target fixes.
Main brought the fixes of eleven pull requests (the texture pool set sealed when an early replay part is submitted, every location reflected in interface arrays, RGB9E5 texels recognised for integer storage views, the upscaler a frame started with kept, GPU pass timestamps without vendor breadcrumbs, the Linux build, window and NGX fixes), render targets released when drawn over at another address, the vertex layout kept in the pipeline on newer AMD drivers, and the upscaler choice read once per evaluation.

Four hunks conflicted and take both sides: pool_sync returns for a sealed set before the per-frame creation budget's clock (vk_exec_draw.c); make_module keeps the test line's early_ok argument and main's module hash (vk_pipeline.c); a texture taken back counts as sampled again and records how long it was away, and the texture line logs the disuse counters and the overwritten render targets (vk_texture.c).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-09 21:10:23 -05:00
chrg6
f1127f8be9 Retire textures evicted by disuse before freeing them, take them back on any use, and add tex_disuse = 2 to tell the freeing from the marks.
0.6.1.14 faulted the GPU (a read of an invalid address in a pass) about 30 seconds after its last disuse evictions, and
no path by which an evicted image is still read was found in the code. An evicted texture is now first retired: the
pool refresh gives its slots the stand-in while the image stays whole. It is destroyed only once the texture pool has
taken every set of its ring since and the GPU has finished the submissions recorded until then, so no pool set can
still be bound with its view. A mark on one of its slots or any lookup outside the pool refresh takes it back as it is,
and the perf line counts those, which shows whether the marks miss a real use. tex_disuse = 2 retires and never frees,
so the next fault can be put on the freeing or on the marks and stand-ins.

The registration shortcut also read a slot's cached entry without checking that the resolution was current, so it could
read the record of a destroyed texture; it now checks the slot's generation first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 4c5b2ae2e030ab00a910d8f071c030e610fd78e1)
2026-11-09 21:09:33 -05:00
Chris Toph
47d9a2d502 Seal the texture pool set when an early replay part is submitted.
A replay part handed to the queue early kept reading the bindless pool set while later parts of the same submission wrote new entries into it. That updates descriptors a pending command buffer reads, and on RADV a texture whose memory was mapped after the part was submitted is absent from its page tables. This caused a gfxhub read fault in the 128x128 pass of the first world frame in Kokiri Forest.

Seal the set when a part goes, take another ring set at the next sync that has entries to write, and keep recording the same part while every other set belongs to the submission. Document the descriptor lifetime contract in maxwell.md 4.9.

Fixes #257.
2026-11-09 20:52:40 -05:00
ajcohn716
e3e2d999c0 Recognize RGB9E5 texels when selecting integer storage views 2026-11-09 20:51:02 -05:00
chrg6
bab143e1a2 Wake the recorder once per sleep, stop its idle spinning, and skip per-draw work in the replay that repeats.
From the replay review of a profiled session:
- vk_rec.c: the producer set the wake event for every packet until the recorder had cleared its sleeping flag, a system call per packet on the submit thread for as long as the recorder took to wake; it now takes the flag back itself and sets the event once. A sleep that ended with nothing new was followed by another 4096-pause spin, every 2 ms for as long as the game was idle or paused; the recorder now sleeps again at once. head, tail and the producer's words are on cache lines of their own, and the producer reads tail only when the ring looks full by the value it last saw.
- vk_exec_draw.c c0_info: a vertex or fragment bank depends on the storage slots and the base instance alone, so those are compared directly instead of clearing, filling and comparing a 1.8 KiB record on every draw.
- vk_exec_draw.c bind_vertex_buffers: a draw that changes no vertex stream returns before the 17 streams are rebuilt and compared.
- vk_exec_draw.c bind_resources: the texture lock is taken at the first texture descriptor that has to be resolved, not for every texture binding whose descriptors are all kept.
- vk_usnap.c vk_usnap_find: the region the last lookup hit is tried before the binary search.
None of this changes what is recorded.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
(cherry picked from commit 8eac567e2a9a353f894f3c66e3fc20fd2c0d295d)
2026-11-09 20:48:10 -05:00
chrg6
06f4aeb694 Time what a submission spends on the GPU outside the game's passes and dispatches, with gpu_passes = 1.
A session with per-pass GPU timestamps showed the game's own render passes and compute dispatches at 1.6 to 2.3 ms of GPU time a frame while the perf line's GPU time was 7.7 to 13.5 ms: most of the frame's GPU time is in commands the replay records between the marks, and nothing said which.

The timed frames now also get a timestamp at the start and the end of each part of a submission, and every stretch between two marks (or a mark and the part's edge) is a gap. The replay names the kind of commands it records in a gap: buffer and texture copies, fills and clears, the temporal upscaler, write-back merges and copies, depth twin copies, the texture pool marks, the mesh draw counts and block-compressed target copies, each with a size where it has one. The report adds the gaps' time per frame summed by the kinds noted in them (a gap nobody noted holds barriers and state only), the parts' own time for comparison with the perf line, and each kind's count and size per frame. Nothing runs outside the timed frames.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-09 18:49:12 -05:00
chrg6
860bc9cf0b Spread the texture pool's entry creation over frames by a per-frame time budget, and stop looking up the slots it left.
The pool refresh runs before every draw that binds the pools, so its count budget of 16 creations held per draw, not
per submission. An area load in the 0.6.1.12 test made 4,925 entries (1.7 GB of uploads) in one 430 ms frame, and
2,018 in a 195 ms one. While slots were left over, every draw walked the whole table and looked each of them up again,
about 100 ms of the 430 ms frame in key hashing alone.

Once a frame's refreshes have taken pool_create_ms (default 6 ms; 0: no limit), they create nothing more until the next
frame, and skip the slots left earlier in the frame. The first refresh of each frame keeps its count budget. The slots
left keep their stand-in for a few frames during a large load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:51:29 -05:00
chrg6
dc9f164afc Evict textures no shader sampled for 30 seconds while video memory or the system's commit runs low.
The texture pool refresh looks up every registered slot, so the textures of every area the game keeps loaded never
counted as idle and their memory only grew. Marked shaders now store into a buffer with one word per pool slot. Every
four submissions that recorded work, the replay copies it out and clears it, and the texture side notes when each
texture was last sampled. Under VRAM pressure or low commit, once idle textures are gone, live textures that come back
intact and were not sampled for 1800 presents go too. Their keys are held, so the pool refresh keeps the stand-in until
a shader samples that slot again, and the next refresh makes the texture again.

Fragment shaders that neither discard nor write depth, sample mask, stencil reference or memory keep early depth tests
(EarlyFragmentTests), so the marks do not take away early depth rejection. Alpha to coverage leaves the dynamic state
while marks are on, so each pipeline knows whether early tests are safe. Disuse eviction waits until every module that
indexes the pool was marked and two reads arrived. NX2NAVI_TEX_DISUSE=0 (tex_disuse = 0) turns it off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 1a4c896150a748f9275c3024e96af3055db94af4)
2026-11-09 14:39:07 -05:00
epicmeme546
26eb249026 Stop the red flashing by showing the picture the game's post pass really writes.
The scene upscaler's stand-in took the RGB9E5 texture at the picture's address, but that is a separate image nothing renders into, so it showed stale or uninitialised memory, which flashed red. The stand-in now finds the image at that address that was written as raw RGB9E5 words this frame, looked up live because a remembered image may be gone by then, and shows that one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 11:58:47 -05:00
epicmeme546
6b5038f6a4 Stop the scene upscaler's stand-in from showing an older picture, which made whatever moved trail.
Without DLSS or FSR 3.1 the stand-in takes the input in the output's format. The current picture also resolves as RGB9E5 at the same address, and when it did it was refused, so the older picture bound beside it was shown instead. An RGB9E5 input now counts as the picture and goes through the same decode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 10:12:45 -05:00
chrg6
e3bfa3d40a Free a destroyed texture's record only after the GPU is past the submission being recorded, and cache no view of it.
A device lost seen on RTX 4090, 5090 and 5070 Ti cards in 0.5.0 and 0.6.0 (#177, #61, and a 0.6.0 test run): a
"read invalid" at the start of a 128x128 scene capture pass, re-rendered at area loads. destroy_tex purged the views of
the image and deferred the image, then freed its record at once, on whichever thread released the texture. The replay
keeps &e->pub as a render target for the rest of a command buffer (vk_exec.c resolve_target) and DLSS for the frame:
a pass that began again (each indirect mesh draw ends the pass) read the freed record and cached a view of the dead
image, which nothing removed. Vulkan gives a destroyed image's handle to a later image, which then got that view, and
the pass loaded its attachments from freed memory.
- destroy_tex marks the record gone and frees it through the deferred destruction (vk_defer_free, a host kind stamped
  with the submission being recorded, as the image is).
- A gone texture's attachment view is made per command buffer (vk_exec.c view_of) or deferred with it
  (vk_exec_target_view, for DLSS and the contact shadows), never cached.
- A new image drops any view still cached under its handle, and the log counts it ("cached views of a destroyed image").
No rendering changes: the views and images live exactly as long as before, the records slightly longer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 09:58:26 -05:00
chrg6
0101a87079 Raise the frame rate: fewer copies into the VRAM mirrors, earlier GPU starts, render target images reused.
From the local fixes package (fix 11), measured in Kokiri Forest at 4K on an RTX 4090 over PCIe 3.0: 40.5 to 62.6 fps
native and 45.6 to 74.9 fps with DLSS Quality, the mirror copies from 6.5 to 0.3 ms of GPU time a frame.
- Pages a VRAM mirror wrote back into guest memory are not copied up into it again: the mirror sync reads page stamps
  of their own that a mirror's write-back leaves alone (vk_gpu_written_back, decided at record time by
  vk_mem_mirrored). This replaces the lookup table NX2NAVI_WB_NO_REUP had, keeps its name, and is now on by default.
- The game's flushes of mirrored memory are not copied where the write watch covers the region, as every page the game
  wrote there is stamped already (47-57 MiB a frame); NX2NAVI_FLUSH_UPLOAD=1 copies them as before.
- Written storage ranges up to NX2NAVI_WB_MERGE_MAX (now 32 MiB) are merged in 4 MiB pieces, so a range is no longer
  bound to what one dispatch covers; the snapshot pool keeps its budget-scaled size with 128 slots.
- A submission's first part goes to the GPU at the first pass boundary while the GPU is idle (split_idle), long passes
  are split too (split_in_pass), and the part's time limit reads the clock less often.
- A render target that needs an image of its own takes the image of a released one with the same parameters, released
  two or more frames before (tex_reuse); memory requirements are kept per parameter set; a released entry another
  descriptor's entry replaced at its address is kept and taken back.
- The memory check reads a page's write-watch bit and stamp under the lock that keeps them together.
- The launcher reads the gamepad only while its own window is in front, and does not start a second copy of the game.
- make_game.py says why a Python package did not load, not only that it is missing.
The fix's per-pass GPU timing is left out: NX2NAVI_GPU_PASSES does the same in main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 09:55:25 -05:00