A slot lookup's callers stamp what they keep with the generation read before the lookup. A lookup that takes a
released entry back for a slot registered since the release left such a stamp naming the released state, with the
entry as its result. When the game released the entry again the bucket came back to that state and got its
generation back, the stamp matched, and the slot was handed the released entry although it is stale by then: a
re-upload from storage the game may be unmapping. The state such a lookup leaves now loses its remembered
generation, so it gets a new one next time and the stamp never matches again. Found in review.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The first version put a bucket's generation back only when a take-back undid the release just before it. A town run
with it showed half the take-backs going back and the fullest bucket (1,315 slots) still bumped 7,736 times per
3,600 submissions: the game keeps those textures released and takes them back for a moment, so every release was a
new generation and the pool refresh still refilled 5,220 slots per submission.
A bucket's state is now named by its epoch (changes other than a release or a take-back) and the XOR of the uids of
its released entries. A release or a take-back that brings the bucket to a state it was in before gets that state's
generation, whichever way round, and in any order of several entries; a new state gets a new one, never one used.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Textures went dark for about a second all over the game. Under memory pressure a texture goes when it was released
120 presents ago or not sampled for 1,800, numbers set at 60 presents a second: without a limit the game presents
85 to 240, so that was half a second and 7 to 20 s. The thresholds now scale with the presents per second.
A pause screen, a menu or a fade draws next to nothing through the texture pool, and every texture of the scene
behind it counted as unsampled: eviction by disuse now waits until two mark reads in a row show the scene drawn.
A texture whose stand-in a shader sampled is on screen as that stand-in: it is made at the next refresh even when
the frame's creation time is spent, 32 of them a present, instead of waiting for a frame with time over.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
In a large town the game releases and takes back about 40,000 textures per 3,600 submissions. Each was a bump of
its address bucket, the fullest buckets (1,300 slots over one address) were bumped most, and the texture pool
refresh refilled about 6,000 slots per submission: it used up its 6 ms of a frame in about half the frames there,
which made the game CPU-bound (the GPU idle 10 ms a frame) and delayed new textures.
A take-back of the entry that was released, with no other change at its address since, now puts the bucket's
generation back to its value from before the release, so everything resolved then is current again. A bump takes
the generation after the highest the bucket ever had, so the value in between is never given to another state.
tex_gen_undo = 0 bumps as before. The pool line counts the take-backs that went back.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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)
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>
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)
Ocarina lays its per-frame render targets out anew every frame in one GPU-only pool. When an early target changes its size, every target after it moves, and each move made a new entry with an image of its own while the old entry stayed live for as long as a pool descriptor named it. After 6,000 frames of walking through Kakariko Village 1,043 such entries held 6.1 GiB of device memory against 233 MiB in the targets still drawn. On a driver that charges device memory to the system commit this kept the commit low, and the idle textures of the area were evicted and uploaded again while walking.
A GPU write in the GPU-only window now marks the entries at other addresses whose storage it runs over as overwritten and releases them. Their images go to the next texture made with the same parameters, or away after 600 presents. On the same walk the process's private memory ends at 23.2 GB instead of 29.3 GB and device memory in use at 8.5 GiB.
A released render target whose content exists only in its image is no longer dropped after 120 presents under commit pressure: the game went on sampling such targets and took them back empty, which drew the scene black for one frame every two to three seconds. Such an entry now waits 1,800 presents, or eight times the longest it stayed released before the game took it back, and none goes while lookups still reach it.
Co-Authored-By: Claude <noreply@anthropic.com>
VMA's blocks on large heaps are 64 MiB instead of 256 (vma_block_mb): one session held 2.1 GiB free inside the
device blocks beside 8.2 GiB of allocations after a few area changes, and the driver counts a block whole until it
empties. The headroom thread keeps its spare block only for the device-local types textures and mirrors grow in; the
spare blocks it made for the host types and the PCIe BAR type at boot stayed empty for the whole run. The ASTC
decoder's scratch is 32 MiB, so it stays inside a block, and an area load that makes one per upload batch holds half
as much at once. A DLSS feature no frame used for 3600 evaluations is freed with its work images, and a model change
now frees all five sizes.
The perf log gets a "vram by use" line (textures, released textures, mirrors, physical pools, ASTC scratch, headroom
spare, free space inside the blocks, memory outside VMA and DLSS's own share), the free ranges per memory type, the
addresses whose duplicate texture entries hold the most, and a line when memory outside VMA moves by 256 MiB.
astc_bc_probe in nx2navi.ini turns on the ASTC opacity probe.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 99cfc2fa14ae208b7b23e057ff9b87986cd6a5e0)
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)
The driver charges device memory to the system's commit. A 32 GB PC lost the device at an area load with the
system at 61 of 65.5 GB committed, the game at 28 GB: 12.35 GB of VRAM in use, of it up to 1.3 GB in released
textures kept for reuse, 0.5 to 1.8 GB free inside VMA's blocks, and a spare 256 MiB block per memory type.
- Released textures keep a thirty-second of the installed memory (512 MiB to 2 GiB) instead of a sixteenth (1 to 4
GiB); only those released STALE_FRAMES presents ago go, so the transient ones the game takes back stay.
- The headroom thread keeps no spare block while the system's commit is low (vk_texture_commit_low), as it already
keeps none under VRAM pressure.
- A texture image of 32 MiB or more gets memory of its own (DEDICATED_MIN), so freeing it gives the memory back at
once instead of leaving a hole in a shared block that the driver counts in full until the block empties.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 0.6.1.9 test still had one black flash, two presents long with FSR 3.1 and its frame generation: a new texture
made over a live one that holds no GPU content started empty (perf counters: one "left uninitialised" at that frame).
A released entry at the same address, kept since 0.6.1 for its descriptor to take back, was never asked for its
content, though on the console the memory still holds what it drew. start_at now takes the newest released entry with
GPU content and a compatible image as the source when no live texture there holds GPU content. Depth buffers that
start empty over another target's memory at every area load are no longer logged, so the 24 lines go to the others,
and the perf line counts copies from released textures.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ocarina gives its scene picture (r11g11b10f, 5120x2160 here) a second descriptor at the same address that nothing
draws into (rgb9e5, read raw by the post pass). About once a second the picture's entry is released and taken back
there, and since 0.6.1 a taken-back entry restarted empty unless a live texture at the address could give it its
content (vk_texture.c start_at): the second descriptor never can, so the scene went black for a frame (issue #253;
the log's empty starts showed it at frames 4523, 4643 and on, each with "the live texture holds no GPU content").
A taken-back entry now keeps its own content unless a texture at its address holds GPU content written since its
release, as the memory would on the console. The perf line counts them ("taken back with their own content").
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ocarina moves render targets whose size follows an effect on screen, so a descriptor made over a live target's memory
is often a few texels larger or smaller than the target. On the console both read the same bytes; here the new image
started empty when its shape differed (vk_texture.c alias_compatible), and the scene read it for a frame. From 0.6.1 on,
where a superseded entry is taken back at such an address, the scene went almost black for one frame about once a
second while the camera turned (issue #253; flight recorder thumbnails: a dark frame every ~121 presents, each with a
new texture left uninitialised over a live one). Uncompressed colour images of one block size now take the region
both cover (alias_copy), the rest of a larger new image cleared as before; block-compressed ones still need the same
shape. An alias that still starts empty is logged with its reason, 24 at most.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
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>
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>
The driver charges device memory to the commit, and idle live textures went only above NX2NAVI_TEX_VRAM_PRESSURE of
the device's budget: on a 16-32 GB card the textures of every area visited stayed until the commit ran out, in 27-37 GB
processes that then failed an allocation or lost the device (#177, #203, #215). While commit_is_low holds and the
released entries are down to their low-commit size, evict_idle now runs too, 256 MiB at a time
(NX2NAVI_TEX_COMMIT_EVICT=0 turns it off).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The draw path called getenv("NX2NAVI_SKIP_PROG") for each of ~2,000 draws a frame, and getenv walks the whole environment block: in a replay-thread profile it was a sixth of the samples. That switch, the polygon offset log and the ASTC alpha probe now read the environment once. The replay's cost per draw went from 3.7-5.0 us to 1.2-2.8 us in play, and the mean frame rate by minute from 60-131 fps to 103-243 fps (different places in each run, so the figures are approximate).
cfg_get and cfg_value keep each thread's answers per name until the settings version changes (cfg_set, cfg_reset, cfg_load, and cfg_setenv, which the code that sets NX2NAVI_ variables in the process's own environment now uses); NX2NAVI_CFG_MEMO=0 asks every time.
The texture pool creates at most pool_create_budget (NX2NAVI_POOL_CREATE_BUDGET, default 16, was a fixed 64) new texture entries per refresh. The refresh holds the texture lock throughout, and streaming new textures in made 20-40 ms frames; at 16 the lock was held 5 ms per slow frame instead of 24 in a dense area, and the frames over 25 ms in a heavy minute fell from 111-188 to 89, with no pop-in seen.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lock_time (NX2NAVI_LOCK_TIME) makes the replay threads time each lock they have to wait for, kept per asking site (platform.h plat_lock_timing, plat_mutex_lock_at and plat_rmutex_lock_at carry the site), and the frame-time summary lists the sites with the most wait, the recorder's full-ring and drain waits, and the texture lock's holds over 1 ms with the code that took it. replay_time now also keeps each frame's replay ops: a frame over 25 ms charged to the replay says how many draws, binds and transfers it replayed, their time, its slowest op, and how much of the replay's wall time the thread was on the CPU. NX2NAVI_PROFILE_REPLAY=1 samples only the replay thread without call chains, and the profiler now follows the thread that replays instead of the one that started the back end.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
texup_log_ms logs a "texup:" line for each frame whose texture work on the render or replay thread
reaches that many milliseconds. The line splits the time into texture creation, staging, storage
copies, ASTC recording, scratch buffers and new device memory, to show where an area load's hitch goes.
astc_scratch_keep keeps the ASTC decoder's scratch buffer across upload batches instead of making a
new 64 MiB buffer for each batch. astc_arena stages GPU-decoded ASTC blocks in the staging arena
instead of a buffer per texture. Both aim at the allocation churn seen during area loads and stay off
until a play test measures them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Performance: draws reuse the bindings that did not change and record only the dynamic states that differ from what
the command buffer holds; small uploads come from a staging arena; finished submissions are held briefly and handed to
the queue in batches; the recorder thread can keep a CPU core of its own; ASTC block-linear textures are deswizzled on
the GPU; dynamic resolution steps the upscaler mode to hold a frame-time target. Each has a setting in nx2navi.ini
(bind_reuse, dyn_delta, stg_arena, submit_batch, recorder_core, recorder_prio, astc_gpu_deswizzle, dyn_res) and the
staging cache now frees what it holds at shutdown.
Capture: NX2NAVI_DUMP=key saves the frame after each press of Insert, with mesh draws listed by task, mesh and fragment
shader, depth test and face culling, and mesh_prims.txt giving each mesh draw's primitive, clipping and fragment counts.
All of it is off unless NX2NAVI_DUMP is set.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A test run with the budget taken as 16 GiB showed two faults. The evictions measured the driver's heap use, which keeps counting a VMA block whole while one allocation lives in it, so freeing textures and mirrors in the middle of blocks did not move it: they went on until 5700 of 7232 textures and 395 of 410 mirrors were gone (9.2 GiB free inside blocks). And mirrors evicted under pressure during a menu were refused again when the world came back, so the draws read the pools over PCIe at 4 fps. The evictions now count the free space inside VMA's blocks as room (vk_mem_vram_live), mirrors are no longer evicted to make room for textures, and a mirror that does not fit after the idle mirrors made room asks idle textures for the rest (vk_texture_want_room) and is asked again 16 submissions later.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pool refresh looks every registered slot up only in submissions that draw through the texture pool. Counted in submissions, a pause screen or a fade that draws nothing through the pool made every texture of the world idle within seconds (the census showed all 3456 decoded textures idle during one such stretch), and under VRAM pressure the eviction would have dropped them all, to be uploaded again when the world came back. The clock now moves only for a submission whose slot checks reached half of the registered pool slots.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Above the VRAM pressure threshold (NX2NAVI_TEX_VRAM_PRESSURE, 90% of the budget) only released textures went before, so a scene whose live textures alone passed the budget kept growing into system memory. Once the released ones that come back intact are gone, live textures go too, least recently looked up first: only those whose content their storage still holds (CPU-written, never drawn into) and that no lookup reached for 240 submissions and 120 presents. The texture pool refresh looks every registered slot up each submission, so no live descriptor names them; the next use creates and uploads them again. Up to 64 per check, until the use is 2% under the threshold, and the next check waits for the GPU to pass the submissions that may still name the freed images. NX2NAVI_TEX_EVICT=0 turns it off.
Measured with the budget taken as 16 GiB (NX2NAVI_VRAM_BUDGET_MB=16384), same route, the exe at this commit and the next one: with the eviction off, 17,479 MiB in use in the world, of which 12,321 MiB textures, 37 MiB of them idle; with it on, 43 idle live textures (10 MiB) went in about 6,000 frames. In the world nearly every loaded texture is named by a descriptor, so the eviction frees memory mostly once an area or a menu is left. That run predates the later fixes (the idle clock in pool walks, the free space inside blocks); an earlier run without them emptied VRAM, as the commit that stops the evictions from emptying it says.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every 600 frames with NX2NAVI_TRACE=perf: the live textures' own memory by kind (decoded ASTC as BC3 or RGBA8, other CPU-written, GPU-written) with the part no lookup reached for 240 submissions and 120 presents, entries sharing a storage address with another, the VkFormats holding the most and the largest entries; then the imported pools the GPU resolved and those it never did, and the VRAM mirrors idle for 120 submissions. Textures now carry the submission and present of their last lookup for it.
Measured with it (user's save, RTX 5090, 2560x1440 with DLSS performance, astc_bc = 1): in the world the live textures held 5,166 MiB (3456 decoded ASTC as BC3, 3438 MiB; 3412 other CPU-written, 965 MiB; 216 GPU-written, 763 MiB; 46 sharing a storage address, 115 MiB) and the mirrors 927 MiB, and of the 5,007 MiB of imported pools the GPU never resolved 4,077 MiB (3787 pools). With fine ASTC footprints kept as RGBA8 (the main checkout's uncommitted rule for astc_bc set by hand), decoded ASTC took 10,382 MiB instead of 3,438.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After an hour at 2160p the 2048 released entries held 5-7 GiB of render targets and decoded textures, charged to Windows' commit as well. NX2NAVI_TEX_RELEASED_MB caps them by size (default 1/16 of RAM, 1-4 GiB), and with less commit free than NX2NAVI_TEX_COMMIT_FREE_MB they are dropped to 256 MiB. Only entries released 120 frames ago or more go, at most 32 a check, oldest first. On Linux the commit check applies only with vm.overcommit_memory = 2 (plat_commit_enforced). From a tester's fixes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Opt the process out of Windows power throttling (execution speed and
timer resolution) at startup; NX2NAVI_POWER_FULL=0 turns it off.
- Fence completion thread wakes waiters before collecting freed memory,
so collection no longer delays them.
- Add a by-region barrier when a draw or clear writes an attachment that
an earlier draw in the same pass sampled; count it and inline uniform
updates in the per-frame stats.
- Hash small texture contents at upload and skip re-uploads whose bytes
are unchanged (removes ~420 redundant uploads per frame in Kokiri
Forest); NX2NAVI_TEX_SAME=0 turns it off.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shaders: a switch whose index is clamped against a register that a MOV of an immediate set before it now finds its
jump table (AmpereLowering.cs BrxTargets), so all 36,031 of the game's shader variants translate and no draw is skipped
for a failed one. The compare-and-swap loop behind storage-buffer atomics (patch 0033) takes the value a failed swap
returns as its next expected value instead of loading the word again, which on some drivers kept returning a stale
copy.
Memory: an unused physical pool outlives the submission being recorded, as virtual pages may still reach it through
device addresses; an image whose creation failed is not tried again for 2 s.
The installer and Linux texts name this game.
The README has the project icon, the current status, features, requirements and known issues.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Crashes: the render-target heap (HeapDef DynamicTextureAllocatorMem and its parent) grows with the widescreen
picture, so the pause menu no longer reads a null block at 5120x2160; texture uploads keep the game's memory mapped
while they copy it, so UnmapPhysicalMemory no longer pulls it away mid-copy; DLSS Frame Generation no longer crashes
in Streamline's set-up (physical devices and the window surface go through its proxies, its swapchain images are
counted first, resources are tagged per frame); a stale core-wait target is cleared before its thread is freed.
Freezes and races: a resize during a swapchain rebuild is kept, a failed frame generation swapchain is retried
instead of replaced by a plain one, three acquire timeouts in a row rebuild the swapchain, device waits take the
queue lock, a translator child that stops answering times out, an in-flight compute pipeline builds at normal
priority, a save Commit started before the window closes finishes and none starts after, a settings change just
before closing is saved, and a movie sample taken before a flush is dropped.
HDR: Enhanced HDR extends the game's own tonemap so highlights go above the picture's white (the hue slider,
which no longer applies, is gone from the menu); frame generation gets a HUD-less picture, the HDR flag and the HDR10
metadata under HDR too.
Memory: ASTC textures are encoded to BC3 unless the PC has 20 GiB of VRAM and 48 GiB of RAM, as Windows charges video
memory to the commit charge (a long session held 17 GiB of RGBA8 textures and 45.7 GiB of commit on a 32 GiB PC).
Shaders: the translator lowers spill-mode programs with more than eight uniform register groups in a wider spill
layout, and local loads and stores with a uniform-register address (36029 of the game's 36031 variants translate,
20 failed before).
The launcher release ships the shader tools and AMD's FidelityFX library (make_launcher.py --ffx); windres there gets
the toolchain on PATH.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A depth-compare read through a sampler whose compare is off now gets the slot's comparing sampler, as the Switch
compares there and only NVIDIA's driver did so on its own. Colour components a fragment shader does not write are
masked out, as Maxwell leaves them alone. Without mailbox presentation the swapchain takes relaxed FIFO, or
immediate, so a late frame no longer halves the frame rate. NX2NAVI_VK_NOOPT=1 builds pipelines without the
driver's optimiser, for a driver whose compiler fails on one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each file that contains copied code names its copyright holder and license and points at THIRD_PARTY_NOTICES.md; zlib code keeps its full notice and the mark that it was altered. Comments and probe text only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comments say what the code does and why, docs/maxwell.md keeps the Maxwell facts, and fetch_refs.sh clones only the checkout the build reads. Code is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NVN2 compute banks get the dispatch's group counts in bytes 0-0xb, for direct and indirect dispatches; the fog pass
after the integration divided by them. Indirect mesh draws read NVN's {count, first} record as {x, y, z}, so y = 0
drew nothing: each now draws from a ring entry holding {count, 1, 1}, copied on the GPU before the draw. An empty set 1
no longer leaves set 0 pushed with 0 bytes. Compute stages with subgroup operations whose width is a whole number of
subgroups require full subgroups.
The texture pool refresh fell from 3.1-3.7 ms to 1.0 ms a frame in Kokiri Forest: slots with the same descriptor,
address generation and entry generation share one lookup (about 14,500 of 15,000 refills a frame), and registering a
texture and view identical to what the slot holds keeps its resolution. Under 20 GiB of VRAM, ASTC textures are
encoded to BC3 by default (Kokiri: 15.9 to 8.2 GiB, same GPU time). The pool log counts refills by cause and what
invalidates them; frame dumps write BC textures as raw blocks and print a storage buffer's backing span; a profile with
NX2NAVI_PROFILE_FRAMES is written when its window ends; the alpha test logs once that it is not applied.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A CPU-written texture slot could resolve to a released entry and upload from storage the game was already freeing,
which crashed in tex_bl_copy during the pool refresh. Each released entry now records the registration serial at
release, and slot_resolve treats slots registered at or before it as stale.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A texture slot whose content the CPU writes now follows another image at its address only when that image differs in
swizzle alone or holds GPU-written content; Ocarina reuses freed glyph atlas memory for captions of another width, and
following the older image drew the Basic Controls screen's "Target" with the wrong row length. Mesh-shader pipelines
are built on the workers and recorded in pipeline-keys.bin (version 4 with the task stage; version 3 files are
converted) instead of stopping the frame for 0.26-0.51 s. The ASTC decoder reuses one scratch buffer per upload command
buffer, and CPU-provided textures up to 32 MiB are sub-allocated unless the driver requires dedicated memory, which
takes the scene-load frame from about 1.25 s to 0.7 s. The feedback scan looks only at bound texture slots instead of
the bindless pool arrays, per-draw knob lookups are cached and the texture address buckets grow to 65536, so Kokiri
Forest's replay falls from about 16 to 7-9 ms a frame and the forest holds 60 fps. A float clear of zero on an integer
image now clears instead of being skipped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The texture pool descriptors are now a ring of sets, one per submission, brought up to date from a change log, and the first submission of each frame waits for its GPU work before the game goes on: the GPU ran late and part of a frame read data of the next one, and distant characters drew NaN that bloom spread over the frame. The window acquire also waits for the image's previous frame. Function locals start at zero unless DLAA is on, which removes the per-warp light tiles on the Great Fairy Fountain floor and Link's dark, speckled look. Texture slots follow only live entries of their own target, so the volumetric fog gets its 3D volume. The pool refresh walks only the slots that changed.
The translator implements PRMT (patch 0021), which it only logged before; the button prompts render again. HFMA2.RELU no longer depends on it, HMMA.F16 rounds once and HMMA.F32 is lowered, checked against GPU vectors with a new Maxwell warp emulator.
The frame dump gains a re-arming white-frame trigger, a trigger on a depth target's first pass, NaN pixels in magenta, image handles and view targets, and depth copies of sampled depth textures.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The NVN2 front end and the SM86 to Maxwell shader lowering (tools/xlate/AmpereLowering.cs, mesh and task stages,
bindless texture pools, BRX jump tables, the NVN2 compute c0 layout) with four translator patches (0017-0020) bring the
opening of the game to 58-60 fps on the Vulkan renderer.
This round fixes the haze: SM86 IPA is lowered as a plain Maxwell IPA.PASS (texture coordinates were corrected for
perspective twice); LDSM, TXD, both F2IP byte forms, HMMA, MOVM and HFMA2.RELU are lowered and spill mode has eight
uniform register groups; conditional rendering keeps the newest counter report per address and treats a report as
pending until its value is in guest memory, so occlusion tests and the depth clears around the depth copy behave; and
the upscaler stand-in decodes the post pass's sRGB picture before writing the linear target. Tensor-core programs keep
the stand-in unless NX2NAVI_NATIVE_TENSOR=1, because their lowering does not match the hardware yet.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>