Repository navigation
Conversation
added 30 commits
October 12, 2026 22:04
Generic host, gfx and tools taken from d2r-mobile (MIT), with the D2R gameplay, diagnostics and Blizzard/Granny/movie layers removed. - hle_hid.c: generic standard-controller layer (all Npad styles) - hle_sdk16.c: newer-SDK oe/time/pl/vsync/diag hooks - hle_offline.c: offline stubs for prepo/ldn/socket/ssl/nifm/nsd/friends/ngc/err - hle_fs.c, hle_account.c: SDK 16 overloads - loader.c: unreferenced forced hooks only logged (DM_FORCE_STRICT=1 aborts) - NVN: API 55.15, 13 newer names, ~45 state-only functions, tex_t packed to 0x80 (Mario allocates NVNtexture as 0x80; 0x88 corrupted the heap) Frontier: null read at main+0x64763c inside the frame loop.
- hle_svc.c: guest AS 6 GB with a 1.25 GB alias region (newer SDK's AddressRegionManager always takes ~1 GB of it as its node area), MapPhysicalMemory rounded to 16 KB host pages, GetInfo(UserExceptionContext) backed by a real buffer, program id now SMBW (DM_PROGRAM_ID overrides) - hle_audren.c (new): silent AudioRenderer, event fired every 5 ms - hle_fs.c: SetPriorityOnCurrentThread / IsEnabledAccessLog (fsp-srv) - hle_sdk16.c: settings language comparison; diag aborts report the call site and backtrace - NVN: nvnProgramSetShadersExt (0x18-byte stage entries) The game now runs ~40 threads; the main thread waits on job events while render commands (CallCommands, BindTexture, BindVertexBuffer, DrawElements, WriteTexels) are still unimplemented.
- BindTexture (combined handles go straight into the texture slot; the replay already splits texture / sampler ids), BindImage, BindTexturesDeferred, BindVertexBuffer, CallCommands - DrawElements / BaseVertex / ArraysInstanced; viewport, scissors and depth ranges in single / multi forms - ReportValue via the event-write record; new OP_CLEAR_BUF record with in-order replay (fillBuffer, or a pattern buffer for non-uniform values) - TextureWriteTexels: deswizzle level, patch region, swizzle back, after lifting write protection - Command memory: when the game's callback cannot supply enough, continue in a host segment instead of aborting - Remaining state the replay lacks (conditional render, depth clamp, rasterizer discard, ...) is logged once and drawing continues The game now runs its frame without errors from these; the main thread waits in the job system's fork-join (executors keep polling).
- patch_nso.py: fix exclusive-window exit order. The fall-through stub must come right after the copied window; it was emitted last, so a successful stxr in 'ldxr; cmp; b.ne out; stxr; cbnz' fell into the branch-out stub (main 0x81c40: job-system enqueue retried forever, tail filled to capacity with no task stored). Bug inherited from d2r-mobile, latent there (no branch-out windows). - patch_nso.py: rewrite 'mrs xN, ctr_el0' (trapped on macOS) to a constant with 64-byte data cache lines. - hle_thread.c: SetThreadCoreMask moves the ideal core into the new mask (Horizon behavior), so pinned threads report the right core. Frames 2 and 3 now record, submit and present (~1,900 NVN calls). Next: Mario's shaders (bfsha) are not in the translation map yet.
Shaders - shader_split.py (new): scan RomFS and main for every BNSH and agl BAHS container (bfsha, particle effects, layouts, agl/gsys packs, main): 12,811 shaders, map + compute facts from the control section - key = sha256(control + code): many shaders share a control section - NVN 55 binding layout: bound textures at 0x20 + 8*slot, images 0x120 - bindless textures read from uniform buffers (tex_ubo / samp_ubo) - GL depth mode: translator remaps z' = z/2 + w/2 in vertex shaders - compute code areas carry a 0x30 header (magic 0x12345679) Replay - 8-bit index buffers widened to 16-bit - texture swizzle through Metal swizzled views - non-packaged textures shared by storage (fixes a ~13 MB/frame leak from transient render targets rebuilt every frame) - view_t packed to 16 bytes (SDK 16 NVNtextureView; fixes a stack smash) - TBDR optimizations off by default until they know bindless readers Host - alias region 2.875 GB for the 1.75 GB VirtualAddressMemory reservation - ideal core -2 resolves to the process default core - shared font served with a BFTTF "decoded" header - crash reports scan the stack and dump the popped frame Docs: docs/agents (guides for porting other titles), AGENTS.md
- DM_KEYS scripted controller input ("seconds:button[+button][~hold]")
- NVN virtual memory pools aliased onto their physical pool when every
MapVirtual request shares one base (Mario's 128 MB pool); previously
MapVirtual failed and the game treated the pool as unusable
- DM_PROBE ported from d2r-mobile (host/probe.c): brk probes with
register / backtrace output, plus DM_PROBE_X2 object dumps; used
because lldb launches now wait on a macOS authorization prompt
- diagnostics: DM_NVN_VLOG (pools, MapVirtual), DM_NVN_CBLOG (command
memory grants and callbacks), DM_NVN_ALLOCPROF
- docs: new failure patterns and the probe recipe
Open: starting a new game crashes while loading the opening course
(model resource heap overflow for NpcCommonerA.bfres).
…PU-written text - patch_nso.py: Mario main cut gives every resource heap +16 KB; Model/NpcCommonerA.bfres came up 0x70 bytes short of its size-table budget while loading Course900 - dmsh_build.py: compute instructions start at code area +0x100, not +0x30; the misaligned decode turned 12 particle / post-effect compute shaders into endless loops (GPU hang) - Linear textures in CPU-visible pools are built on the pool buffer, so the CPU-rasterized glyph cache reaches the GPU (menu and dialogue text) - Host command-memory segments grow on demand; RGB10A2SN vertex format; instanced DrawArrays - DM_PROBE: thread IDs, register-relative dumps, hit filters, ExpHeap walker - dm/tools/ghidra/Decompile.java; agent guides and README updated
…y colour ramps - dmsh_build.py: vertex shaders whose inputs are only used as integer bit casts are re-translated with uint inputs (529 shaders); bone indices were converted to floats and every character was stretched off screen - Host: Metal vertex formats follow the shader input type (signedness swap, 32-bit float reinterpretation), mismatches reported - LINEAR_RENDER_TARGET textures in CPU-visible pools are zero-copy too (sky colour ramps) - Pass dump lists all vertex attributes; docs and README updated
- dm/ios: lean app shell (main.m boot/env/log, front_ios.m front.h + 16:9 Metal view, DmGamepad.m touch gamepad in Nintendo positions + GameController), xcodegen project, tools/build_ipa.sh (embedded game code, iOS shader libraries, RomFS in the bundle) - Guest address space back to 5 GB (heap 1.625 GB; the game asks for 1.47 GB) - README / agent guide: iOS build steps and address-space sizing
…nt, ordered copies - Audio: run the sdk's own audio renderer on the CPU in manual mode (hle_audren.c), feed its DeviceSink output to the AudioOut sink; catch-up render on back-to-back updates fixes the ApplyLightLimiterEffect crash at the title screen - Button icons: make_ext_font.py generates a stand-in Nintendo extension font (A/B/X/Y, L/R/ZL/ZR/SL/SR, +/-, D-pad, stick arrows); served as shared font type 5; the iOS bundle now carries both shared fonts - Fountain panels: Metal 4 does not order copies inside one encoder; add barriers when ranges overlap, so the GPU wave simulation no longer reads a stale uniform - Zero-fill new colour textures; scissored zero clears; uniform-update snapshots - Docs: graphics ordering, audio, diagnostics, intermittent-glitch method
Ranges are rounded to 16 KB host pages but NVN pools are only 4 KB aligned, so adjacent pools share their first / last page and one address can fall in several registered ranges. Every lookup took the first range containing the address: - textures whose pool's first page is shared with a smaller preceding pool were judged untracked and re-uploaded on every use (two ASTC 6x5 textures in the opening course: 12 re-uploads, about 6 MB, per frame); - a fault or host pre-write on a shared page released only one range, leaving the other marked protected; - destroying a pool could unregister its neighbour (same rounded base). Tracked / protect / since now use the range that holds the whole span; faults and host pre-writes release every range covering the page; pool removal matches the exact pool start. Opening course: 3600 re-uploads per 300 frames -> 0; DM_NVN_DIRTYCHECK=1 over 3900 frames: 0 misses. t_dirty_slots covers the shared-page case (3 checks fail on the old code).
A sideloaded app cannot be given environment variables from outside. main.m now reads KEY=VALUE lines from Documents/env.txt and from dm/env.txt in the bundle (Documents wins, real environment wins over both) and logs each applied line as "boot: 环境 ...". build_ipa.sh copies DM_ENV_FILE=<file> into the bundle as dm/env.txt.
dmsh_chain.py --update-lock on a fresh Mac (Xcode 27.0, metal 32023.921 unchanged): the translator DLLs built here and Homebrew's spirv-cross have different fingerprints. Chain b1a4876b9511; dmsh_build gives the same result as documented (12809 / 12811 compile, the same 2 agl compute shaders make SPIRV-Cross throw) and c1_full.tsv lists the same 11 shaders. Another machine with other tool builds needs --update-lock + --header.
Opening course on an iPhone 18 Pro Max (A20 Pro GPU): black diagonal band, black-edged white glow at the horizon, grey striped blocks, alternating frame by frame. The Mac (M4 Pro) never shows it, not even with the iOS metallibs, display pacing, -Os, DM_3D_SCALE=0.75 or the no-BC path. On-device colour-target stats (DM_DBG_TEXSTAT, diagnostic commit that follows): even frames' main 1920x1080 RG11B10 target has 54 NaN pixels (Mac: 52); odd frames 727k NaN, and the 960x540 / 1100x280 / 275x70 targets downsampled from it carry it on. The NaN is already in the main target before the first downsample (pass 47 of 80), so it comes from the scene passes, not the post-effect chain. The translated shaders reproduce Maxwell's NaN rules with select(x, 0, isnan(x)) (8337 / 12809 shaders). Default fast math records air.compile.fast_math_enable, which lets each GPU's backend compiler assume no NaN / Inf; relaxed keeps the reassociation / contraction but preserves NaN / Inf. Hypothesis only: chain 1b46c9a2e920 (MSL byte-identical to b1a4876b9511; c1_full.tsv lists the same 11 shaders) still has to be run on the iPhone. If the NaN persists, the next step is finding the producing draw in passes 12-45.
Temporary instrumentation for the A20 Pro NaN investigation; every line is tagged [DEBUG-flk1] so it can be removed with one grep. - DM_DBG_TEXSTAT=N with DM_NVN_TEXDUMP=<frame>:<path>: for N consecutive frames, log one line per colour target instead of writing PNGs: per-channel mean, NaN / Inf counts, largest finite value, black share. - Inside the DM_NVN_PASSDUMP window: each submission's commit->completion time and the counter values written back (timestamps / samples passed). - DM_NVN_SHOT accepts up to 4096 frames (was 16). Device capture used so far (unsigned IPA, DM_ENV_FILE for build_ipa.sh): DM_NVN_TEXDUMP=3600:td_%d.png DM_DBG_TEXSTAT=2 DM_NVN_PASSDUMP=3600-3601 DM_NVN_SHOT=3600,3601,3602,3603:shot_%d.png DM_NVN_SHOT_OUT=960x540
Fixes the flicker / black band in the opening course and the crash after the first scene on the iPhone (A20 Pro), confirmed on the device. - nvn_obj.h: cmd_t leaves byte +0x10 of NVNcommandBuffer to the game. Mario's inlined NVN code writes 1 there (main+0x4da5c, main+0xb8dec). It used to hit the low byte of `end`: the game's 512-byte material setup blocks shrank and overflowed into host segments, GetCommandMemoryUsed (cur - begin) returned 0, the game marked the setups empty and skipped calling them, and draws ran with the previous vertex buffers (out-of-range vertices, NaN). - hle_nvn.c: GetCommandMemoryUsed counts bytes across host segments plus 16 for the jump. Host segments are released only when the game re-grants memory overlapping the recording's guest bytes (the game keeps calling recorded setup blocks for many frames); the 8-frame recycling is gone. - nvn_mtl.m: failed pipelines are cached and reported once with their vertex / fragment keys instead of being rebuilt on every draw. - front_ios.m / main.m: the audio session asks for a 5 ms I/O buffer at boot and on return to the foreground. The default (~21 ms, 1024 frames per callback) outran the 4 x 5 ms the renderer keeps queued: every callback underran (crackling). Device: 240-frame callbacks, 0 underruns. Still contains [DEBUG-flk1] instrumentation (tagged, mostly behind DM_DBG_* switches; audio statistics every 2000 callbacks in hle_audio.c). To be removed with one grep.
Metal builds a pipeline only when every pixel shader input is a vertex shader output; Maxwell gives an unwritten attribute a default. With shaders translated one at a time, 331 of v0's 9,043 vertex / pixel pairs failed to link and later levels lost those draws (about 11,500 failed pipeline builds in one device session). - shader_split.py writes shader_pairs.tsv (pairs of every BNSH variation) and takes comma-separated RomFS / main lists for several game versions, writing their union (keys are content hashes; v0 rows keep their package indices). - dmsh_build.py vs_pad(): vertex shaders get the outputs their partners read but they don't write, float4 (0, 0, 0, 1); vertex shaders with partners are finished last and their partner list is part of the cache rule. shader_pairs.tsv is part of the chain version. - Tables now cover v0 and update 1.2.1: 16,268 shaders (1.2.1 recompiled 3,451 SecredUber pixel shaders and added 6 effect shaders), 14,603 pairs. Chain 5f1ec82dfcf0: 16,266 compile (the 2 known SPIRV-Cross failures); an offline link test of all pairs gives 14,603 / 0 (v0 before the padding: 8,712 / 331). c1_full.tsv regenerated (same 11 keys). The v0 IPA with this padding played 11 minutes on the iPhone with no pipeline failures.
…calls - dm/tools/nx_extract (C#, LibHac 0.19): hactool stops with "Invalid BKTR layout!" on the update's patch NCA. nx_extract reads the NCAs straight from both NSPs, imports their common tickets, merges the update's RomFS over the base game, prints the display version and module build IDs, and writes files identical to a base RomFS as APFS clones (the merged 1.2.1 RomFS adds about 114 MB). - dm/tools/nso_fnmap.py: carries offsets between builds by matching eh_frame functions with address bits masked; globals through their adrp references. - patch_nso.py: resource heap +16 KB cut for 1.2.1 main ff773e90... (main+0x1cf9b0, mapped from v0 0x1e62fc; the function is identical after masking). fixups.tsv now records the module build ID; the loader keeps it in module_t.build_id. - hle_oe.c: the 3D render scale inherited from d2r-mobile writes and calls fixed main addresses (0x31e0848, 0x8582f0). In Mario v0 0x8582f0 is the middle of a static initializer; it only did nothing because the pointer read 0. Now enabled only on D2R's build. - hle_misc.c: owned add-on content defaults to none except on D2R's build (DM_AOC_OWNED overrides). - New imports in 1.2.1 answered as a Switch 1 without amiibo: nn::nfp (one NFC device on the connected controller, detection never finds a tag; nfp::Initialize at boot used to abort in nn::sm), pl::IsRunningOnOunce (false), ec::ShowShopApplicationInformation- ForUpgrade (no-op), account::PopOpenUsers (none: the game falls back to TryOpenPreselectedUser as in v0). oe::GetDisplayVersion by build (1.0.0 / 1.2.1). Mac: 1.2.1 and v0 both run the scripted opening for 120 s with only the known SetRenderEnableConditional red line. iPhone: 1.2.1 played 8.5 minutes with no crash.
- README: status for v0 / 1.2.1 on the iPhone, update 1.2.1 build steps, diagnostic env files, finishing the IPA by hand when Xcode uses a custom build location, app data folders after a reinstall, prewarm lists (pso_user.tsv / pso_manifest.tsv). - AGENTS.md: per-build knowledge keyed by build ID, shader_pairs.tsv on the chain, unsigned IPAs only. - docs/agents: update extraction and offset porting (01), the command-buffer byte, command memory, iOS audio, update imports and build-gated D2R code (03), vertex output padding and iOS math mode (04), on-device diagnostics and the offline link check (05). - dm/gfx README / nvn_metal_mapping (en + zh-CN): pairs table, several game versions, prewarm lists, DM_PSO_USER, command buffer notes; corrected shader key, build script and 8-bit index lines. - dm/host/README(.zh-CN).md removed: an index of d2r-mobile's D2R features; most files it listed no longer exist.
- DmGamepad.m: layout after a PS remote-play pad. ZL above L and ZR above R (teardrops) in the top corners; -/+ in the bottom corners with the D-pad (four arrow pads) and the A/B/X/Y diamond just above them; left and right sticks next to those along the bottom edge. Everything hugs the edges to leave the picture room. Layout constants are at the top of the file. - Sticks are fixed rings (tilt from the ring centre, 0.12 R dead zone) instead of the floating left stick; the new right stick merges with a physical pad's right stick the same way as the left one. - One CAShapeLayer per control instead of a full-screen drawRect: a press swaps the fill, a stick move only moves its knob. Colours carry low alpha (fill 0.14, outline 0.38, labels 0.6) rather than a view alpha, which would add an off-screen pass. - front_ios.m header and the README app-shell line follow.
- dm/ios/tools/build_ipa_from_nsp.py (Spyder or python3): picks the base game and update 1.2.1 by title ID (DLC is skipped), extracts them with nx_extract, checks the main / sdk build IDs, rewrites the modules, splits the shaders and requires the tables to match the repo's byte for byte, builds the iOS shader libraries, then runs build_ipa.sh. It uses only the repo, the NSP folder and prod.keys: intermediates go to <NSP folder>/smbw_build/ (full step logs in logs/), and the extracted game files are deleted after success. Tested end to end: first run 33 min, re-run 10 min. - dm/gfx/tools/dmsh_xlate_bin: the translator build that matches dmsh_chain.lock. A fresh dotnet publish gives different dmsh_xlate and Ryujinx dll fingerprints, which dmsh_build refuses. - build_ipa.sh: when Xcode's Locations setting is a custom location, take the app path from the build log instead of stopping at "no built app". - README: the script; the custom-location note replaces the by-hand finish.
- nx_extract --manifest: write ExeFS and romfs_manifest.tsv (path, size, first 32 bytes of every file) instead of the RomFS, so a large title can be surveyed without writing its game files. - nx_extract prints the build ID of every NSO module, the display version and the game name, and saves the raw control.nacp next to the output for naming the app. - Game name: newer SDKs compress the NACP title area (u16 size + raw deflate, inflating to 32 languages x 0x300; Mario 1.2.1 does this). LibHac 0.19 does not decode it, so nx_extract does. - nso_syms.py: '-' for the reference game compares one game's imports with the host hooks only.
- dm/games/<id>/game.tsv holds what is specific to one game: title and program ID, known builds (module build IDs, display versions), package and shader versions, code modules, RomFS marker, zip store list, memory split, NVN driver constants, shader split groups, app name / bundle ID / IPA name. Mario's profile is smbw, the default. - The shader tables, c1_full.tsv, pso_manifest.tsv, bf_want.tsv and dmsh_chain.h move from dm/gfx/nvn to dm/games/smbw. - dm/games/game.py loads profiles (DM_GAME, by title ID), answers shell queries and generates the host's game_profile.h. - Shader tools (dmsh_chain, dmsh_build, dmsh_facts, shader_split, tbdr_budget) take tables and constants from the profile. dmsh_build stops if the profile's texture / sampler bases differ from the translator's built-in ones. dmsh_chain hashes the profile's nvn_* / shader_* keys; the chain version is now 02ed42db694f. All 16,266 translated shaders are byte-identical to 5f1ec82dfcf0's, and c1_full.tsv differs only in its header. - Host: GAME ?= smbw in the Makefile; memory split, display versions, NVN bases, default modules, window title and the shader map path come from the profile. D2R-only code (Settings.json edits, the main+0x3509a0 read) runs only on D2R's build, which also stops a stray Settings.json in Mario's iOS save. - iOS: build_ipa.sh, gen_build.py, project.yml and main.m take the app name, bundle ID, category, modules, RomFS marker and tables from the profile (GAME=<id>, workspace ~/<id>-work). - dm/games/README(.zh-CN).md: the keys and how to add a game.
- The game comes from the NSPs' title ID and its profile in dm/games/; the versions to extract, the accepted build IDs, the modules to rewrite and the tables to compare all come from the profile. TITLE / BUILDS are gone from the script. Work folder: <NSP folder>/<id>_build/. - A title with no profile is surveyed instead: <NSP folder>/<title ID>_survey/survey.md lists the NSPs, modules and build IDs, SDK version and components, Unity version, engine / API markers, RomFS folders, magics and extensions, insn_census counts, imports vs host hooks, and notes. Fire Emblem Engage was surveyed this way. - APP_NAME setting; empty uses the game name from the base NSP's NACP (compressed title areas decoded), then the profile's app_name. - PACKAGE and OUT_IPA default to the profile's package and ipa. - Tested on Mario end to end from fresh extraction: the IPA is named "Super Mario Bros. Wonder" and carries the current chain's tables.
- README: presented as Switch games running natively on Apple platforms, with Mario as the one supported game. A games table (Mario playable, Fire Emblem Engage surveyed), component status, game profiles and how to add a game, the NSP script, generic step-by-step build commands (profile, workspace and version as variables), and a Mario section for the per-game notes (1.2.1). - AGENTS.md: profiles, DM_GAME / GAME, workspaces, build-ID gating, the chain rule per profile. - docs/agents: one repository with one profile per title; survey mode in 02-survey, including the compressed NACP title area. - dm/gfx README (+ zh-CN): table paths in the profile.
- hle_nvn.c: drop the command memory callback / grant / caller logging, the overflow details, the +0x10 write log, the one-off NVN table dump, and the DM_DBG_GRANTS, DM_DBG_CALLSITES, DM_DBG_CMDMEM_SHRINK and DM_DBG_OLD_USED switches. - nvn_mtl.m: drop the per-draw NaN probe (DM_DBG_NANPROBE), the colour target statistics (DM_DBG_TEXSTAT) and the PASSDUMP completion timing. - Kept as regular diagnostics: the audio callback line every 2000 callbacks (frames per callback, queued blocks, underruns) and DM_DBG_AU_FRAMES (docs/agents/03-bringup.md, crackling on iOS); DM_NVN_SHOT up to 4096 frames (the 05-debugging burst recipe). - Mac 1.2.1 scripted run reaches the opening course with the same single red line as before.
- attach(): a render-target view that changes the format is attached as a Metal view of that format (kept until the submission completes), so pipeline formats follow it. Mario's last pass writes the RGBA8 swapchain texture through an RGBA8_SRGB view; with the base texture attached, linear values were stored unencoded and the whole picture was darker: on the Mac and the iPhone every channel equalled the Switch value decoded from sRGB once more (0.55 -> 0.26). After the fix the Mac title frame matches a Switch screenshot (mean RGB 0.556 / 0.621 / 0.633 vs 0.557 / 0.621 / 0.633). - present_raw_src(): an sRGB-typed swapchain texture is sampled through a non-sRGB view, so the stored bytes reach the screen as on the Switch's scan-out (no change for Mario, whose swapchain is RGBA8). t_present_crop gets an sRGB case (34/34; fails without the fix). - docs/agents/04-graphics.md and the mapping docs: the rule and how it was measured.
- patch_nso.py: three more x18 forms from IL2CPP code: an offset jump table (targets read at rewrite time), blr x18 (original return address kept for C++ unwinding) and an sp write from x18 (alloca). Mario's rewrite output stays byte-identical. - loader.c: symbols resolve globally in load order, also for a module's references to its own exports (local / non-default visibility excepted). Engage's main overrides operator new / delete; sdk bound its own copies and freed Unity's blocks into the SDK heap. - hle_svc.c: QueryMemory reports each module's Horizon layout (code, read-only, data, patch area) and other host memory as free, which the SDK's C++ unwinder (nn::ro::detail::GetExceptionInfo) needs. - New takeovers: nn::fs::IsMounted, nn::ro (hle_ro.c), prepo Initialize, SDK 12 audio device names and OpenDefaultAudioOut, an SDK 12 hid block (single GetNpadState, modes, touch, gestures, six-axis details, colors, applets), movie::Decoder with no impl (hle_movie.c) and failing nvdrv opens (hle_nvdrv.c), and NVN getters / no-ops Engage calls. nvn.h: TextureGetMemoryPool returns a pointer. - Makefile: a game stamp, so changing GAME rebuilds the host. - docs/agents/03-bringup.md: catalogue entries for all of the above. - Mario 1.2.1 scripted run still reaches the opening course with the same single red line.
- dm/games/fe_engage: identity and the 2.0.0 build IDs (main, subsdk0, sdk), modules in Horizon load order, RomFS marker, empty shader tables and their chain header. Memory: an 8 GB reservation with a 5.5 GB alias region for its virtual address memory (Mac only for now: iOS allows at most 6 GB without the extended-addressing entitlement); NVN constants are Mario's until measured. - On the Mac the host boots Engage through Unity's startup and runs to the opening movie with nothing on screen yet: its shaders are in UnityFS bundles that shader_split.py cannot read, and movies are not decoded. - README: the games table row.
- New dm/gfx/tools/unityfs.py: UnityFS bundles (LZ4 / LZMA blocks), serialized files (formats 19..22), objects read by their type trees (Unity's common string table comes from the game's own main), and a Shader object's per-platform compressed subprograms. The player's own files have no type trees and borrow the bundles' Shader tree of the same type hash. - shader_split.py reads Unity Shader objects in a second pass: each Switch subprogram is one NVN program (0x60-byte header of per-stage offset / control size / code size, then control + code per stage); a program's vertex / pixel stages form a pair. Engage: 9,269 shaders, 4,634 pairs. Mario's tables and package are byte-identical. - Engage profile: shader groups engine / assets, measured NVN layout (texture handles 0x168 + 8 r, 128 slots; separate samplers 0x568), regenerated tables, chain a295a8035b7b. 9,268 of 9,269 compile (one geometry shader; Metal has none). - dmsh_build.py: the translator's built-in bases only matter with per-slot facts, so the guard checks that; c2 reads count the sampler table and 16-byte rows overlapping a table as fillable. - game.py: DM_GAME_NVN_SAMP_BASE. NSP script survey note updated. - Mario chain is now 271056163ea2 (Mac and iOS libraries rebuilt, 16,266 of 16,268 as before; c1_full regenerated).
…gets a notes column (60 fps upgrades, DLC, touch layout)
…ault language; English-only comments, bilingual README - Magenta 16x16 blocks in Super Mario 3D World 1-1 (iPhone only): the composite shader 66a71a3081b91b9a renders into the RGB10A2 image while sampling it in the same pass. That is undefined in Metal: the M4 Pro reads the old content, the A20 Pro sometimes returns whole 16x16 blocks as (1,0,1). Found with the new device self-check DM_NVN_MAGSCAN (blocks first appear on that attachment, and still appear with the suspected particle dropped). fb_prepare ends the pass, copies the attachment level into a snapshot and binds the snapshot for that draw, only for shaders in the new profile key feedback_snap (doing it for every shader cost BotW 16.6 -> 36.6 ms). DM_NVN_FB_SNAP=0 / all / <keys> overrides. - The game language now defaults to English (nn::oe::GetDesiredLanguage returns en-US; DM_LANG=zh-Hans in Documents/env.txt for Chinese). - Code comments, docstrings and docs are English only; the zh-CN doc twins are removed. README.md has the English text followed by the same text in Chinese. Files the shader chain version hashes keep their bilingual comments (editing them changes every game's chain version).
….0, SDK 8); BotW HUD prompt boxes fixed BotW: the button-prompt shadow samples an R8 blur whose swizzle (R,0,0,1) made alpha 1, so every prompt got a solid box. New profile key alpha_from_red takes alpha from red for the named shader. Link's Awakening: - NVN lower-left window origin (negative viewport height, winding flip, flipped present and raw screenshots) - texture copies with format change, scaling, mirroring and depth (copy_t2t_draw); SetCopyImageStride; nvnWindowGetPresentInterval - oe::PopNotificationMessage, vi SetLayerCrop / DestroyLayer / CloseDisplay / Finalize, audren P_SIZE 0x40 for SDK 8, hid style-set update event signalled once on bind - Vorbis movie audio through stb_vorbis (dm/third_party/stb_vorbis) - patch_nso jump tables: other index registers, mov copies, masked copies
…d alpha from red in all 26 layout shaders); work folders move to the NSP folder The prompt mask is a layout capture (panes tagged CaptureOn / A8): an R8 render target mapped (R, 0, 0, 1) holding the blurred alpha in red. Besides the black shadow (e6a88e12), each prompt bar draws a cream glow (aa209f57) whose alpha is min(cloud alpha, capture alpha); with only the shadow shader listed, the glow filled each key's rectangle with the Kumo64 cloud. alpha_from_red now lists every pixel-shader variant of the layout library (main's BNSH at 0x1d83000) and tex_alpha_red only converts render targets. Game work folders now live in <NSP folder>/<id>-work instead of the home folder: AGENTS.md and the docs say so, and build_ipa.sh requires W and writes the IPA next to the work folder by default.
…age fixed - Sound: SDK 8 numbers the DSP commands differently and its DeviceSink is 0x10, not 0x13, so every rendered frame played silence (only the movies had sound). capture() now takes the one 0x148-byte command with 1-6 inputs as the sink when the expected ID is missing. - Lighting: the light-culling compute shader reads its workgroup count from NVN's driver segment c0 (+0x200). dmsh_build's drv_reads scan only matches fragment-shader names, so compute and vertex shaders got an all-zero c0: every tile row wrote row 0, and the doorway step flickered with white 64-pixel tiles. A declared driver-segment binding now counts as read, and compute c0 carries the dispatch size (0x200) and the uniform buffer table (0x210 + 16 r). BotW and SM3DW render as before. - Foliage: the shadow / depth pre-pass pipeline 147c829e79fb322f failed (uint4 inputs fed 16-bit normalized formats), so with depth test EQUAL the palm tree and flowers never drew. New profile file shader_facts_manual.tsv (merged by shader_split.py) declares those inputs float; Link's Awakening's chain is now ccb18ba743bf.
… a provisional profile; Link's Awakening stencil copy and outdoor shaders - README: a gallery with one picture per game (docs/images): iPhone shots with the virtual gamepad for Mario Wonder, 3D World, BotW and Link's Awakening; Mac shots (captioned) for Engage, Metroid Dread and 13 Sentinels. Link's Awakening is now listed as in testing on an iPhone. - scripts/build_ipa_from_nsp.py: a game with no profile is surveyed, then gets a provisional profile guessed from the survey in <NSP folder>/<id>_build/profile/<id>/ (outside the repo, reused on the next run) and a best-effort IPA; --survey-only keeps the old behaviour. game.py searches DM_GAMES_DIR after dm/games; the host Makefile reaches such a profile through a symlink; build_ipa.sh finds it through game.py. zip_store also stores files whose headers say they are compressed. - copy_t2t_draw: depth-stencil copies now carry the stencil ([[stencil]] export from an X32_Stencil8 view). Link's Awakening's occlusion pass tests stencil bit 1 of its quarter-size depth copy, whose stencil was the new texture's undefined content. - Link's Awakening: four outdoor shaders with the foliage shader's input loop failed on the iPhone (Half2 / normalized formats); listed in shader_facts_manual.tsv. Chain c4995bb3161c.
… screenshots recaptured on the Mac - Link's Awakening 1.1.0 main: the per-world PhysX completion task destroys itself in its release (vtable back to the base, mTm = 0). At 30 fps the game steps physics twice per frame; a worker descheduled between the run's unlock and the release let the main thread rebuild the task first, and the late destructor wiped the new one, so the next completion crashed in removeReference (main+0x10ccf28). A per-build cut makes that release a ret. Unfixed, every Mac run with the CPU loaded crashed; fixed, runs with 138-257 switches to 30 fps and walks into and out of the house are clean. - Crash reports print what each register points at ([dm] *xN), so an object's vtable names its class. - RED_ONCE's flag array was one slot short. - README gallery: Super Mario Bros. Wonder, Super Mario 3D World, Breath of the Wild and Metroid Dread recaptured with the current build; no "(Mac)" captions. - docs: the crash in the bring-up catalogue; debugging recipe for racy crashes (CPU load, trace gates, a ring printed at the crash).
…d; README screenshots of Engage, 13 Sentinels and Link's Awakening - NVN's depth mode is runtime state: Mario, Metroid Dread, Super Mario 3D World and Breath of the Wild keep near = -w (GL); Link's Awakening, 13 Sentinels and Engage set near = 0. The translator rewrote z for GL in every vertex shader, so near = 0 games had all depths in 0.5..1 and depth-to-distance effects were wrong: Link's Awakening's depth of field blurred the whole screen outdoors. - The translator no longer rewrites z; dmsh_build.py (vs_depth) writes two entry points into every vertex library, main0 with the GL rewrite (the same arithmetic as before) and main0_z without; the host picks one from the mode the game sets (mtl_set_depth_zero, shader_load). No per-game setting; a red line if the mode changes after vertex shaders loaded. Metal function constants were measured at about 2.4 ms of specialization per vertex shader, so two entry points instead. - New translator dll (Ryujinx dlls unchanged), lock and chain versions for every profile; Mac libraries and c1_full.tsv rebuilt for Link's Awakening, Engage, 13 Sentinels and Mario Wonder (Breath of the Wild, Super Mario 3D World and Metroid Dread follow). - Checked on the Mac: Link's Awakening outdoors (from a save in Mabe Village) has a sharp middle band again; Mario Wonder's title renders the same as before (differences only in animation). - README gallery: Engage, 13 Sentinels and Link's Awakening recaptured with this build.
…'s outdoor sunlight fixed; IPA version is the game's display version - dmsh_build.py vs_init: every float4 vertex output is set to (0, 0, 0, 1) before the translated body, as unwritten components read on the hardware. The translator's MSL started from all zeros; Link's Awakening's surface shaders divide a world position by its w, which the vertex shader never writes, so every sun-shadow compare value was infinite and the whole outdoor scene was lit as if in shadow (dim, no shadows from fences, house or trees). All seven chain versions change. - Mac libraries and c1_full.tsv rebuilt for Link's Awakening, Engage, 13 Sentinels and Mario Wonder (Breath of the Wild, Super Mario 3D World and Metroid Dread follow). - DM_NVN_TEXRAW dumps the depth plane of a Depth32Float_Stencil8 texture (shadow maps). - The IPA's version (CFBundleShortVersionString / CFBundleVersion) is the packed game's display version: the update's when an update is packed, else the base game's (nacp.py --version, DM_APP_VERSION in build_ipa.sh, project.yml; the NSP script prints it). - README: Link's Awakening screenshot outdoors in Mabe Village.
… (boots to its frame loop on the Mac) - README / AGENTS.md: The Legend of Zelda: Link's Awakening moves into the playable table (tested on an iPhone with the physics, blur and sunlight fixes); Super Mario Odyssey listed as being ported; the app takes the game's version. - Super Mario Odyssey (update 1.4.1, SDK 7.3.2): profile dm/games/0100000000010000 from the NSP script's provisional one (3D touch layout). Host stand-ins for the services it calls at startup that no other game did: account OpenPreselectedUser / GetLastOpenedUser, bcat (Initialize, a failing MountDeliveryCacheStorage: the game's own "nothing delivered" path), oe HOME-button blocking / screenshot orientation / inactivity query, pctl stereo-vision restriction, vi SetLayerScalingMode, time ToPosixTimeFromUtc, hid debug pad and IsSevenSixAxisSensorAtRest, and the SDK 7 names of the audio device notification and channel count. It now reaches its frame loop (past frame 8,700 in 150 s); its Mac shader libraries are still building, so nothing is drawn yet. - c1_full.tsv for Breath of the Wild, Super Mario 3D World and Metroid Dread rebuilt for the vertex-output chain (all seven playable games now match their chain headers).
…seedds#4) The game encodes one 32x32 BC4 texture on the GPU, drawing its blocks through an RGBA16UI view. On a GPU with BC that attachment was already left out (Metal cannot attach a compressed texture or make an uncompressed view of one). Without BC the texture is stored decompressed (R8), the check on the Metal format missed it, and the host asked Metal for an R8Unorm -> RGBA16Uint view, which aborts the process (iPhone 14 Pro / A16; DM_TEST_NO_BC=1 reproduces it on the Mac). attach, the pipeline prediction and the sampling views now decide by the NVN format: a BC texture is never a render target and its raw blocks are not sampled through an uncompressed view, on any GPU (red line once each). Checked on the Mac with DM_TEST_NO_BC=1: Breath of the Wild runs with the same two red lines as with BC; smoke runs of the other games unchanged. Comments and dm/gfx/tex/README.md no longer point at d2r-mobile's offline ASTC pack (dm/tools/astc_pack.py), which is not in this repository; the memory cost of no BC (about 3.9 GB instead of 2.8 GB in Breath of the Wild) is noted in 04-graphics.md.
…ll shaders compiled with preserved invariance - Movies: H.264 decoded with VideoToolbox (dm/host/hle_movie_avc.c). This SDK's MP4 demuxer passes the parameter sets as the "avcc" record; pictures leave in presentation order through a 4-deep queue (41 of Odyssey's 44 movies have B-frames), and an end of stream drains the queue. The hint videos in Odyssey's tutorial boxes now play (they were black). VP9 unchanged (Engage: 2,816 packets in, 2,816 frames out). - Controller input: GetNpadStates fills every requested history entry with the current state under consecutive sampling numbers. Odyssey reads all 16 entries whatever count comes back and polls every slot each frame; with only the newest written, neither stick did anything in play while buttons and menus worked (its first hint, "Look Around", waited forever). DM_KEYS takes RLeft / RUp / RRight / RDown. - Odyssey's HUD counters were solid white cards: the profile lists its 26 layout shaders (main's BNSH at 0x132c000) under alpha_from_red, as for Breath of the Wild. - -fpreserve-invariance on every Metal compile (dmsh_build.py MAC_METAL, ios_metal.py): Odyssey draws a depth pre-pass with alRenderDepthOnly, then the G-buffer with other vertex shaders and depth test less-or-equal; Metal gave the identical position math slightly different depths and those pixels kept stale content (Cap Kingdom's ground in 32x32 blocks on every fourth frame). Checked by recompiling the frame's 78 vertex shaders with the flag: four consecutive frames identical, no blocks. All eight chain versions change; Mac libraries and c1_full.tsv are being rebuilt and follow. - DM_NVN_TEXSNAP works again (its entries lacked the layer field the dump loop reads) and names its files <path>_s<pass index>_<serial>_<level>.png. - Smoke runs of the seven playable games on the Mac after these changes: only their known red lines.
…ster Cuphead (Unity 2017.4) main+0x1bb872c loads the table entry into x17 and only the add writes x18: cmp w17,seedds#7; ldrsw x17,[x15,x17,lsl seedds#2]; add x18,x17,x15; br x18. jump_offsets now takes the loaded register from the add; the walk from the index back to the bounds check is unchanged. Ported from GitHub pull request seedds#1 onto the current jump_offsets (the PR's other two shapes already pass since Link's Awakening's subsdk work). All 35 rewritable modules of the 9 extracted titles give byte-identical output. Co-authored-by: Jeffrey Wang <11900676+armyja@users.noreply.github.com>
…ity 2017.4)
- serialized format 17 is accepted; type tree nodes are 24 bytes before
format 19 (the trailing refTypeHash u64 arrived with Unity 2019.1)
- before 2019.3 a platform's subprograms sit in one segment with 8-byte
{offset, length} entries (the old scalar branch read 12-byte entries)
- before 2019.3 a subprogram's program code is a 0x10 header {?, ?, control
length, code length} + control section + code area holding one stage; the
stage comes from the Shader's m_ParsedForm, and a subprogram missing there
is a red line
From GitHub pull request seedds#2, with the node size cut at format 19 instead of
21 (formats 19 and 20 keep reading as before). Fire Emblem Engage (format 22)
splits to an identical package and tables.
Co-authored-by: Jeffrey Wang <11900676+armyja@users.noreply.github.com>
- Add universal dmsh_xlate launcher that detects architecture (runs native on arm64, dotnet exec on x86_64) - Make DOTNET_ROOT and toolchain detection dynamic in build_ipa_from_nsp.py - Add comprehensive x86_64 macOS documentation in docs/building_on_x86_64_macos.md
drewpall
force-pushed
the
feat/x86_64-macos-support
branch
from
October 18, 2026 02:12
cb1400f to
b5a2a8c
Compare
seedds
added a commit
that referenced
this pull request
Oct 23, 2026
…uctions back (ASTRAL CHAIN 1.0.1 main+0x6db4a0, SDK 6: cmp w18,#5; b.hi; ldrsw x18,[x24,x18,lsl #2]; add x18,x18,x24; br x18). The function's first block loads six table bases with adrp + add into registers its loop keeps (x24 441 instructions before this load) and a later block one more (x3, 549 before the load at +0x6db70c); jump_offsets followed the base's writer chain 256 instructions back, and the rewrite stopped with jump table 6db4a0. Where nothing writes the base in those 256, its last attempt (far_base) follows the chain to the function's start (table_base far), through no call when the base is caller-saved, and accepts the table only when every target is an instruction of the function. The function-wide search jump_adr_offsets uses for a hoisted base (the one adrp + add pair that fits) finds two for x3 there, the other the local table of a br x17 further on. Three of that main's five br x18 sites need it, their targets checked by hand; main and sdk rewrite. It runs only where every other form has failed: the Tears of the Kingdom, Age of Calamity, Cuphead, DARK SOULS: REMASTERED, Luigi's Mansion 3 and Metroid Dread mains come out byte-identical (patched image and site list)
Know-It-All-Brother
pushed a commit
to Know-It-All-Brother/nxnative
that referenced
this pull request
Nov 9, 2026
…uctions back (ASTRAL CHAIN 1.0.1 main+0x6db4a0, SDK 6: cmp w18,seedds#5; b.hi; ldrsw x18,[x24,x18,lsl seedds#2]; add x18,x18,x24; br x18). The function's first block loads six table bases with adrp + add into registers its loop keeps (x24 441 instructions before this load) and a later block one more (x3, 549 before the load at +0x6db70c); jump_offsets followed the base's writer chain 256 instructions back, and the rewrite stopped with jump table 6db4a0. Where nothing writes the base in those 256, its last attempt (far_base) follows the chain to the function's start (table_base far), through no call when the base is caller-saved, and accepts the table only when every target is an instruction of the function. The function-wide search jump_adr_offsets uses for a hoisted base (the one adrp + add pair that fits) finds two for x3 there, the other the local table of a br x17 further on. Three of that main's five br x18 sites need it, their targets checked by hand; main and sdk rewrite. It runs only where every other form has failed: the Tears of the Kingdom, Age of Calamity, Cuphead, DARK SOULS: REMASTERED, Luigi's Mansion 3 and Metroid Dread mains come out byte-identical (patched image and site list)
iDams
pushed a commit
to iDams/nxnative
that referenced
this pull request
Nov 13, 2026
…d its amiibo-nolimit folder served first The amiibo work of Tizzle2x and Atomsk (cheemu21#4 and seedds#5) came from the X line, where build_ipa.sh packed a romfs_overlay folder beside the RomFS and hle_fs.c's rom_overlay_set chose its per-mode resolution and amiibo folders. The FF line has neither (its render scale is a patch), so: - build_ipa.sh: a profile with amiibo.tsv gets a romfs_overlay folder of its own in the app: the list (the in-game Amiibo menu, GameMenu.swift) and, with amiibo_overlay on, the game's Game/AmiiboSetting with every amiibo's daily limit off and its resource size table entry, made from the player's own RomFS image by scripts/oot_amiibo_overlay.py (nothing of the game in the repository; the list alone when the script fails). The X line's resolution folders beside the RomFS are not packed. - hle_fs.c rom_overlay_expand: DM_ROMFS_OVERLAY's folders, each after its amiibo-nolimit/ subfolder where it has one; no per-mode folders on this line. Checked: t_amiibo ok, t_nfc 95 checks 0 failed, t_fs 146 checks 0 failed, the Mac host builds. Not yet on an iPhone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 20a9c0d)
1 task done
seedds
added a commit
that referenced
this pull request
Nov 27, 2026
Sonic Racing: CrossWorlds 1.41 main+0x726afc (issue #3383) spills a 32-bit subs w4, w8, #1 result to [sp, #0x80] across two calls and reloads it with ldr x4, [sp, #0x80] before cmp w4, #5; b.hi; ldrsw x0, [x17, x4, lsl #2]. Without a stack-slot model, the 64-bit reload produced an unconstrained 64-bit root whose unknown upper half a 32-bit compare cannot bound, stopping the rewrite at 'the index reaches 0xffffffffffffffff'. Track provably local fixed stack slots inside the function's allocated frame (frame, slots, escaped) and stack-derived register offsets ('sp', offset) uniformly covering x29 frame pointers in dm/tools/jump_solver.py: - Only track fixed-offset GPR str/stur/stlr/stp/stnp slots strictly inside [0, frame) allocated by sub sp / pre-decrement, and reload only on matching width (or a 32-bit reload of the low half of an 8-byte slot). - Invalidate overlapping byte ranges on any fixed-offset stack write, clear slots on indexed or unknown-size stack writes (including LSE atomics), and latch escaped=True whenever a stack pointer escapes to a call (x0-x18/x30), memory, syscall, unhandled op, or mismatched join. - Reject trusting targets solely because they lie in the function when the upper half remains unproved. Checked: 37/37 test_jump_solver.py, 7/7 test_docs.py, 71/71 related rewriter tests, ruff/pyright (0 errors/warnings on modified files), byte-identical main rewrites on Cuphead (-0.6%) and Manual Samuel (+0.9%), and quick regress.py checks on Well Dweller and DOOM 3 (PASS). Awaits reporter retest on Sonic Racing: CrossWorlds main. Co-authored-by: dationguyen <26321444+dationguyen@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds out-of-the-box build support for x86_64 macOS (Intel Macs and AMD Hackintosh systems) while preserving 100% native compatibility on Apple Silicon (arm64).
Key Changes
dmsh_xlateLauncher:uname -m).arm64, executes the native Mach-O binary (dmsh_xlate.arm64).x86_64, transparently executesdotnet exec dmsh_xlate.dllvia .NET SDK 10, resolving the previousExec format error.scripts/build_ipa_from_nsp.py:DOTNET_ROOTand system path fallback across both/usr/local(Intel) and/opt/homebrew(Apple Silicon).USERenv to avoid xcodegen failures in background/isolated environments.docs/building_on_x86_64_macos.mdwith complete prerequisites and hardware verification.Hardware Verification
.ipa, runs smoothly at 60 FPS with physical controllers.