Commit Graph

68 Commits

Author SHA1 Message Date
itaskaev2
b4a876200b Link the game's manifest and icon as a .res written in Python when lld links, so no build path goes through windres.
windres (binutils) opens its files and starts its preprocessor through the system's ANSI code page. A build or user
folder whose name holds a character outside that code page (Victor with an accent on a Cyrillic Windows, a Japanese
user name, a folder named with a full-width colon) failed the Compile step with "Invalid argument" or "Cannot create
temporary file". make_game.py now writes runtime/nx2navi.rc's two resources as a .res file itself (resource_file) and
hands it to lld, which builds the resource section from it and opens paths as Unicode. The resources come out as
windres made them: the manifest as 24/1, the icon's images as RT_ICON 1..7 and their group as RT_GROUP_ICON 1, US
English. Without lld the windres path stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 15:45:50 +01:00
DieMitchell
21eb3de1c2 Fix out-of-bounds texture size query extracts in the SPIR-V translator
The SPIR-V generator emitted OpCompositeExtract with the guest's component index even when it exceeded the image's size vector. A 2D texture's OpImageQuerySizeLod returns a v2int, so a guest request for the third component (depth) produced an extract of index 2, which is invalid SPIR-V. RADV crashed while compiling those variants during shader preparation.

Return the constant 1 for a component past the texture's dimensions, the depth of a 1D/2D/cube texture, and apply the same guard in the GLSL generator. build_xlate.py now expects the added patch.
2026-11-09 10:44:00 -05:00
chrg6
4223e0aa5c Name the translator a shader cache was made with before an update replaces it, so the first update carries too.
A shader cache made before the game carried translations over has no identities.txt, so after the update that brings
the carrying the game could carry nothing, yet the update skipped the shader step whenever shaders had been prepared.
Before a new translator goes beside the game (the compile step, and the shader step a translator-only kit runs alone),
note_cache_translator writes identities.txt naming the translator still there, in the form runtime/gfx_shader.c
reads; a file already there is left alone. The shader step is skipped only when the cache names a translator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 10:42:36 -05:00
chrg6
2ce8451fe9 Keep the compiled game across updates: stable compile keys, objects of earlier versions taken over, shaders carried.
An update recompiled every file of the game's code whenever anything in its keys changed, though the compile was the
same. The compiler's id held the file time of clang.exe, so a tool update that put the same compiler back made every
object stale; it is now the version text and the size. The fast CLANG64 compiler, whose objects are UCRT64's byte for
byte, was part of the key through its id and --sysroot; it no longer is.
So that this change itself costs nothing, an object whose entry has the key an earlier version gave the same compile
is taken over (ObjectCache.adopt) when its sources and headers read as they did: 0.6.0's form, and the form of 0.5.0
and earlier, which held the kit's own folder (app/<version>) in its paths; a header in that folder is read in this kit.
Checked read-only against two real game folders: all 551 lifted objects of a 0.6.0 install and of a 0.3.10 install
match their form and would be taken over.
The objects of 0.5.0 and earlier were compiled for generic x86-64, so an update keeps compiling the lifted code for the
level the objects were compiled for (build-cache/obj/lifted-build.json, lifted_level); --retune, for Rebuild the
Game, compiles it for this processor's level. An update also leaves the shaders prepared before in use and lets the
game translate them again in the background (shader_carry, NX2NAVI_SHADER_CARRY), instead of a full preparation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 10:42:36 -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
chrg6
f1779ec9e4 Refresh the translator beside the game before the shader step prepares shaders.
The compile step copies the kit's translator next to the game, but a kit that changes only the translator runs the
shader step alone (its step key holds the translator's identity), which then prepared with the old copy. From the
local fixes package (fix 9); its translator build guard is in main already.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 09:48:29 -05:00
chrg6
dfc5b90b59 Fix what the 0.6.0 review found, and ship DLSS Frame Generation in the launcher release.
The commit census of the perf trace walked the address space on the presenting thread outside mem_census, which
brought back the hitch mem_census was added to remove; it now runs only with mem_census = 1. DLSS's output pass at
the mode's share fell back to no pass at all when the scene was not at that share (the first presents, a dynamic
resolution step): after such a frame the first pass wider than the scene is taken again for 120 frames. The launcher's
nx2navi.ini editor no longer rewrites a file it cannot read, keeps the byte order mark and bytes that are not UTF-8,
reads an empty line as the game does, and leaves no temporary file behind. The build kit carries the two modules
build_game.py imports on Linux, the Linux steps list the right packages and Python, and stale comments and notes are
corrected (Discord on by default, two prebuild threads, Enhanced HDR gone).

DLSS Frame Generation needs nx2navi_dlssg.dll, NVIDIA Streamline's runtime and nvngx_dlssg.dll beside the game, which
no release carried, so the menu offered it and the game turned it off. tools/make_launcher.py --dlssg and --streamline
put them with their licences and a notice in the release's bin/dlssg/, and tools/make_game.py place_dlssg copies the
whole set beside the game. THIRD_PARTY_NOTICES.md has the row; the notes and README say RTX 40 and 50.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 09:10:36 -05:00
chrg6
7530ca5044 Build on Linux without libunwind, and ship build_game.py in the kit for the Linux build's VMA header.
The Linux build linked libunwind for a frame walk the runtime no longer uses: platform/linux.c walks the stack with
libgcc's unwinder. make_game.py's Linux toolchain imports build_game.vma_include, so the kit carries that file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:22:06 -05:00
loteran
f3daf7e2b4 Build Ocarina natively on Linux with tools/make_game.py, and pack the kit as an AppImage.
make_game.py only knew MSYS2. On Linux it now does what tools/build_game.py's Linux path does:
- clang, clang++ and lld from PATH (checked at start), the system's headers and libraries, vk_mem_alloc.h from the
  system or the pinned copy build_game.py fetches into toolchain/vma;
- the runtime's *_sdl.* files and platform/linux.c in place of the Win32 ones; no shim.c (ui/menu_sdl.cpp defines
  menu_sdl_event), no windres, no DLLs to copy;
- -fdeclspec for C++, as third_party/ffx_api/ffx_api.h declares __declspec(dllexport) unconditionally;
- build_game.py's Linux link flags (-no-pie, noexecstack, rpath $ORIGIN, libstdc++ static) and libraries, plus
  dav1d (the AV1 movies), libatomic and libunwind (the previous commit's plat_frame_capture);
- ocarina and nx2navi_xlate without .exe; the translator from the kit's bin/ or a checkout's build/xlate.
Windows is unchanged: every difference is under os.name.

tools/make_appimage.py packs the kit (tools, recomp, runtime, the built translator, VMA) with a relocatable CPython 3.14
and numpy, lz4, zstandard and fonttools into NX2navi-Linux-<version>-x86_64.AppImage. Its AppRun checks for the
compiler and headers and names the packages for Arch, Fedora and Debian/Ubuntu, installs zbic (GPL-2.0, not bundled)
with pip into ~/.local/share/nx2navi/pydeps on the first run, picks --jobs from the memory, builds and writes play.sh
beside the game. README-BuildKit.md has a Linux section.

Tested on CachyOS (kernel 7.3, clang 23, RTX 3080, NVIDIA 620.70.06, 16 GB): make_game.py --nup ... --jobs 4 builds
ocarina in 9.9 minutes from a 1.1.1 dump, which passes --probe-cfg; a build with the same sources and flags
(compiled by hand before this script could) starts, loads a save and plays. With one compile per thread on 16 GB
the build filled memory and swap and the kernel stopped desktop processes, hence the --jobs advice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:21:36 -05:00
Tyler
a0bba31248 Write the linker map in the launcher's build so sampling profiles can be symbolised
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HtayeqEG2x5woYzWuEQBGV
2026-11-09 08:16:43 -05:00
itaskaev2
e5ce29aa97 Restore the vendored TitleIDs.cs to the pinned translator copy, so build_xlate.py builds again.
tools/build_xlate.py (verify_vendor) requires tools/vendor/ryujinx to match the pinned refs checkout byte for byte and
stops with "tools/vendor/ryujinx differs from MNG in 1 files" since the comment after one title id in TitleIDs.cs was
changed. The file is back to the pinned contents; the translator identity stays 4ced1da5bfc7465d, so shader caches
keep their keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:16:25 -05:00
Claude
837a82a1a1 Put the signed flag of I2F's source format in bit 13 of the Maxwell encoding, where the decoder reads it.
The Ampere I2F lowering wrote (size | 4) << 10, so the signed flag landed in bit 12, which the Maxwell decoder
does not read (ISrcFmt = (op >> 11) & 4 | (op >> 10) & 3). I2F.F32.S16 and the other signed sources converted
as unsigned: in Jabu-Jabu's Belly the walls' deformation grid of signed 16-bit offsets turned -5 into 65531 and
the room shell into huge stretched triangles (issue 57). The size code stays in bits 10-11, the flag goes to 13,
as I2FP already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:16:25 -05:00
chrg6
8e30ad7927 Carry the button art in releases and draw the button prompts during the game build.
make_launcher.py and make_kit.py take --prompt-art (folders holding XGamepad, P5Gamepad and Keyboard_Mouse, or those
folders) and copy only the pictures pad_prompts.py reads into the release's prompt-art folder; tools/prompt_art.py
holds the art tables and that list, with no imaging packages. make_game.py's new last step, prompts, runs
pad_prompts.py on that art into the game folder's romfs-patches-* folders. Its key names everything it reads (the
RomFS, the art, the tools, the bind_ lines of nx2navi.ini, the folders being there), so it runs again only when one of
those changed, and it makes no other step run. A kit without art skips it. The launcher's Python gets fonttools and
pillow, and its jobs show a Draw the Button Prompts row when the version has art.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:09:26 -05:00
chrg6
7f25329e72 Stop saying that shader preparation keeps play from ever stopping to compile.
The preparation translates the game's shaders in their default bind state and builds their stage libraries and
compute pipelines into the driver's own cache. Variants met in play with another bind state are still translated then,
pipelines are still linked in play, and the driver cache is kept per executable and is lost when the driver clears
it. The launcher's step text, the README, make_game.py and docs/launcher.md now say it makes such stops far rarer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:09:26 -05:00
tangerineturtle1
0b4622bad1 Translate the last 31 game shader programs the translator refused, so every one of the 42,177 now translates.
A census of every NVN2 program in the RomFS shader packages found 31 that failed in the SM86 lowering, none met in play yet. Each form was checked with nvdisasm. MUFU.F16 (the upscaler's colour decode: a half lane widened, the F32 function, rounded back to a half) in 11 upscaler programs. ATOMS.POPC.INC with the X16 index stride, the luminance histograms' three counters per 16-byte bin, in 8 programs. LDG and STG .STRONG.GPU, read as plain accesses, in 2. TLD.LZ.MS, a 2x MSAA resolve that reads samples 0 and 1, in 3. ATOMG.CAS for the foliage programs' slot claims in 4, through Maxwell ATOM.CAS, which the translator only logged as not implemented: patch 0037 emits a global compare-and-swap for it. SUATOM.D on a 1D image, the post-effect append counters, in 2. ISBERD.O, a task program reading back its own payload, in 1. HighestGpr also counts the registers these forms read beyond the base fields.

All 31 now pass spirv-val, and the other 42,146 programs give SPIR-V byte-identical to the previous translator. tensor_lowering_check passes 29 of 29, with four new MUFU.F16 cases checked against a model of the lowering (the warp emulator gains MUFU); a wrong half select fails all four.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:09:26 -05:00
chrg6
9e56d5a316 Add keyboard and mouse button prompts, drawn from the art's keys.
The Button prompts row gains Keyboard and mouse (prompts = pc). tools/pad_prompts.py --style pc writes
romfs-patches-pc: every button glyph shows the first key its bindings give it (Ocarina's defaults, with the bind_
lines of the install's nx2navi.ini over them), the mouse buttons as a mouse, the d-pad and the left stick as their
keys laid out as on the keyboard (1 to 4, W A S D), and the camera as the mouse moving. The action prompt shows the
key's label, the ocarina's notes the light keys. A key the art has no picture of is written on a blank key. The pad
styles draw the same bytes as before.

The prompts description says so in each menu language, and the Chinese one no longer splits words across its lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:09:26 -05:00
chrg6
ef08fed45f Ship NVIDIA's DLSS library in the setup and the build kit, and put it beside the game.
The release carried AMD's FSR 3.1 library but not nvngx_dlss.dll, so DLSS ran only where the NVIDIA driver supplied the model itself; elsewhere players had to fetch the DLL by hand. tools/make_launcher.py and tools/make_kit.py now download NVIDIA's own build from the DLSS SDK repository at a pinned tag (tools/dlss_pin.py: 310.9.1, checked against its size and SHA-256, cached), and put it in the release's bin/ with a notice naming the NVIDIA RTX SDKs License that covers it. --dlss FILE takes a copy on disk instead, --no-dlss leaves it out.

tools/make_game.py copies the DLL and its notice beside the game. A different nvngx_dlss.dll the player put there is kept; the one an earlier build placed (named by the notice's sha256 line) is replaced, so a newer release can bring a newer DLSS. The compile step's key covers make_game.py and the kit version, so existing installs get the DLL with their next update.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:09:26 -05:00
chrg6
7ee5ce195e Check a .nup table of contents against the file size before reading it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:09:26 -05:00
tangerineturtle1
9e574f84ec Replace the enhanced HDR with a port of RenoDX's tone mapper.
The game's ACES tonemap shader gets a GLSL function linked into its SPIR-V where it clamps each channel: the game's SDR result upgraded to the HDR range by luminance and mapped to the display with the RenoDRT curve, exposure, highlights, shadows, contrast, saturation, highlight saturation, blowout, flare and hue correction. The settings reach it as four vec4 the support buffer gains at 1440. The present encode is a port of the swap chain pass: gamma correction, gamut compression, the peak clamp and PQ. Without an HDR10 swapchain the shader gives the game's own SDR picture; native HDR is unchanged.

The menu offers Off, RenoDX and Native, with gamma correction, the tone mapper and its grading rows. The shader build compiles sources marked "keep functions" without optimisation so their functions survive for the splice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 06:06:33 -05:00
epicmeme546
778c55777d Say a restart is needed only when one is, and drop the line under Preparing shaders.
The Upscaling row no longer carries "DLSS on or off: after restart". It shows "after restart" only while the upscaler picked cannot start in this run. Frame generation says so only for a change to or from NVIDIA's, since AMD's applies at once, and the HDR row no longer says it twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 04:29:01 -05:00
chrg6
b0d420db3d Land the shader and pipeline stutter pass, and the fixes it needed.
Large compute shaders that no cache holds are built on one background thread after the boot prebuild, smallest first, so their first dispatch no longer compiles them on the replay thread. NX2NAVI_BIG_BUILD_MAX_MB stops that builder once the process has grown by that much: on a 31 GB machine one of these shaders took the process up by 12.8 GB and the game stuttered while Windows paged. The builder takes the queue under its lock and copies each entry out before compiling it, so a shader queued meanwhile cannot free the arrays under it. The same change reports what pipeline-cache.bin gives back, and starts over when the file grows past NX2NAVI_PIPELINE_CACHE_MAX_MB.

A tensor-core program is now tested before its shader is asked for, in both dispatch paths. It runs the stand-in while NX2NAVI_NATIVE_TENSOR is off, and translating it anyway recorded four AI-upscaler shaders of 0.87 to 4.4 million SPIR-V words that this game never dispatches natively. Process memory went from 29.3 GB to 24 GB and the multi-gigabyte builds during play are gone.

The frame-time summary says which part a slow frame went to, and with NX2NAVI_REPLAY_TIME how the replay splits between draws, binds and transfers; NX2NAVI_SVC_SLOW_MS logs the kernel services that block, with the thread they blocked on. prof_report.py reads the map this build writes and adds the image base to a runtime Rip, so a profile resolves to function names instead of question marks.

build_xlate.py applies the patches with GIT_CEILING_DIRECTORIES set to the build folder's parent. Inside a checkout git read 0021-prmt-byte-permute.patch's paths from the repository's top, skipped every file of it and still exited 0, so PRMT was missing from locally built translators and every byte permute was a no-op. A Skipped patch line now fails the build. The note in AmpereLowering.cs that said the translator emits nothing for PRMT is corrected.
2026-11-09 03:34:46 -05:00
chrg6
612c02311d Add Xbox and PlayStation button prompts, drawn from button art on the player's machine.
The Controls tab has a Button prompts row again, with Nintendo, Xbox and PlayStation. prompts = playstation is a new
value next to xbox; nintendo, xbox and pc read as before, and pc stays out of the row as nothing makes its files for
this game. The game reads its prompts at start, so the row says when a restart would change them.

tools/pad_prompts.py writes the overlay folders romfs-patches-xbox, -xbox-label, -playstation and -playstation-label
from the player's RomFS and a folder of button art that stays outside the repository. The button font's glyphs become
outlines traced from the art, the action prompt's letters and the ocarina's note buttons are painted again in their
own BC4 and ASTC formats, and the font's entry in the resource size table grows with it. The by-position folders show
Switch A as B or circle, the by-label ones as A or cross, following the pad layout. The settings probe checks the new
value and folder names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 03:34:46 -05:00
chrg6
b6b76b7547 Give task and mesh payloads room for the header before the program's data, which stops the white specks in foliage.
The payload size in an NVN2 task or mesh program header counts only the program's own data, which starts after a
24-byte header (the mesh count and two words the mesh program reads). The foliage task writes three 1024-byte arrays
from there, up to byte 3096 of a payload sized 3072, so the last entries of the third array were lost and its mesh
programs read past the end of their buffer. Those reads came back different on each run, so a few leaves of each dense
patch landed in different places in the depth pre-pass and the colour pass, and the colour pass's equal depth test left
them unpainted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 03:34:46 -05:00
Claude
b1421faaf9 Show Prepare the Shaders moving in the launcher: the game prints its counts and the step sends them on.
The step sat at 0 % until it was done, an hour on some PCs, because nothing it ran reported progress to the launcher. nx2navi.exe --prepare-shaders now prints how many shaders it has translated and how many it has built into the driver's cache every 2 s. make_game.py reads them as they come and fills the bar, the translation the first half and the build the second, with the counts in the step's text. An event every 10 s keeps the text current while nothing is printed, and after 3 minutes without a count moving it says so, and that the step is still running.

The selftest draws the step as a tenth screen. Its made-up update was version 0.3.11, so from 0.4.0 on the update-ready screen showed Up to Date and was no longer drawn; it is now a minor version past the launcher running it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BSHQpLnScF9sNv4LNAaaS3
2026-11-09 08:32:13 +00:00
epicmeme546
754ded99e0 Raise the frame rate in Kokiri Forest and apply more settings during a run.
The foliage's sun shadows took most of the GPU time: one mesh draw shaded about 1,000 million fragments in the far cascade. The far cascade now shades them at a 2x2 rate, and the two far cascades drop one side of the double-sided cards. At the forest entrance the frame rate went from 18 to about 43 fps on an RX 7900 XT.

FSR 3.1, its frame generation and the console mode now take effect without a restart. The full performance overlay lists the settings shown in the options menu.

NX2NAVI_GPU_PASSES times each pass and counts its fragments, and NX2NAVI_SET_AT changes settings at a given frame for test runs. Both are off by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 02:40:51 -05:00
chrg6
dc1afcb54f Unpack the release's Tcl/Tk again when its pinned installer changed or the last unpack stopped.
make_launcher.py reused WORK/tcltk whenever DLLs/_tkinter.pyd was there: after a new Python or Tcl/Tk pin the old
files went into the release while its runtime id said new ones did, and an msiexec run cut short after that file
was written was trusted too. A stamp naming the msi, written once the unpack is complete, now decides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 15:51:48 -05:00
chrg6
f753dd0e33 Check what is staged, not the working copy, in check_content.py --staged.
The pre-commit check took the staged file names from the index but read their content from disk, so a chunk with
the generated-code marker that was staged and then removed from the working copy alone passed the check and went
into the commit (CI's full check would still catch it). --staged now reads the staged blobs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 15:51:48 -05:00
chrg6
96b33aefd2 Report a malformed .nup table of contents as a damaged file instead of hanging or crashing.
The table's sha256 is checked, but a table whose counts and offsets do not fit it went on: a directory listed as its
own child made tree() go round for good (the build hung at "check"), and a name pool placed before the entries, an
entry index past the lists, a name that is not UTF-8 or damaged zstd data raised struct.error, IndexError,
UnicodeDecodeError or ZstdError, which make_game.py does not catch, so the player got a traceback. All of them are
NupError now, which make_game.py and the launcher report as a damaged dump.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 15:51:48 -05:00
chrg6
95903c361a Mark one cheat or ExeFS patch the lifter cannot take as unsupported instead of failing them all.
convert caught ValueError only, while the lifter raises its own Unsupported for an instruction it does not take (an
FP16 operation in a code cave): tools/cheats.py and tools/exefs_patches.py stopped, and the setup then built the game
without any of the mods' cheats or ExeFS patches. It is now that file's own "unsupported" with the reason. A code
cave with a trap or system instruction before its last one, which recomp/gen.py refuses and which failed the whole
lift, is refused here the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 15:51:48 -05:00
chrg6
215c423d84 Write make_game.py's reset state at once when the game files changed.
A new input reset the steps in memory only; the next save came after the first step finished, while the exefs step
rewrites <out>/exefs in place. A run stopped there left the old state.json saying the old game's steps were done,
and --rebuild then trusted the half-replaced files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 15:51:48 -05:00
chrg6
35ff999958 Rebuild from extracted game folders whose files changed, not only when their count did.
With --exefs and --romfs folders, the identity the exefs and romfs steps are keyed on was the two paths and the
number of RomFS files: a RomFS extracted again or edited with the same number of files, or a replaced sdk or
subsdk0, printed "done before" and the build kept the old unpacked files. Each file's size and modification time
is now part of it. A build from such folders unpacks once more after this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 15:51:48 -05:00
chrg6
a24a21bff5 Write make_game.py's state.json whole or not at all.
A write cut by a full disk or by Cancel ending the build left a state.json that loads as {}: the launcher then took
the built game for none, showed the first run and needed the dump again for a rebuild. It is now written to a
temporary file and moved into place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 15:51:48 -05:00
chrg6
1f4839d4a5 Look for a mod's Atmosphere folders under this game's title id, 0400486024DEC000.
The runtime, the setup's cheat and ExeFS patch tools and the old installer named them after another game's title id, so
a mod laid out as atmosphere/contents/<title id>/romfs (or contents/<title id>, <title id>) was listed as empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 15:51:48 -05:00
chrg6
82257eec3d Send atomics through the device address table to guest memory too, so the trees no longer flicker or stretch into columns.
The culling passes count each frame's visible foliage with atomics through the device address table into small records (an indirect draw's count, then 1, 1). Stores through the table already reached both the VRAM mirror and its guest copy, but atomics reached the mirror only, so guest memory held the CPU's template of zeros. The CPU writes other words of the same pages every frame, and the sync of such a page copied those zeros over the counts: in Hyrule Field the trees flickered, went missing or stretched into columns reaching the sky. NX2NAVI_MEMORY=verify found 5 to 10 such pages a minute, all in ten pools of 20 and 44 KiB.

Translator patch 0036 repeats every table atomic on the twin (a compare-exchange with the same operands), leaving its result unused so the driver need not wait on guest memory. A buffer fill into a mirror now fills its guest copy at once (vk_mem_guest_twin), so a counter the GPU resets that way counts on from the same value in both; that mismatch is why table atomics stayed out of the twin before. The memory check's mismatch lines now also give the pool's last written binding, its last use, the CPU's write stamp for the page and the first bytes of both copies.

With the change the trees stayed steady at the spot where they flickered, all 37,848 shaders translated without a failure, and the GPU time per frame stayed at about 9 ms (75 fps uncapped).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 15:51:47 -05:00
chrg6
f57a327a86 Keep saves safe in Import Saves and Quit, draw no traced game art, and recompile the game for a new processor.
Import Saves: the saves folder picked in the dialog imports what waits in it (it had made the folder's README the
save); the save backed up is the one the game would load, in runtime/fs_host.c save_recover's order, so an interrupted
commit's only copy is kept, and the rest of the commit journal moves into the backup instead of being deleted; the
imported save goes into place before the old one is deleted, which comes back if that fails; another NX2navi install's
finished commit counts as its save. Tests cover each.

Quit waits while the game writes a save, as Restart does: the game runs on under the menu, and closing the window
finishes only a commit that has begun. The VSync row says "in use: Immediate" when VSync On falls back to tearing, and
its default follows the device profile (cfg_default). Without the game's textures the menu's divider is a plain line
and diamond of its own, not a tracing of the game's ornament.

make_game.py: the compile key holds the processor's features (cpu_tag), so a game folder moved to a PC without AVX2
compiles again instead of crashing; the main thread gets 16 MiB of stack with GNU ld too; any error waits for the
RomFS image, so its .part file is not cut short. The launcher tests use a neutral title id; tools/menu_preview.cpp
has cfg_default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 03:57:02 -05:00
chrg6
8daedbd806 Redraw the in-game menu with the game's own interface textures, and bring in the launcher's save import and faster builds.
In-game menu: the settings window, its tabs, rows, buttons and cursor, the performance overlay and the Preparing
shaders box are drawn with the game's interface textures where the RomFS holds them (runtime/ui/menu_skin.cpp,
perf_panel.cpp; plain shapes until they are decoded). Restart joins Continue and Quit, each behind a confirmation;
VSync is an on/off switch; DLSS is listed only on NVIDIA GPUs; the menu sounds are quieter; Picture shape is gone and
the setting descriptions are shorter; edge cases of input, layout and fonts are fixed. tools/menu_preview.py draws the
menu without the game.

Launcher: Import Saves takes a save from the game folder's saves/ folder or one the player picks; downloads fall back
to Windows' own certificate check when Python's refuses a server; updates are faster; the title bar is drawn in the
window and Navi is every icon. tools/make_game.py builds with CLANG64's clang where the launcher installed it, packs
the RomFS beside the lift and the compile, takes a prebuilt runtime, and compiles the game's resources without cmd.exe,
so a user folder with a space in its name builds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 03:57:01 -05:00
chrg6
7cd1b6ee23 Leave the NDSR upscaler's slow, unused compute shaders out of the install's shader preparation.
The translator turns the larger programs of agl_ndsr.pck and agl_ndsr_vr.pck into 3-12.6 MB of SPIR-V, which the GPU driver took 34 s to 44 minutes each to build: 19,400 of the 21,750 s every compute variant took together, most of the install's hour of driver builds. Play met none of them that was slow to build, so the default variants of those programs above 16 KB of code are left out; agl_ndsr_vr_light.pck, whose programs play meets, stays whole. --all-shaders prepares them too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 01:25:12 -05:00
chrg6
936dd8094a Translate 40 more shaders, and build the upscaler's compute shaders five times faster in the driver.
The SM86 lowering now takes MEMBAR (as Maxwell MEMBAR.GL), drops ERRBAR, takes F2I of an immediate and MATCH.ALL.U64,
and finds a switch's jump table bound past the BSSY the compiler puts between the IMNMX and the shift: three vertex
shaders, one of them drawn in Kokiri Forest, were skipped for it. A task program and the mesh programs it feeds whose
payload size field reads 0 (it counts 256-byte units) get one unit. Of the 42,177 programs, 31 still fail, all modes
whose meaning is not certain.

Translator patch 0035 inlines SHFL.IDX over the whole warp (mask 0x1f) on a 32-lane host as the subgroup shuffle,
instead of a call to the general shuffle helper. The tensor lowering shuffles thousands of times per program and the
driver inlined the helper at each call: a mid-size upscaler shader built in 185 s before and in 34 s now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 00:34:29 -05:00
chrg6
96b6e04937 Compile the resources with windres when the install folder's path holds a space.
GNU windres runs its preprocessor through cmd.exe and, left to find it, puts the full path of the gcc beside it on that
command line. When that path and the .rc's both hold a space (a Windows user name such as "Joe Budson"), cmd.exe drops
the outer quotes and splits the command at the first space, so 0.5.0's Compile step failed with "'C:\Users\Joe' is not
recognized". make_game.py, build_game.py and make_launcher.py now name gcc by bare name (the toolchain's bin is first
on PATH) with windres's own preprocessor arguments, and make_game.py and make_launcher.py run windres in the .rc's
folder with relative names. The objects are byte-identical to before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 00:34:29 -05:00
chrg6
fc8a9523a4 Prepare shaders under the code hashes play asks for, from every shader package, with better guessed bind states.
The install step seeded only 63% of the programs a play session met under their run-time code hash. A Switch 2 program with an empty c1 range past its code was hashed with that range, the Switch 2 agl and NDSR packages had no reader, and Layout2Shader/ was not walked. It now seeds 99.3% of the programs play asks for.

A default variant's answers are read again from its first translation (runtime/gfx_shader_guess.c): vertex inputs the shader reads as integers become uint, and a compute shader takes the texture and image types its translation declares. Task and mesh defaults carry the workgroup words play answers with. Against a play session's recorded variants, --prepare-shaders now matches 98.3%; the plain default guess matched 89.5%.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 00:34:29 -05:00
chrg6
d0da862c87 Release 0.5.0: fix the white haze in fog and the flickering foliage.
The float atomic add's compare-and-swap loop (patch 0033) carried its expected value round the loop in a local, but the
pass runs on SSA form and the optimizer's copy propagation takes every value as assigned once, so the loop compared
against a stale value and the froxel fog added up wrong: Kokiri Forest was washed out white. Each attempt now reads the
word with an atomic OR of 0, which also cannot return a stale cached copy.

Writes through the device address table go to the guest copy for stores only (patch 0034). An atomic on the guest copy
started from its stale value, so a counter the GPU reset with a buffer fill kept counting there, and the page's next
sync copied the wrong count into the mirror: culled foliage drew garbage for a frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 22:05:43 -05:00
chrg6
4cb8188491 Write through the device address table into guest memory too, so the GPU's writes there are no longer lost.
The table's records gain a twin: a pool with a VRAM mirror names the mirror first and its imported buffer, guest
memory, second; any other record names one buffer twice. Shaders read through the first address and store and run
atomics through both (translator patch 0034); a page without a twin sends the second write to a 4 KiB scratch buffer.
The GPU's writes through the table were not recorded as GPU writes, so they stayed in the mirror: the CPU never saw
them, and a sync of a page the CPU wrote copied the stale guest page over them. Trees drawn from records lost that
way stretched into columns reaching the sky. With NX2NAVI_MEMORY=verify the Hyrule Field walk found 16 such mirror
pages before and none or one after; GPU time per frame 5.92 ms before, 6.17 ms after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 20:27:34 -05:00
chrg6
e7f6a00407 Translate every shader, keep atomic loops from spinning on stale values, harden pool teardown, and update the README.
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>
2026-11-07 18:03:20 -05:00
chrg6
37c06e6894 Sample terrain with the right mip levels, keep NaNs out of min, max and clamp, and give shadow gathers their own tap offsets.
The runtime's TXD gradient transpose (gfx_shader.c patch_txd_transpose) is off for Switch 2 titles: the SM86 lowering
already orders the interleaved derivatives for the translator, so transposing again swapped them back. The
translator's float min, max and clamp are the NaN-safe forms (patch 0031), as Maxwell FMNMX and saturate behave, so a
NaN no longer spreads through lighting and bloom on drivers that pass it on. Depth-compare gathers with per-tap offsets
are split into one gather per tap like the others (patch 0032), where all four taps took the first tap's offset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 16:28:53 -05:00
chrg6
501d5bd084 Release pass: fix crashes, freezes and races, cut VRAM use, and translate more shaders.
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>
2026-11-07 16:02:30 -05:00
Claude
c403547c8b Add the NX2navi launcher: a one-click setup that builds the game from the player's dump, starts it and keeps it up to date.
NX2navi-Setup.exe installs the launcher into %LOCALAPPDATA%\Programs\NX2navi without administrator rights, with
shortcuts and an Apps entry. The launcher finds the player's .nup, downloads the build tools itself (the MSYS2 UCRT64
packages toolchain.lock.json pins, checked by sha256 and unpacked without pacman, and zbic from PyPI) and runs
tools/make_game.py, whose steps it shows with their progress. Its window follows the game's options menu: colours
sampled from it, the menu's filigree, the white glowing cursor, the Triforce in the title band and as the programs'
icon, and all text in the game's Cetra Display, decoded from the player's own dump. Mouse, keyboard and an XInput
pad drive it.

Updates come from GitHub releases (NX2navi-update.json): the new version is downloaded, checked and staged beside
the running one, the stub restarts into it and falls back to the previous version when it fails to start, and the
game is rebuilt without the dump. make_game.py now keys its exefs and romfs steps on the game files alone, has
--rebuild and --events, compiles only the files whose source, headers, flags or compiler changed, and replaces
ocarina.exe only once the new one links. tools/make_launcher.py builds the release on Windows or Linux.

Tested: tests/launcher_test.py (19 tests), the real toolchain download and install, and under Wine 11 the setup,
the stub, the window on the bundled Windows Python, an update from a local feed by clicking Updates, the rollback
of a version that fails to start, and the downloaded clang compiling and linking a program against the game's
libraries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Merged onto the current port: make_game.py keeps the launcher's step keys, cached link and in-place swap, and its
own runtime manifest (windres), AMD's FidelityFX library and the shader preparation, which becomes a step of its own
("shaders") that the launcher shows in its install, rebuild and update jobs. make_launcher.py ships the shader tools
and, with --ffx, AMD's library.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 14:50:52 -05:00
chrg6
514bb8eaa9 Translate the 8- and 16-bit uniform constant loads whose unused register field is 0, not 63.
ULDC's immediate form (0xab9) has no register index; the sub-word path required the field to hold URZ, as the 32-
and 64-bit paths do not, and compilers leave 0 there too. Of the game's 36,031 shaders, 40 more translate: 20 failures
are left, all the lowering's room for uniform register groups.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 13:42:09 -05:00
chrg6
8f6bcd367e Build kit: ship AMD's amd_fidelityfx_vk.dll for FSR 3.1 (make_kit.py --ffx) and let its DLLs past the size check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 13:31:07 -05:00
chrg6
a42648e27a Add the game's native HDR, render at the monitor's real size, and refresh movie frames on the GPU.
HDR is now a menu row: Off, Enhanced (the runtime's own HDR tonemap) or Native. Native reports an HDR10 display to
the game with the settings' peak and paper white; the game then renders its own HDR picture and presents it as PQ in
A2B10G10R10, which goes to the HDR10 swapchain as it is. The peak, game, HUD and (for Enhanced) hue rows follow it.

The build kit's link left out runtime/nx2navi.rc, so the game had no manifest and no icon: without per-monitor DPI
awareness, a 5120x2160 monitor at 150 % gave a 3413x1440 window that Windows stretched. It is compiled with windres
and linked again.

The movie decoder's frames are copied into the game's buffer by the host; the back end is now told of that write, so
the GPU's copy of the buffer does not keep older or empty bytes (green stripes in NV12).

A longjmp out of the game's JPEG decoder now logs the guest functions that called it, to trace a later crash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 13:31:07 -05:00
chrg6
b9a042969e Keep the HUD out of frame generation, show the frame generation rate, and start DLSS Frame Generation.
Frame generation now gets the picture without the HUD each frame: the upscaler's output before the HUD is drawn over
it, encoded to sRGB as the game's last pass encodes its picture and put through the same colour, scaling and borders
as the presented frame, so it tells the HUD apart and leaves it unwarped in the generated frames
(NX2NAVI_FG_HUDLESS_SHOW=1 shows that picture, a test). The performance overlay gains an FG row and the fps line the
display's rate, generated frames included. The device enables VK_KHR_get_memory_requirements2 whenever AMD's frame
generation is on, which crashed at start with DLSS upscaling.

DLSS Frame Generation through NVIDIA Streamline (vk_dlssg.c, and nx2navi_dlssg.dll from runtime/dlssg, built with
MSVC by tools/build_dlssg.py against the SDK kept outside the repository) creates the instance and device through
Streamline's proxies and calls its swapchain hooks; Streamline still fails in its plugin start-up here, so the menu
lists it only while it is set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 13:31:07 -05:00