Skip to content

Breath of the Wild above 60 fps and at native 1440p / 4K, faster NVN → Metal translation, iOS launcher - #62

Closed
v0lumehi wants to merge 12 commits into
seedds:mainfrom
v0lumehi:launcher
Closed

v0lumehi wants to merge 12 commits into
seedds:mainfrom
v0lumehi:launcher

Conversation

@v0lumehi

@v0lumehi v0lumehi commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Tested on the Mac (M2 Max, macOS 27) and briefly on an iPhone 17 Pro Max (iOS 27).

This is an intermediate result. The goal is Breath of the Wild at a native 120 fps and native 1440p / 4K on the Mac and iPhone, without frame interpolation. The measurements below show there is a lot left, so follow-ups are planned (see the end).

What's in it

iOS launcher

  • A settings screen before the game starts (Launcher.swift, SwiftUI): frame rate, render scale, console mode, game language, frame-rate counter, Metal HUD. Only what the game profile supports is shown. Documents/env.txt takes precedence, and DM_LAUNCHER=0 skips the screen.

Faster NVN → Metal translation (all games)

  • Metal encoding on its own thread: on by default on iOS, opt-in on macOS with DM_NVN_ENC_THREAD=1. The submit thread records encoder calls and a worker replays them (nvn_rec.h). Also fewer lookups per draw (a page-table pc cache).
  • Uniform shadows of 512 bytes or more are copied on a worker thread (DM_NVN_UB_COPY_THREAD=0 turns it off).
  • Deferred inline uniform updates are kept across render pass ends. They land before the next pass that can read them, not at every pass end (DM_NVN_UB_LAZY, default 160). BotW: GPU 9.3 → 8.0 ms in the test scene.
  • BotW translation per frame went from about 6.4 ms to about 4.4–5.3 ms in the same scene.

Diagnostics

  • DM_NVN_GPUPROF=f or f1-f2: the GPU start and duration of every encoder, from Metal 4 counter heaps.

Mac

  • The process declares latency-critical activity.
  • DM_METAL_HUD=1 shows Apple's performance HUD (set before main, so it applies to the first device).
  • GPU filler (DM_GPU_KEEPALIVE, default 2 on macOS, off on iOS). macOS lowers the GPU clock until the GPU is about 95% busy, whatever the deadline. BotW waits for each frame's GPU work, so the clock fell from 1398 to 444 MHz and the game missed 60 fps. Filling only short gaps was not enough.
  • Above 60 fps, a screen whose rate isn't a multiple of the target switches to a mode at the target while the game runs, and back on quit.
  • The drawable follows the window in pixels. Before, it stayed at 1280x720 even in fullscreen.

Breath of the Wild (1.9.0)

  • Above 60 fps (DM_FPS_TARGET=61–240): a variable frame step. The VFR gets the time each frame was shown, so the game keeps real-time speed at any frame rate.
  • Native resolution above 1080p (DM_RENDER_SCALE up to 3.0 with the new profile key render_pool): 1.2 = 1080p, 1.6 = 1440p, 2.4 = 4K.
    • The game's render buffer pool, nninitStartup's heap, the RootHeap, the application pool and the alias region grow with the scale.
    • Above 1.2 the game's output also takes the views' size: the size global, the docked output width, the render size and the window crop. Frames are composed and shown at 1440p / 4K, not scaled down to 1920x1080.
  • Mac results in the Great Plateau test scene: about 84 fps at 1440p and about 74 fps at 4K.

Measured (Breath of the Wild, Mac M2 Max, Great Plateau)

Each row is an 80 s headless run of the same save and scripted input, with the variable frame step (DM_FPS_TARGET=120, DM_PRESENT_HZ=120, DM_PRESENT_LINK=2). fps is the mean of the last four 300-frame windows in the log; "submit" is the translation thread's wall-clock time per frame.

DM_RENDER_SCALE 3D views Output Frame rate Submit per frame Frame rate with DM_NVN_ENC_THREAD=1 Submit with it
1.0 (the game's own) 1600×900 1920×1080 83 fps 6.8 ms 85 fps 5.5 ms
1.2 1920×1080 1920×1080 86 fps 6.9 ms 90 fps 5.6 ms
1.6 2560×1440 2560×1440 84 fps 7.0 ms 85 fps 5.6 ms
2.4 3840×2160 3840×2160 74 fps 7.5 ms 75 fps 5.8 ms

Before this PR, the game ran at most 60 fps (whole vsyncs) and output at most 1920×1080, with the 3D views at most 1600×900. Up to 1440p the frame rate hardly depends on the resolution: the frame is bound by fixed costs (the serialized translation and the GPU tail, per-encoder gaps), not by pixels. That is why the follow-ups target those costs. A shorter submit thread alone raises it only slightly (83 → 85 fps at 1.0); the rest of the frame (the game's own CPU work and the GPU) now dominates, which a per-frame breakdown is to show next.

Docs: docs/development.md (BotW notes, Power) and docs/agents/04-graphics.md (switches).

Not done / known issues

  • iPhone (17 Pro Max, BotW): it starts at 60 fps but drops to 30 after a short time in the open world, even with 60 fps chosen, docked and handheld alike. This was the same before this PR. The log shows why:
    • The GPU needs about 14 ms per frame there, and BotW waits for each frame's GPU work, so a frame takes about 22 ms.
    • Once the game holds 30, iOS lowers both clocks: the GPU takes 1.5–1.9× as long and the CPU drops to about 1.9 GHz. Every return to 60 then fails.
    • The encoding thread halves the submit thread (about 8 ms → 3.3–4.5 ms a frame), so the CPU side is no longer the limit.
    • A GPU filler like the Mac's kept the GPU fast, but the phone got warm and the CPU clock fell instead.
    • No visual glitches were seen.
  • On iOS the launcher's render-scale slider still stops at 1.0, so the higher scales and their memory growth are untested there.
  • With the variable frame step, the menus (title screen, inventory) run at double speed.
  • Below the screen's refresh rate (for example 84 fps on 120 Hz), frames alternate between one and two refreshes, so pacing is uneven.

Overlap with #33

#33 has the same fix for the drawable keeping its first size (1280x720 even in fullscreen), done with window notifications where this PR uses the view's setFrameSize: / viewDidChangeBackingProperties. Whichever lands first, the other should drop its version.

Where the frame time goes (1440p, DM_NVN_GPUPROF)

Of a 12 ms frame, the GPU works about 5.5 ms. It waits about 2.5 ms between encoders (fixed cost per encoder, about 190 a frame) and about 2 ms for the next command buffer from the translation. The translation takes about 7 ms. BotW waits for each frame's GPU work before starting the next, so CPU and GPU take turns. 84 fps is not the hardware limit.

Planned follow-ups

  • Profile one frame in detail (game CPU, translation, GPU tail) and attack the biggest part. Candidates: several encode threads, and fewer encoders (barriers inside an encoder instead of new ones).
  • Fix the menu speed under the variable frame step.
  • A macOS launcher like the iOS one (resolution, frame rate, HUD), probably its own PR, together with a way to package a Mac app.
  • Higher resolutions from the iOS launcher, and full-width output on wide iPhone screens (camera aspect ratio and HUD layout at the edges).

…HUD for Apple's performance HUD

The launcher (Launcher.swift, SwiftUI) sets the switches env.txt sets: frame rate (games with fps_target),
render scale (new profile key render_scale: Breath of the Wild, Tears of the Kingdom), docked / handheld,
game language (the control data's languages, DMLanguages in Info.plist), the frame-rate counter and the
performance HUD. env.txt still wins, DM_LAUNCHER=0 skips the screen. The host's early loading starts once
the launcher has set the switches it reads. DM_METAL_HUD=1 turns on CAMetalLayer's developer HUD on the
Mac and iOS.
…kups per draw

The replay's Metal calls (encoders, draws, state, argument table writes, commits) can go to a
worker thread through stand-ins (nvn_rec.h), so the submit thread keeps translating: Breath of
the Wild's submit time 6.4 → 4.9 ms a frame on an M2 Max. The address → pool cache is now two
levels (a table by page, then the last 8 pools), and the pass dump check answers first when off.

GPU keep-alive on macOS: macOS lowers the GPU clock until the GPU is busy about 95% of the time,
whatever the frames' deadlines, and a game that waits for its own frame on the GPU then drops
frames (1398 → 444 MHz, GPU 9 → 14 ms a frame). One small dispatch keeps the GPU busy while the
game submits frames (DM_GPU_KEEPALIVE=0 turns it off).
…ith DM_METAL_HUD

macOS is told the host's work is latency-critical (NSActivityLatencyCritical). DM_METAL_HUD
also sets MTL_HUD_ENABLED before the first device is made: the layer's developer HUD properties
alone did not show it.
…=61 to 240)

VFR::updateInterval publishes the host's step instead of interval / 2 when one is set (state
page +0x28; the game's own override in cutscenes keeps its steps). The host steps each frame by
the time the previous one took, in 1/30 s units clamped to [30 / cap, 1.5], and shows frames as
soon as they are ready. On an M2 Max the game runs at 72-85 fps in the open world at real-time
speed.
ubp_get's copies (Breath of the Wild: about 440 shadows, 14 MB a frame) are queued in order and
made by one worker; every commit of the main command buffer first waits for the copies queued
before it, and a CPU read of a shadow waits for its own. Submit time 4.86 → 4.44 ms a frame on
an M2 Max. DM_NVN_UB_COPY_THREAD=0 copies on the submit thread as before.
…per-encoder GPU times

Deferred inline uniform updates are no longer landed at every pass end but when something needs
the memory itself: the next copy or dispatch (in that compute encoder), a draw reading them other
than through a covered uniform binding, the end of the submission, or more than DM_NVN_UB_LAZY
(default 160) of them. Breath of the Wild had about 45 small copy encoders between its render
passes a frame, each with idle GPU around it: GPU 9.3 → 8.0 ms, frame 11.9 → 10.7 ms at the
120 fps cap on an M2 Max. A page filter keeps the lookups cheap, and a deferred update marks
only the stages whose uniform bindings it overlaps for encoding again.

DM_NVN_GPUPROF=frame writes relaxed timestamps at every encoder's start and end in that frame
and logs each encoder's GPU time, so the time between encoders shows too.
…rame step waits one link tick

With DM_FPS_TARGET above 60 on a screen whose refresh rate is not a multiple of it, the screen
switches to a mode of that rate at the same size while the game runs (for this app only, macOS
switches it back when the host quits): a 144 Hz screen fired a 120 Hz display link on every other
refresh, 72 Hz. With the variable frame step a frame waits for one tick of the link instead of
two at 120 Hz (a whole 60 Hz vsync), which held Breath of the Wild at 60 fps.
…1440p, 4K

DM_RENDER_SCALE may go up to 3.0 for a profile with render_pool. Above 1.0 gsys's render
buffer pool (115 MB, main+0x106d328) grows by the factor's square rounded up, and so does what
holds it: nninitStartup's fixed 3.05 GB heap (main+0x71c) and the RootHeap inside it
(main+0xc617c0), whose fixed size left PlacementMgr's 328 MB heap without room once
gsys::SystemTask grew. The host adds the same to the application pool, the alias region and the
reserved address space (hle_svc.c mem_extra). On an M2 Max at the 120 fps cap: 1.6 = 2560x1440
at about 84 fps, 2.4 = 3840x2160 at about 74 fps in the Great Plateau test scene.
… composed and shown at 1440p / 4K, not scaled down to 1920x1080

The game composed every frame into 1920x1080 display buffers whatever its 3D views rendered at. Its size global (main+0x1e43dc0), the docked output width, render size and window crop now take the host's size (state page +0x40 / +0x48, written by the loader where base 1600 x the render scale passes 1920).
…een's resolution, not 1280x720), and DM_METAL_HUD sets MTL_HUD_ENABLED before main

The layer assigned to the layer-backed view kept its drawable at the first window's 1280x720 in fullscreen too, so the picture was scaled down to it and back up. Set in front_run, MTL_HUD_ENABLED came after the first device and the HUD did not show.
…clock filler, and the new diagnostic switches
…=0 turns it off): Breath of the Wild's submit thread on an iPhone 17 Pro Max went from about 8 ms a frame to 3.3–4.5 ms
@v0lumehi
v0lumehi marked this pull request as ready for review October 22, 2026 23:20
@v0lumehi v0lumehi changed the title Breath of the Wild above 60 fps and at native 1440p / 4K, faster NVN → Metal translation, iOS launcher (draft) Breath of the Wild above 60 fps and at native 1440p / 4K, faster NVN → Metal translation, iOS launcher Oct 22, 2026
seedds added a commit that referenced this pull request Oct 23, 2026
…its own thread (on by default on iOS), uniform shadows copied by a worker, uniform updates kept across render passes

Taken from v0lumehi's PR #62, the parts that hold for every game (none is gated by a title, build or profile; all but the Mac front end reach only the NVN games):
- nvn_rec.h: the replay's Metal calls (encoders, draws, state, argument table writes, commits, event signals) go to a worker thread as records, in the same order. The submit thread waits for it at the end of each submission and before anything that waits for the GPU or uses another queue. On by default on iOS, DM_NVN_ENC_THREAD=1 on the Mac.
- Uniform shadows of 512 bytes or more (ubp_get) are copied by a worker; a commit waits for the copies queued before it, a CPU read of a shadow for its own (DM_NVN_UB_COPY_THREAD=0 copies on the submit thread as before).
- Deferred inline uniform updates are kept across render pass ends (DM_NVN_UB_LAZY, at most 160) and land before the next copy, a draw that reads their memory other than through uniform bindings the shadows cover, or the end of the submission, instead of in a copy encoder after every pass.
- A two-level address → pool cache (by 4 KB page, then the last 8 pools found), and the pass dump check answered first when it is off.
- DM_NVN_GPUPROF=f or f1-f2: every encoder's GPU start and duration, from Metal 4 counter heap timestamps.
- Mac: the drawable follows the window in pixels (in fullscreen it had stayed at 1280x720), the process declares latency-critical activity, and DM_METAL_HUD=1 shows Apple's performance HUD (on the iPhone too, from Documents/env.txt).

On top of the PR:
- A dispatch lands the kept updates first when it reads or writes their memory through a storage buffer or its indirect arguments, or reads a part of a uniform binding the shadows cannot give (ubd_conflict_cs, with the per-stage check it shares with draws, ubd_conflict_sh). Dispatches open the copy encoder through blit_open, which never landed them, so they ran before the updates. Transform feedback draws land them first, as every pass end did before.
- A deferred update that a newer one covers whole is dropped from the landing list. Breath of the Wild rewrites the same 64 bytes before every draw group, so the list held up to 160 repeats that every binding lookup scanned: the port cost 16,800 instructions a draw against main's 13,200, and costs 13,500 with the drop.
- The encoding thread records encoder labels (DM_NVN_ENC_LABEL) and counter heap timestamps (DM_NVN_GPUPROF): without them either diagnostic stopped the host on iOS.
- DM_NVN_UBP_CHECK waits for the copy worker before it reads a shadow. It compared unfilled shadows (293,447 "different"); now 232,000 equal and 0 different with the encoding thread on, 234,000 and 0 with it off.

Left out: Breath of the Wild above 60 fps and above 1080p (rewriter cuts for its build and a profile key), the Mac GPU filler and screen mode switch, and the iOS launcher.

Breath of the Wild on the Mac (the Great Plateau save, 60 fps cap, beside main under the same load): submit thread 4.30 against 4.48 ms a frame, GPU p95 6.2 against 7.0-7.3 ms, 1.000 of real time, no red lines; with the encoding thread the submit thread takes 3.16 ms (9,700 instructions a draw). t_nvn 100/100 with the encoding thread off and on; the hosts for TOTK and Hades build.

Co-authored-by: v0lumehi <[email protected]>
@seedds

seedds commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Thanks — the general parts are in main as 8a4b1dc (with you as co-author): the encoding thread (on by default on iOS), the uniform copy worker, inline updates kept across passes, the two-level pool cache, DM_NVN_GPUPROF, and on the Mac the drawable fix, the latency-critical activity and DM_METAL_HUD. Changes on top of the PR:

  • Dispatches land the kept updates. dispatch_enc opens the copy encoder through blit_open, which never landed them, so a dispatch could run before updates that came earlier in command order. A dispatch now lands them first when it reads or writes their memory through a storage buffer or its indirect arguments, or reads a part of a uniform binding the shadows can't give (ubd_conflict_cs, which shares the per-stage check with draws). Transform feedback draws land them first too: tf_draw runs before draw's conflict check and relied on every pass end landing them.
  • An update a newer one covers whole is dropped from the list. BotW rewrites the same 64 bytes before every draw group, so with DM_NVN_UB_LAZY the list held up to 160 repeats, which ubd_covers / ubd_shadow / ubd_read scan for most bindings of most draws: the submit thread took 16,800 instructions a draw against main's 13,200. Such an update never needs to land, and without them it is 13,500.
  • The shadow check works with the copy worker. DM_NVN_UBP_CHECK copied a shadow before the worker had filled it and reported 293,447 differences; it now waits for the worker (232,000 equal, 0 different).
  • The encoding thread records encoder labels and counter-heap timestamps, so DM_NVN_ENC_LABEL and DM_NVN_GPUPROF no longer stop the host on iOS through rec_missing.

BotW on an M4 Pro at the 60 fps cap, beside main under the same load: submit thread 4.30 against 4.48 ms a frame, GPU p95 6.2 against 7.0–7.3 ms, 1.000 of real time; with the encoding thread the submit thread takes 3.16 ms.

Not taken:

  • BotW above 60 fps and above 1080p. The host accepted DM_FPS_TARGET 61–240 for every frame-step game and then wrote its float step to state page +0x28, which is Age of Calamity's vsyncs-per-update field; the heap sizes and the 1600 base width were BotW constants in the general loader; and the menus run at double speed, as you noted.
  • The Mac GPU filler. It keeps a dispatch running whenever any game runs on the Mac, and shares the GPU with the game's own work, whose times the frame step reads.
  • The screen-mode switch, which only served the variable step.

The launcher comes next, built from a settings table as you proposed in #64; I've answered there.

seedds added a commit that referenced this pull request Oct 23, 2026
…e table of player-facing settings (dm/games/settings.tsv; GitHub PR #62, issue #64)

The launcher from v0lumehi's PR #62 (Launcher.swift, SwiftUI: the game's icon, name and version, Play, and the settings), built as their issue #64 proposes: dm/games/settings.tsv declares each player-facing setting once (the environment variable it sets, its kind: choice, range or toggle, its default and the condition under which a game offers it). build_ipa.sh runs dm/games/settings.py, which keeps the rows that hold for the game and fills in its defaults: the host's own from game_profile.h (DM_GAME_FPS_TARGET, DM_GAME_OPMODE), the build's (DM_LANG, DM_SHOW_FPS), the game's languages from its control data, and the render scale only for a build with the rewriter's render-scale stub, which patch_nso.py now records in main's table (RENDER_SCALE: Breath of the Wild 1.9.0, Tears of the Kingdom 1.4.3). The result goes into the app as dm/launcher.json, and the launcher draws one row per setting from it, so a new setting is one table row. Diagnostic switches stay environment-only. Breath of the Wild offers frame rate, render scale, console mode, 15 languages, the frame-rate counter and Apple's performance HUD.

Differences from the PR's launcher:
- The host's loading still starts at app launch. Only the loader read the frame rate and the render scale that early; it now just maps the frame step state page, and dm_fps_state_apply (main.c, when the game starts) writes both, so a boot is no slower with the launcher (the PR started all loading when Play was tapped). The game view, the pad and the frame-rate counter are made after Play, since they read the launcher's switches.
- The language choice applies: main.m sets the packed language as a default before the launcher runs, which the PR then took for a setting from env.txt and kept. main.m now lists the variables an env file set (DM_ENV_FILE_KEYS); only those are kept, and the launcher shows them greyed out.
- No new profile key for render scale (the rewriter's table tells), and the scale stops at 100 % (the above-1080p part is not in main). No Mac launcher.

The choices are kept in UserDefaults; DM_LAUNCHER=0 in Documents/env.txt skips the screen, as does an app without launcher.json. README: the settings screen in the Play section; dm/games/README.md and docs/development.md describe the table.

Checked: Launcher.swift type-checks against the iOS SDK and the Breath of the Wild IPA builds with it (launcher.json and RENDER_SCALE inside); the Mac host applies DM_FPS_TARGET=30 from the first present and DM_RENDER_SCALE=0.75 when the game starts. Not yet run on an iPhone.

Co-authored-by: v0lumehi <[email protected]>
@seedds

seedds commented Oct 23, 2026

Copy link
Copy Markdown
Owner

The launcher is in main too, as 2f69480 (with you as co-author): built from the settings table as proposed in #64, with the host's loading still starting at app launch and the language choice applying (main.m's packed-language default no longer counts as an env.txt setting). With 8a4b1dc that covers what this PR's general parts and launcher do; the parts left out are listed in my comment above. Closing — thanks!

v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 24, 2026
…ants in the host

Builds tell the loader which further stubs they have through main's rewriter table (ctx.keys of the stubs in the profile's patches.py):
VAR_STEP, RENDER_POOL and the base sizes VIEW_W / VIEW_H / OUTPUT_W / OUTPUT_H. The loader writes the state
page fields beyond +0x40 only for such a build, so AoC's +0x28 and TOTK's +0x8 are never touched and no heap
size or base width of one game is in the host. The page grows to 0x60 bytes. Breath of the Wild's stubs are in its patches.py; its main rewrites byte-identically to the previous patch_nso.py version of this change.

- Variable frame step (DM_FPS_TARGET 61 to 240, refused on a build without VAR_STEP): each frame the host
  publishes the time the previous one took as the VFR's frame ratio (state +0x50, main+0x151d484); the VFR
  override and prerendered movies keep the whole-vsync step. The display link runs at the cap (mode 4, with
  virtual ticks on a screen whose rate is not a multiple of it; no screen mode switch). Steps have no floor at
  the cap: at 120 on a 144 Hz screen a floor of 1/120 s ran the game at 1.12 of real time.
- Interval-stepped logic: the layout system's animation step (menus, HUD; main+0x1280ec8) and a fade
  (main+0x125f114) take the VFR's frame ratio in place of max(interval, 1); menus and the HUD ran at twice the
  speed at 120. Held buttons count the ratio (main+0xeb0f88): the inventory cursor repeated at twice the speed
  at 60 already. The physics step gets a ratio of at least 0.5 (main+0x128106c), three substeps, where two at
  120 blew ragdolls apart. Sites from MacNativeGames PR seedds#103, checked by disassembly.
- Above 1080p (render scale up to 3.0, Mac only): the render buffer pool grows by the factor's square
  (main+0x106d328), the application pool, alias region and the game's fixed heaps by what it adds plus 64 MB
  (state +0x58: the stubs add it to the game's own sizes), and above 1.2 the output takes the views' size.
- The iOS launcher keeps 30 / 60: above 60 is not yet run on an iPhone (DM_FPS_TARGET in env.txt reaches it).

Mac (M2 Max, 144 Hz screen): 119.5 fps at 2560x1440 at the title and in the menus at 1.000 of real time, menus and
the inventory at normal speed; in the open world about 84 fps at 1440p and 74 at 4K with PR seedds#62's implementation of
the same step (two physics substeps a frame at 120, three here; not measured again); at the profile's 60 fps 1.000 of real time. Red lines: BufferInitialize past the end of a pool when the
inventory opens, on main too; MemoryPoolInitialize without storage only at render scale 1.6, as with the first
implementation (PR seedds#62). TOTK, AoC and
Paper Mario: their stubs are unchanged and their tables get no new rows (not run here).
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 24, 2026
…he game's submissions

macOS lowers the GPU clock while the GPU idles part of each frame, even when the frames then miss their
deadline, and offers no interface to ask for a clock. Breath of the Wild waits for each frame's GPU work, so
its GPU idles while the host translates the next frame (GitHub issue seedds#71). The filler of PR seedds#62 ran for every
game all the time and shared the GPU with the game's work. Now it starts only when a tenth of 120 presents
come late (mtl_gpu_fill_frame), keeps one small dispatch on a queue of its own only while none of the game's
submissions is on the GPU (from the completion of the last in flight to the next commit), so it never adds
to the GPU time the frame step reads, and stops after a hold without late frames that doubles at each start
(60 s up to 16 min). DM_GPU_FILL=0 never, =1 from the start (also on iOS, where it is off by default).

Breath of the Wild at 60 fps (M2 Max, macmon each second for 180 s): without it the clock fell to 444 MHz
after 70 s and stayed (304-346 late frames every 30 s); with it 1398 MHz throughout (11-17).
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 24, 2026
…ants in the host

Builds tell the loader which further stubs they have through main's rewriter table (ctx.keys of the stubs in the profile's patches.py):
VAR_STEP, RENDER_POOL and the base sizes VIEW_W / VIEW_H / OUTPUT_W / OUTPUT_H. The loader writes the state
page fields beyond +0x40 only for such a build, so AoC's +0x28 and TOTK's +0x8 are never touched and no heap
size or base width of one game is in the host. The page grows to 0x60 bytes. Breath of the Wild's stubs are in its patches.py; its main rewrites byte-identically to the previous patch_nso.py version of this change.

- Variable frame step (DM_FPS_TARGET 61 to 240, refused on a build without VAR_STEP): each frame the host
  publishes the time the previous one took as the VFR's frame ratio (state +0x50, main+0x151d484); the VFR
  override and prerendered movies keep the whole-vsync step. The display link runs at the cap (mode 4, with
  virtual ticks on a screen whose rate is not a multiple of it; no screen mode switch). Steps have no floor at
  the cap: at 120 on a 144 Hz screen a floor of 1/120 s ran the game at 1.12 of real time.
- Interval-stepped logic: the layout system's animation step (menus, HUD; main+0x1280ec8) and a fade
  (main+0x125f114) take the VFR's frame ratio in place of max(interval, 1); menus and the HUD ran at twice the
  speed at 120. Held buttons count the ratio (main+0xeb0f88): the inventory cursor repeated at twice the speed
  at 60 already. The physics step gets a ratio of at least 0.5 (main+0x128106c), three substeps, where two at
  120 blew ragdolls apart. Sites from MacNativeGames PR seedds#103, checked by disassembly.
- Above 1080p (render scale up to 3.0, Mac only): the render buffer pool grows by the factor's square
  (main+0x106d328), the application pool, alias region and the game's fixed heaps by what it adds plus 64 MB
  (state +0x58: the stubs add it to the game's own sizes), and above 1.2 the output takes the views' size.
- The iOS launcher keeps 30 / 60: above 60 is not yet run on an iPhone (DM_FPS_TARGET in env.txt reaches it).

Mac (M2 Max, 144 Hz screen): 119.5 fps at 2560x1440 at the title and in the menus at 1.000 of real time, menus and
the inventory at normal speed; in the open world about 84 fps at 1440p and 74 at 4K with PR seedds#62's implementation of
the same step (two physics substeps a frame at 120, three here; not measured again); at the profile's 60 fps 1.000 of real time. Red lines: BufferInitialize past the end of a pool when the
inventory opens, on main too; MemoryPoolInitialize without storage only at render scale 1.6, as with the first
implementation (PR seedds#62). TOTK, AoC and
Paper Mario: their stubs are unchanged and their tables get no new rows (not run here).
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 24, 2026
…he game's submissions

macOS lowers the GPU clock while the GPU idles part of each frame, even when the frames then miss their
deadline, and offers no interface to ask for a clock. Breath of the Wild waits for each frame's GPU work, so
its GPU idles while the host translates the next frame (GitHub issue seedds#71). The filler of PR seedds#62 ran for every
game all the time and shared the GPU with the game's work. Now it starts only when a tenth of 120 presents
come late (mtl_gpu_fill_frame), keeps one small dispatch on a queue of its own only while none of the game's
submissions is on the GPU (from the completion of the last in flight to the next commit), so it never adds
to the GPU time the frame step reads, and stops after a hold without late frames that doubles at each start
(60 s up to 16 min). DM_GPU_FILL=0 never, =1 from the start (also on iOS, where it is off by default).

Breath of the Wild at 60 fps (M2 Max, macmon each second for 180 s): without it the clock fell to 444 MHz
after 70 s and stayed (304-346 late frames every 30 s); with it 1398 MHz throughout (11-17).
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 24, 2026
…ants in the host

On the general output size machinery (ctx.keys, OUTPUT_W / OUTPUT_H, DM_OUTPUT_SIZE, the state page), builds tell the loader which further
stubs they have through main's rewriter table: VAR_STEP, RENDER_POOL and the base sizes VIEW_W / VIEW_H. An explicit DM_OUTPUT_SIZE replaces the
size a render scale above 1.0 gives the output. With present snapshots on, the variable step is paced by the snapshot ring as any other frame. The loader writes the state
page fields beyond +0x40 only for such a build, so AoC's +0x28 and TOTK's +0x8 are never touched and no heap
size or base width of one game is in the host. The page grows to 0x60 bytes. Breath of the Wild's stubs are in its patches.py; its main rewrites byte-identically to the previous patch_nso.py version of this change.

- Variable frame step (DM_FPS_TARGET 61 to 240, refused on a build without VAR_STEP): each frame the host
  publishes the time the previous one took as the VFR's frame ratio (state +0x50, main+0x151d484); the VFR
  override and prerendered movies keep the whole-vsync step. The display link runs at the cap (mode 4, with
  virtual ticks on a screen whose rate is not a multiple of it; no screen mode switch). Steps have no floor at
  the cap: at 120 on a 144 Hz screen a floor of 1/120 s ran the game at 1.12 of real time.
- Interval-stepped logic: the layout system's animation step (menus, HUD; main+0x1280ec8) and a fade
  (main+0x125f114) take the VFR's frame ratio in place of max(interval, 1); menus and the HUD ran at twice the
  speed at 120. Held buttons count the ratio (main+0xeb0f88): the inventory cursor repeated at twice the speed
  at 60 already. The physics step gets a ratio of at least 0.5 (main+0x128106c), three substeps, where two at
  120 blew ragdolls apart. Sites from MacNativeGames PR seedds#103, checked by disassembly.
- Above 1080p (render scale up to 3.0, Mac only): the render buffer pool grows by the factor's square
  (main+0x106d328), the application pool, alias region and the game's fixed heaps by what it adds plus 64 MB
  (state +0x58: the stubs add it to the game's own sizes), and above 1.2 the output takes the views' size.
- The iOS launcher keeps 30 / 60: above 60 is not yet run on an iPhone (DM_FPS_TARGET in env.txt reaches it).

Mac (M2 Max, 144 Hz screen): 119.5 fps at 2560x1440 at the title and in the menus at 1.000 of real time, menus and
the inventory at normal speed; in the open world about 84 fps at 1440p and 74 at 4K with PR seedds#62's implementation of
the same step (two physics substeps a frame at 120, three here; not measured again); at the profile's 60 fps 1.000 of real time. Red lines: BufferInitialize past the end of a pool when the
inventory opens, on main too; MemoryPoolInitialize without storage only at render scale 1.6, as with the first
implementation (PR seedds#62). TOTK, AoC and
Paper Mario: their stubs are unchanged and their tables get no new rows (not run here).

The graphics tests that compile nvn_mtl.m and hle_nvn.c in one translation unit rename nvn_mtl.m's weak nvn_var_fps, as they do nvn_game_fps.
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 24, 2026
…ants in the host

On the general output size machinery (ctx.keys, OUTPUT_W / OUTPUT_H, DM_OUTPUT_SIZE, the state page), builds tell the loader which further
stubs they have through main's rewriter table: VAR_STEP, RENDER_POOL and the base sizes VIEW_W / VIEW_H. An explicit DM_OUTPUT_SIZE replaces the
size a render scale above 1.0 gives the output. With present snapshots on, the variable step is paced by the snapshot ring as any other frame. The loader writes the state
page fields beyond +0x40 only for such a build, so AoC's +0x28 and TOTK's +0x8 are never touched and no heap
size or base width of one game is in the host. The page grows to 0x60 bytes. Breath of the Wild's stubs are in its patches.py; its main rewrites byte-identically to the previous patch_nso.py version of this change.

- Variable frame step (DM_FPS_TARGET 61 to 240, refused on a build without VAR_STEP): each frame the host
  publishes the time the previous one took as the VFR's frame ratio (state +0x50, main+0x151d484); the VFR
  override and prerendered movies keep the whole-vsync step. The display link runs at the cap (mode 4, with
  virtual ticks on a screen whose rate is not a multiple of it; no screen mode switch). Steps have no floor at
  the cap: at 120 on a 144 Hz screen a floor of 1/120 s ran the game at 1.12 of real time.
- Interval-stepped logic: the layout system's animation step (menus, HUD; main+0x1280ec8) and a fade
  (main+0x125f114) take the VFR's frame ratio in place of max(interval, 1); menus and the HUD ran at twice the
  speed at 120. Held buttons count the ratio (main+0xeb0f88): the inventory cursor repeated at twice the speed
  at 60 already. The physics step gets a ratio of at least 0.5 (main+0x128106c), three substeps, where two at
  120 blew ragdolls apart. Sites from MacNativeGames PR seedds#103, checked by disassembly.
- Above 1080p (render scale up to 3.0, Mac only): the render buffer pool grows by the factor's square
  (main+0x106d328), the application pool, alias region and the game's fixed heaps by what it adds plus 64 MB
  (state +0x58: the stubs add it to the game's own sizes), and above 1.2 the output takes the views' size.
- The iOS launcher keeps 30 / 60: above 60 is not yet run on an iPhone (DM_FPS_TARGET in env.txt reaches it).

Mac (M2 Max, 144 Hz screen): 119.5 fps at 2560x1440 at the title and in the menus at 1.000 of real time, menus and
the inventory at normal speed; in the open world about 84 fps at 1440p and 74 at 4K with PR seedds#62's implementation of
the same step (two physics substeps a frame at 120, three here; not measured again); at the profile's 60 fps 1.000 of real time. Red lines: BufferInitialize past the end of a pool when the
inventory opens, on main too; MemoryPoolInitialize without storage only at render scale 1.6, as with the first
implementation (PR seedds#62). TOTK, AoC and
Paper Mario: their stubs are unchanged and their tables get no new rows (not run here).

The graphics tests that compile nvn_mtl.m and hle_nvn.c in one translation unit rename nvn_mtl.m's weak nvn_var_fps, as they do nvn_game_fps.
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 25, 2026
…ants in the host

Builds tell the loader which further stubs they have through main's rewriter table (ctx.keys of the stubs in the profile's patches.py):
VAR_STEP, RENDER_POOL and the base sizes VIEW_W / VIEW_H / OUTPUT_W / OUTPUT_H. The loader writes the state
page fields beyond +0x40 only for such a build, so AoC's +0x28 and TOTK's +0x8 are never touched and no heap
size or base width of one game is in the host. The page grows to 0x60 bytes. Breath of the Wild's stubs are in its patches.py; its main rewrites byte-identically to the previous patch_nso.py version of this change.

- Variable frame step (DM_FPS_TARGET 61 to 240, refused on a build without VAR_STEP): each frame the host
  publishes the time the previous one took as the VFR's frame ratio (state +0x50, main+0x151d484); the VFR
  override and prerendered movies keep the whole-vsync step. The display link runs at the cap (mode 4, with
  virtual ticks on a screen whose rate is not a multiple of it; no screen mode switch). Steps have no floor at
  the cap: at 120 on a 144 Hz screen a floor of 1/120 s ran the game at 1.12 of real time.
- Interval-stepped logic: the layout system's animation step (menus, HUD; main+0x1280ec8) and a fade
  (main+0x125f114) take the VFR's frame ratio in place of max(interval, 1); menus and the HUD ran at twice the
  speed at 120. Held buttons count the ratio (main+0xeb0f88): the inventory cursor repeated at twice the speed
  at 60 already. The physics step gets a ratio of at least 0.5 (main+0x128106c), three substeps, where two at
  120 blew ragdolls apart. Sites from MacNativeGames PR seedds#103, checked by disassembly.
- Above 1080p (render scale up to 3.0, Mac only): the render buffer pool grows by the factor's square
  (main+0x106d328), the application pool, alias region and the game's fixed heaps by what it adds plus 64 MB
  (state +0x58: the stubs add it to the game's own sizes), and above 1.2 the output takes the views' size.
- The iOS launcher keeps 30 / 60: above 60 is not yet run on an iPhone (DM_FPS_TARGET in env.txt reaches it).

Mac (M2 Max, 144 Hz screen): 119.5 fps at 2560x1440 at the title and in the menus at 1.000 of real time, menus and
the inventory at normal speed; in the open world about 84 fps at 1440p and 74 at 4K with PR seedds#62's implementation of
the same step (two physics substeps a frame at 120, three here; not measured again); at the profile's 60 fps 1.000 of real time. Red lines: BufferInitialize past the end of a pool when the
inventory opens, on main too; MemoryPoolInitialize without storage only at render scale 1.6, as with the first
implementation (PR seedds#62). TOTK, AoC and
Paper Mario: their stubs are unchanged and their tables get no new rows (not run here).

The graphics tests that compile nvn_mtl.m and hle_nvn.c in one translation unit rename nvn_mtl.m's weak nvn_var_fps, as they do nvn_game_fps. dm/host/tests/t_heap_size.c and t_svc_memory.c, which compile hle_svc.c on their own, define dm_mem_extra (0: no render buffer pool grown), as loader.c does in the host.

On cae5ec2's memory layout: the extra goes into the alias size its boundary check (mem_init_once) validates as well as the layout, RESERVE and APP_POOL as before; the heap budget and the map limit take APP_POOL, so they include it.
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 25, 2026
…ants in the host

Builds tell the loader which further stubs they have through main's rewriter table (ctx.keys of the stubs in the profile's patches.py):
VAR_STEP, RENDER_POOL and the base sizes VIEW_W / VIEW_H / OUTPUT_W / OUTPUT_H. The loader writes the state
page fields beyond +0x40 only for such a build, so AoC's +0x28 and TOTK's +0x8 are never touched and no heap
size or base width of one game is in the host. The page grows to 0x60 bytes. Breath of the Wild's stubs are in its patches.py; its main rewrites byte-identically to the previous patch_nso.py version of this change.

- Variable frame step (DM_FPS_TARGET 61 to 240, refused on a build without VAR_STEP): each frame the host
  publishes the time the previous one took as the VFR's frame ratio (state +0x50, main+0x151d484); the VFR
  override and prerendered movies keep the whole-vsync step. The display link runs at the cap (mode 4, with
  virtual ticks on a screen whose rate is not a multiple of it; no screen mode switch). Steps have no floor at
  the cap: at 120 on a 144 Hz screen a floor of 1/120 s ran the game at 1.12 of real time.
- Interval-stepped logic: the layout system's animation step (menus, HUD; main+0x1280ec8) and a fade
  (main+0x125f114) take the VFR's frame ratio in place of max(interval, 1); menus and the HUD ran at twice the
  speed at 120. Held buttons count the ratio (main+0xeb0f88): the inventory cursor repeated at twice the speed
  at 60 already. The physics step gets a ratio of at least 0.5 (main+0x128106c), three substeps, where two at
  120 blew ragdolls apart. Sites from MacNativeGames PR seedds#103, checked by disassembly.
- Above 1080p (render scale up to 3.0, Mac only): the render buffer pool grows by the factor's square
  (main+0x106d328), the application pool, alias region and the game's fixed heaps by what it adds plus 64 MB
  (state +0x58: the stubs add it to the game's own sizes), and above 1.2 the output takes the views' size.
- The iOS launcher keeps 30 / 60: above 60 is not yet run on an iPhone (DM_FPS_TARGET in env.txt reaches it).

Mac (M2 Max, 144 Hz screen): 119.5 fps at 2560x1440 at the title and in the menus at 1.000 of real time, menus and
the inventory at normal speed; in the open world about 84 fps at 1440p and 74 at 4K with PR seedds#62's implementation of
the same step (two physics substeps a frame at 120, three here; not measured again); at the profile's 60 fps 1.000 of real time. Red lines: BufferInitialize past the end of a pool when the
inventory opens, on main too; MemoryPoolInitialize without storage only at render scale 1.6, as with the first
implementation (PR seedds#62). TOTK, AoC and
Paper Mario: their stubs are unchanged and their tables get no new rows (not run here).

The graphics tests that compile nvn_mtl.m and hle_nvn.c in one translation unit rename nvn_mtl.m's weak nvn_var_fps, as they do nvn_game_fps. dm/host/tests/t_heap_size.c and t_svc_memory.c, which compile hle_svc.c on their own, define dm_mem_extra (0: no render buffer pool grown), as loader.c does in the host.

On cae5ec2's memory layout: the extra goes into the alias size its boundary check (mem_init_once) validates as well as the layout, RESERVE and APP_POOL as before; the heap budget and the map limit take APP_POOL, so they include it.
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 25, 2026
…ants in the host

Builds tell the loader which further stubs they have through main's rewriter table (ctx.keys of the stubs in the profile's patches.py):
VAR_STEP, RENDER_POOL and the base sizes VIEW_W / VIEW_H / OUTPUT_W / OUTPUT_H. The loader writes the state
page fields beyond +0x40 only for such a build, so AoC's +0x28 and TOTK's +0x8 are never touched and no heap
size or base width of one game is in the host. The page grows to 0x60 bytes. Breath of the Wild's stubs are in its patches.py; its main rewrites byte-identically to the previous patch_nso.py version of this change.

- Variable frame step (DM_FPS_TARGET 61 to 240, refused on a build without VAR_STEP): each frame the host
  publishes the time the previous one took as the VFR's frame ratio (state +0x50, main+0x151d484); the VFR
  override and prerendered movies keep the whole-vsync step. The display link runs at the cap (mode 4, with
  virtual ticks on a screen whose rate is not a multiple of it; no screen mode switch). Steps have no floor at
  the cap: at 120 on a 144 Hz screen a floor of 1/120 s ran the game at 1.12 of real time.
- Interval-stepped logic: the layout system's animation step (menus, HUD; main+0x1280ec8) and a fade
  (main+0x125f114) take the VFR's frame ratio in place of max(interval, 1); menus and the HUD ran at twice the
  speed at 120. Held buttons count the ratio (main+0xeb0f88): the inventory cursor repeated at twice the speed
  at 60 already. The physics step gets a ratio of at least 0.5 (main+0x128106c), three substeps, where two at
  120 blew ragdolls apart. Sites from MacNativeGames PR seedds#103, checked by disassembly.
- Above 1080p (render scale up to 3.0, Mac only): the render buffer pool grows by the factor's square
  (main+0x106d328), the application pool, alias region and the game's fixed heaps by what it adds plus 64 MB
  (state +0x58: the stubs add it to the game's own sizes), and above 1.2 the output takes the views' size.
- The iOS launcher keeps 30 / 60: above 60 is not yet run on an iPhone (DM_FPS_TARGET in env.txt reaches it).

Mac (M2 Max, 144 Hz screen): 119.5 fps at 2560x1440 at the title and in the menus at 1.000 of real time, menus and
the inventory at normal speed; in the open world about 84 fps at 1440p and 74 at 4K with PR seedds#62's implementation of
the same step (two physics substeps a frame at 120, three here; not measured again); at the profile's 60 fps 1.000 of real time. Red lines: BufferInitialize past the end of a pool when the
inventory opens, on main too; MemoryPoolInitialize without storage only at render scale 1.6, as with the first
implementation (PR seedds#62). TOTK, AoC and
Paper Mario: their stubs are unchanged and their tables get no new rows (not run here).

The graphics tests that compile nvn_mtl.m and hle_nvn.c in one translation unit rename nvn_mtl.m's weak nvn_var_fps, as they do nvn_game_fps. dm/host/tests/t_heap_size.c and t_svc_memory.c, which compile hle_svc.c on their own, define dm_mem_extra (0: no render buffer pool grown), as loader.c does in the host.

On cae5ec2's memory layout: the extra goes into the alias size its boundary check (mem_init_once) validates as well as the layout, RESERVE and APP_POOL as before; the heap budget and the map limit take APP_POOL, so they include it.
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 26, 2026
…ants in the host

Builds tell the loader which further stubs they have through main's rewriter table (ctx.keys of the stubs in the profile's patches.py):
VAR_STEP, RENDER_POOL and the base sizes VIEW_W / VIEW_H / OUTPUT_W / OUTPUT_H. The loader writes the state
page fields beyond +0x40 only for such a build, so AoC's +0x28 and TOTK's +0x8 are never touched and no heap
size or base width of one game is in the host. The page grows to 0x60 bytes. Breath of the Wild's stubs are in its patches.py; its main rewrites byte-identically to the previous patch_nso.py version of this change.

- Variable frame step (DM_FPS_TARGET 61 to 240, refused on a build without VAR_STEP): each frame the host
  publishes the time the previous one took as the VFR's frame ratio (state +0x50, main+0x151d484); the VFR
  override and prerendered movies keep the whole-vsync step. The display link runs at the cap (mode 4, with
  virtual ticks on a screen whose rate is not a multiple of it; no screen mode switch). Steps have no floor at
  the cap: at 120 on a 144 Hz screen a floor of 1/120 s ran the game at 1.12 of real time.
- Interval-stepped logic: the layout system's animation step (menus, HUD; main+0x1280ec8) and a fade
  (main+0x125f114) take the VFR's frame ratio in place of max(interval, 1); menus and the HUD ran at twice the
  speed at 120. Held buttons count the ratio (main+0xeb0f88): the inventory cursor repeated at twice the speed
  at 60 already. The physics step gets a ratio of at least 0.5 (main+0x128106c), three substeps, where two at
  120 blew ragdolls apart. Sites from MacNativeGames PR seedds#103, checked by disassembly.
- Above 1080p (render scale up to 3.0, Mac only): the render buffer pool grows by the factor's square
  (main+0x106d328), the application pool, alias region and the game's fixed heaps by what it adds plus 64 MB
  (state +0x58: the stubs add it to the game's own sizes), and above 1.2 the output takes the views' size.
- The iOS launcher keeps 30 / 60: above 60 is not yet run on an iPhone (DM_FPS_TARGET in env.txt reaches it).

Mac (M2 Max, 144 Hz screen): 119.5 fps at 2560x1440 at the title and in the menus at 1.000 of real time, menus and
the inventory at normal speed; in the open world about 84 fps at 1440p and 74 at 4K with PR seedds#62's implementation of
the same step (two physics substeps a frame at 120, three here; not measured again); at the profile's 60 fps 1.000 of real time. Red lines: BufferInitialize past the end of a pool when the
inventory opens, on main too; MemoryPoolInitialize without storage only at render scale 1.6, as with the first
implementation (PR seedds#62). TOTK, AoC and
Paper Mario: their stubs are unchanged and their tables get no new rows (not run here).

The graphics tests that compile nvn_mtl.m and hle_nvn.c in one translation unit rename nvn_mtl.m's weak nvn_var_fps, as they do nvn_game_fps. dm/host/tests/t_heap_size.c and t_svc_memory.c, which compile hle_svc.c on their own, define dm_mem_extra (0: no render buffer pool grown), as loader.c does in the host.

On cae5ec2's memory layout: the extra goes into the alias size its boundary check (mem_init_once) validates as well as the layout, RESERVE and APP_POOL as before; the heap budget and the map limit take APP_POOL, so they include it.
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 26, 2026
…ants in the host

Builds tell the loader which further stubs they have through main's rewriter table (ctx.keys of the stubs in the profile's patches.py):
VAR_STEP, RENDER_POOL and the base sizes VIEW_W / VIEW_H / OUTPUT_W / OUTPUT_H. The loader writes the state
page fields beyond +0x40 only for such a build, so AoC's +0x28 and TOTK's +0x8 are never touched and no heap
size or base width of one game is in the host. The page grows to 0x60 bytes. Breath of the Wild's stubs are in its patches.py; its main rewrites byte-identically to the previous patch_nso.py version of this change.

- Variable frame step (DM_FPS_TARGET 61 to 240, refused on a build without VAR_STEP): each frame the host
  publishes the time the previous one took as the VFR's frame ratio (state +0x50, main+0x151d484); the VFR
  override and prerendered movies keep the whole-vsync step. The display link runs at the cap (mode 4, with
  virtual ticks on a screen whose rate is not a multiple of it; no screen mode switch). Steps have no floor at
  the cap: at 120 on a 144 Hz screen a floor of 1/120 s ran the game at 1.12 of real time.
- Interval-stepped logic: the layout system's animation step (menus, HUD; main+0x1280ec8) and a fade
  (main+0x125f114) take the VFR's frame ratio in place of max(interval, 1); menus and the HUD ran at twice the
  speed at 120. Held buttons count the ratio (main+0xeb0f88): the inventory cursor repeated at twice the speed
  at 60 already. The physics step gets a ratio of at least 0.5 (main+0x128106c), three substeps, where two at
  120 blew ragdolls apart. Sites from MacNativeGames PR seedds#103, checked by disassembly.
- Above 1080p (render scale up to 3.0, Mac only): the render buffer pool grows by the factor's square
  (main+0x106d328), the application pool, alias region and the game's fixed heaps by what it adds plus 64 MB
  (state +0x58: the stubs add it to the game's own sizes), and above 1.2 the output takes the views' size.
- The iOS launcher keeps 30 / 60: above 60 is not yet run on an iPhone (DM_FPS_TARGET in env.txt reaches it).

Mac (M2 Max, 144 Hz screen): 119.5 fps at 2560x1440 at the title and in the menus at 1.000 of real time, menus and
the inventory at normal speed; in the open world about 84 fps at 1440p and 74 at 4K with PR seedds#62's implementation of
the same step (two physics substeps a frame at 120, three here; not measured again); at the profile's 60 fps 1.000 of real time. Red lines: BufferInitialize past the end of a pool when the
inventory opens, on main too; MemoryPoolInitialize without storage only at render scale 1.6, as with the first
implementation (PR seedds#62). TOTK, AoC and
Paper Mario: their stubs are unchanged and their tables get no new rows (not run here).

The graphics tests that compile nvn_mtl.m and hle_nvn.c in one translation unit rename nvn_mtl.m's weak nvn_var_fps, as they do nvn_game_fps. dm/host/tests/t_heap_size.c and t_svc_memory.c, which compile hle_svc.c on their own, define dm_mem_extra (0: no render buffer pool grown), as loader.c does in the host.

On cae5ec2's memory layout: the extra goes into the alias size its boundary check (mem_init_once) validates as well as the layout, RESERVE and APP_POOL as before; the heap budget and the map limit take APP_POOL, so they include it.
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 26, 2026
…ants in the host

Builds tell the loader which further stubs they have through main's rewriter table (ctx.keys of the stubs in the profile's patches.py):
VAR_STEP, RENDER_POOL and the base sizes VIEW_W / VIEW_H / OUTPUT_W / OUTPUT_H. The loader writes the state
page fields beyond +0x40 only for such a build, so AoC's +0x28 and TOTK's +0x8 are never touched and no heap
size or base width of one game is in the host. The page grows to 0x60 bytes. Breath of the Wild's stubs are in its patches.py; its main rewrites byte-identically to the previous patch_nso.py version of this change.

- Variable frame step (DM_FPS_TARGET 61 to 240, refused on a build without VAR_STEP): each frame the host
  publishes the time the previous one took as the VFR's frame ratio (state +0x50, main+0x151d484); the VFR
  override and prerendered movies keep the whole-vsync step. The display link runs at the cap (mode 4, with
  virtual ticks on a screen whose rate is not a multiple of it; no screen mode switch). Steps have no floor at
  the cap: at 120 on a 144 Hz screen a floor of 1/120 s ran the game at 1.12 of real time.
- Interval-stepped logic: the layout system's animation step (menus, HUD; main+0x1280ec8) and a fade
  (main+0x125f114) take the VFR's frame ratio in place of max(interval, 1); menus and the HUD ran at twice the
  speed at 120. Held buttons count the ratio (main+0xeb0f88): the inventory cursor repeated at twice the speed
  at 60 already. The physics step gets a ratio of at least 0.5 (main+0x128106c), three substeps, where two at
  120 blew ragdolls apart. Sites from MacNativeGames PR seedds#103, checked by disassembly.
- Above 1080p (render scale up to 3.0, Mac only): the render buffer pool grows by the factor's square
  (main+0x106d328), the application pool, alias region and the game's fixed heaps by what it adds plus 64 MB
  (state +0x58: the stubs add it to the game's own sizes), and above 1.2 the output takes the views' size.
- The iOS launcher keeps 30 / 60: above 60 is not yet run on an iPhone (DM_FPS_TARGET in env.txt reaches it).

Mac (M2 Max, 144 Hz screen): 119.5 fps at 2560x1440 at the title and in the menus at 1.000 of real time, menus and
the inventory at normal speed; in the open world about 84 fps at 1440p and 74 at 4K with PR seedds#62's implementation of
the same step (two physics substeps a frame at 120, three here; not measured again); at the profile's 60 fps 1.000 of real time. Red lines: BufferInitialize past the end of a pool when the
inventory opens, on main too; MemoryPoolInitialize without storage only at render scale 1.6, as with the first
implementation (PR seedds#62). TOTK, AoC and
Paper Mario: their stubs are unchanged and their tables get no new rows (not run here).

The graphics tests that compile nvn_mtl.m and hle_nvn.c in one translation unit rename nvn_mtl.m's weak nvn_var_fps, as they do nvn_game_fps. dm/host/tests/t_heap_size.c and t_svc_memory.c, which compile hle_svc.c on their own, define dm_mem_extra (0: no render buffer pool grown), as loader.c does in the host.

On cae5ec2's memory layout: the extra goes into the alias size its boundary check (mem_init_once) validates as well as the layout, RESERVE and APP_POOL as before; the heap budget and the map limit take APP_POOL, so they include it.
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 26, 2026
…ants in the host

Builds tell the loader which further stubs they have through main's rewriter table (ctx.keys of the stubs in the profile's patches.py):
VAR_STEP, RENDER_POOL and the base sizes VIEW_W / VIEW_H / OUTPUT_W / OUTPUT_H. The loader writes the state
page fields beyond +0x40 only for such a build, so AoC's +0x28 and TOTK's +0x8 are never touched and no heap
size or base width of one game is in the host. The page grows to 0x60 bytes. Breath of the Wild's stubs are in its patches.py; its main rewrites byte-identically to the previous patch_nso.py version of this change.

- Variable frame step (DM_FPS_TARGET 61 to 240, refused on a build without VAR_STEP): each frame the host
  publishes the time the previous one took as the VFR's frame ratio (state +0x50, main+0x151d484); the VFR
  override and prerendered movies keep the whole-vsync step. The display link runs at the cap (mode 4, with
  virtual ticks on a screen whose rate is not a multiple of it; no screen mode switch). Steps have no floor at
  the cap: at 120 on a 144 Hz screen a floor of 1/120 s ran the game at 1.12 of real time.
- Interval-stepped logic: the layout system's animation step (menus, HUD; main+0x1280ec8) and a fade
  (main+0x125f114) take the VFR's frame ratio in place of max(interval, 1); menus and the HUD ran at twice the
  speed at 120. Held buttons count the ratio (main+0xeb0f88): the inventory cursor repeated at twice the speed
  at 60 already. The physics step gets a ratio of at least 0.5 (main+0x128106c), three substeps, where two at
  120 blew ragdolls apart. Sites from MacNativeGames PR seedds#103, checked by disassembly.
- Above 1080p (render scale up to 3.0, Mac only): the render buffer pool grows by the factor's square
  (main+0x106d328), the application pool, alias region and the game's fixed heaps by what it adds plus 64 MB
  (state +0x58: the stubs add it to the game's own sizes), and above 1.2 the output takes the views' size.
- The iOS launcher keeps 30 / 60: above 60 is not yet run on an iPhone (DM_FPS_TARGET in env.txt reaches it).

Mac (M2 Max, 144 Hz screen): 119.5 fps at 2560x1440 at the title and in the menus at 1.000 of real time, menus and
the inventory at normal speed; in the open world about 84 fps at 1440p and 74 at 4K with PR seedds#62's implementation of
the same step (two physics substeps a frame at 120, three here; not measured again); at the profile's 60 fps 1.000 of real time. Red lines: BufferInitialize past the end of a pool when the
inventory opens, on main too; MemoryPoolInitialize without storage only at render scale 1.6, as with the first
implementation (PR seedds#62). TOTK, AoC and
Paper Mario: their stubs are unchanged and their tables get no new rows (not run here).

The graphics tests that compile nvn_mtl.m and hle_nvn.c in one translation unit rename nvn_mtl.m's weak nvn_var_fps, as they do nvn_game_fps. dm/host/tests/t_heap_size.c and t_svc_memory.c, which compile hle_svc.c on their own, define dm_mem_extra (0: no render buffer pool grown), as loader.c does in the host.

On cae5ec2's memory layout: the extra goes into the alias size its boundary check (mem_init_once) validates as well as the layout, RESERVE and APP_POOL as before; the heap budget and the map limit take APP_POOL, so they include it.
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 28, 2026
…ants in the host

Builds tell the loader which further stubs they have through main's rewriter table (ctx.keys of the stubs in the profile's patches.py):
VAR_STEP, RENDER_POOL and the base sizes VIEW_W / VIEW_H / OUTPUT_W / OUTPUT_H. The loader writes the state
page fields beyond +0x40 only for such a build, so AoC's +0x28 and TOTK's +0x8 are never touched and no heap
size or base width of one game is in the host. The page grows to 0x60 bytes. Breath of the Wild's stubs are in its patches.py; its main rewrites byte-identically to the previous patch_nso.py version of this change.

- Variable frame step (DM_FPS_TARGET 61 to 240, refused on a build without VAR_STEP): each frame the host
  publishes the time the previous one took as the VFR's frame ratio (state +0x50, main+0x151d484); the VFR
  override and prerendered movies keep the whole-vsync step. The display link runs at the cap (mode 4, with
  virtual ticks on a screen whose rate is not a multiple of it; no screen mode switch). Steps have no floor at
  the cap: at 120 on a 144 Hz screen a floor of 1/120 s ran the game at 1.12 of real time.
- Interval-stepped logic: the layout system's animation step (menus, HUD; main+0x1280ec8) and a fade
  (main+0x125f114) take the VFR's frame ratio in place of max(interval, 1); menus and the HUD ran at twice the
  speed at 120. Held buttons count the ratio (main+0xeb0f88): the inventory cursor repeated at twice the speed
  at 60 already. The physics step gets a ratio of at least 0.5 (main+0x128106c), three substeps, where two at
  120 blew ragdolls apart. Sites from MacNativeGames PR seedds#103, checked by disassembly.
- Above 1080p (render scale up to 3.0, Mac only): the render buffer pool grows by the factor's square
  (main+0x106d328), the application pool, alias region and the game's fixed heaps by what it adds plus 64 MB
  (state +0x58: the stubs add it to the game's own sizes), and above 1.2 the output takes the views' size.
- The iOS launcher keeps 30 / 60: above 60 is not yet run on an iPhone (DM_FPS_TARGET in env.txt reaches it).

Mac (M2 Max, 144 Hz screen): 119.5 fps at 2560x1440 at the title and in the menus at 1.000 of real time, menus and
the inventory at normal speed; in the open world about 84 fps at 1440p and 74 at 4K with PR seedds#62's implementation of
the same step (two physics substeps a frame at 120, three here; not measured again); at the profile's 60 fps 1.000 of real time. Red lines: BufferInitialize past the end of a pool when the
inventory opens, on main too; MemoryPoolInitialize without storage only at render scale 1.6, as with the first
implementation (PR seedds#62). TOTK, AoC and
Paper Mario: their stubs are unchanged and their tables get no new rows (not run here).

The graphics tests that compile nvn_mtl.m and hle_nvn.c in one translation unit rename nvn_mtl.m's weak nvn_var_fps, as they do nvn_game_fps. dm/host/tests/t_heap_size.c and t_svc_memory.c, which compile hle_svc.c on their own, define dm_mem_extra (0: no render buffer pool grown), as loader.c does in the host.

On cae5ec2's memory layout: the extra goes into the alias size its boundary check (mem_init_once) validates as well as the layout, RESERVE and APP_POOL as before; the heap budget and the map limit take APP_POOL, so they include it.
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 29, 2026
…ants in the host

Builds tell the loader which further stubs they have through main's rewriter table (ctx.keys of the stubs in the profile's patches.py):
VAR_STEP, RENDER_POOL and the base sizes VIEW_W / VIEW_H / OUTPUT_W / OUTPUT_H. The loader writes the state
page fields beyond +0x40 only for such a build, so AoC's +0x28 and TOTK's +0x8 are never touched and no heap
size or base width of one game is in the host. The page grows to 0x60 bytes. Breath of the Wild's stubs are in its patches.py; its main rewrites byte-identically to the previous patch_nso.py version of this change.

- Variable frame step (DM_FPS_TARGET 61 to 240, refused on a build without VAR_STEP): each frame the host
  publishes the time the previous one took as the VFR's frame ratio (state +0x50, main+0x151d484); the VFR
  override and prerendered movies keep the whole-vsync step. The display link runs at the cap (mode 4, with
  virtual ticks on a screen whose rate is not a multiple of it; no screen mode switch). Steps have no floor at
  the cap: at 120 on a 144 Hz screen a floor of 1/120 s ran the game at 1.12 of real time.
- Interval-stepped logic: the layout system's animation step (menus, HUD; main+0x1280ec8) and a fade
  (main+0x125f114) take the VFR's frame ratio in place of max(interval, 1); menus and the HUD ran at twice the
  speed at 120. Held buttons count the ratio (main+0xeb0f88): the inventory cursor repeated at twice the speed
  at 60 already. The physics step gets a ratio of at least 0.5 (main+0x128106c), three substeps, where two at
  120 blew ragdolls apart. Sites from MacNativeGames PR seedds#103, checked by disassembly.
- Above 1080p (render scale up to 3.0, Mac only): the render buffer pool grows by the factor's square
  (main+0x106d328), the application pool, alias region and the game's fixed heaps by what it adds plus 64 MB
  (state +0x58: the stubs add it to the game's own sizes), and above 1.2 the output takes the views' size.
- The iOS launcher keeps 30 / 60: above 60 is not yet run on an iPhone (DM_FPS_TARGET in env.txt reaches it).

Mac (M2 Max, 144 Hz screen): 119.5 fps at 2560x1440 at the title and in the menus at 1.000 of real time, menus and
the inventory at normal speed; in the open world about 84 fps at 1440p and 74 at 4K with PR seedds#62's implementation of
the same step (two physics substeps a frame at 120, three here; not measured again); at the profile's 60 fps 1.000 of real time. Red lines: BufferInitialize past the end of a pool when the
inventory opens, on main too; MemoryPoolInitialize without storage only at render scale 1.6, as with the first
implementation (PR seedds#62). TOTK, AoC and
Paper Mario: their stubs are unchanged and their tables get no new rows (not run here).

The graphics tests that compile nvn_mtl.m and hle_nvn.c in one translation unit rename nvn_mtl.m's weak nvn_var_fps, as they do nvn_game_fps. dm/host/tests/t_heap_size.c and t_svc_memory.c, which compile hle_svc.c on their own, define dm_mem_extra (0: no render buffer pool grown), as loader.c does in the host.

On cae5ec2's memory layout: the extra goes into the alias size its boundary check (mem_init_once) validates as well as the layout, RESERVE and APP_POOL as before; the heap budget and the map limit take APP_POOL, so they include it.
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 30, 2026
…ants in the host

Builds tell the loader which further stubs they have through main's rewriter table (ctx.keys of the stubs in the profile's patches.py):
VAR_STEP, RENDER_POOL and the base sizes VIEW_W / VIEW_H / OUTPUT_W / OUTPUT_H. The loader writes the state
page fields beyond +0x40 only for such a build, so AoC's +0x28 and TOTK's +0x8 are never touched and no heap
size or base width of one game is in the host. The page grows to 0x60 bytes. Breath of the Wild's stubs are in its patches.py; its main rewrites byte-identically to the previous patch_nso.py version of this change.

- Variable frame step (DM_FPS_TARGET 61 to 240, refused on a build without VAR_STEP): each frame the host
  publishes the time the previous one took as the VFR's frame ratio (state +0x50, main+0x151d484); the VFR
  override and prerendered movies keep the whole-vsync step. The display link runs at the cap (mode 4, with
  virtual ticks on a screen whose rate is not a multiple of it; no screen mode switch). Steps have no floor at
  the cap: at 120 on a 144 Hz screen a floor of 1/120 s ran the game at 1.12 of real time.
- Interval-stepped logic: the layout system's animation step (menus, HUD; main+0x1280ec8) and a fade
  (main+0x125f114) take the VFR's frame ratio in place of max(interval, 1); menus and the HUD ran at twice the
  speed at 120. Held buttons count the ratio (main+0xeb0f88): the inventory cursor repeated at twice the speed
  at 60 already. The physics step gets a ratio of at least 0.5 (main+0x128106c), three substeps, where two at
  120 blew ragdolls apart. Sites from MacNativeGames PR seedds#103, checked by disassembly.
- Above 1080p (render scale up to 3.0, Mac only): the render buffer pool grows by the factor's square
  (main+0x106d328), the application pool, alias region and the game's fixed heaps by what it adds plus 64 MB
  (state +0x58: the stubs add it to the game's own sizes), and above 1.2 the output takes the views' size.
- The iOS launcher keeps 30 / 60: above 60 is not yet run on an iPhone (DM_FPS_TARGET in env.txt reaches it).

Mac (M2 Max, 144 Hz screen): 119.5 fps at 2560x1440 at the title and in the menus at 1.000 of real time, menus and
the inventory at normal speed; in the open world about 84 fps at 1440p and 74 at 4K with PR seedds#62's implementation of
the same step (two physics substeps a frame at 120, three here; not measured again); at the profile's 60 fps 1.000 of real time. Red lines: BufferInitialize past the end of a pool when the
inventory opens, on main too; MemoryPoolInitialize without storage only at render scale 1.6, as with the first
implementation (PR seedds#62). TOTK, AoC and
Paper Mario: their stubs are unchanged and their tables get no new rows (not run here).

The graphics tests that compile nvn_mtl.m and hle_nvn.c in one translation unit rename nvn_mtl.m's weak nvn_var_fps, as they do nvn_game_fps. dm/host/tests/t_heap_size.c and t_svc_memory.c, which compile hle_svc.c on their own, define dm_mem_extra (0: no render buffer pool grown), as loader.c does in the host.

On cae5ec2's memory layout: the extra goes into the alias size its boundary check (mem_init_once) validates as well as the layout, RESERVE and APP_POOL as before; the heap budget and the map limit take APP_POOL, so they include it.
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
…ng on its own thread (on by default on iOS), uniform shadows copied by a worker, uniform updates kept across render passes

Taken from v0lumehi's PR seedds#62, the parts that hold for every game (none is gated by a title, build or profile; all but the Mac front end reach only the NVN games):
- nvn_rec.h: the replay's Metal calls (encoders, draws, state, argument table writes, commits, event signals) go to a worker thread as records, in the same order. The submit thread waits for it at the end of each submission and before anything that waits for the GPU or uses another queue. On by default on iOS, DM_NVN_ENC_THREAD=1 on the Mac.
- Uniform shadows of 512 bytes or more (ubp_get) are copied by a worker; a commit waits for the copies queued before it, a CPU read of a shadow for its own (DM_NVN_UB_COPY_THREAD=0 copies on the submit thread as before).
- Deferred inline uniform updates are kept across render pass ends (DM_NVN_UB_LAZY, at most 160) and land before the next copy, a draw that reads their memory other than through uniform bindings the shadows cover, or the end of the submission, instead of in a copy encoder after every pass.
- A two-level address → pool cache (by 4 KB page, then the last 8 pools found), and the pass dump check answered first when it is off.
- DM_NVN_GPUPROF=f or f1-f2: every encoder's GPU start and duration, from Metal 4 counter heap timestamps.
- Mac: the drawable follows the window in pixels (in fullscreen it had stayed at 1280x720), the process declares latency-critical activity, and DM_METAL_HUD=1 shows Apple's performance HUD (on the iPhone too, from Documents/env.txt).

On top of the PR:
- A dispatch lands the kept updates first when it reads or writes their memory through a storage buffer or its indirect arguments, or reads a part of a uniform binding the shadows cannot give (ubd_conflict_cs, with the per-stage check it shares with draws, ubd_conflict_sh). Dispatches open the copy encoder through blit_open, which never landed them, so they ran before the updates. Transform feedback draws land them first, as every pass end did before.
- A deferred update that a newer one covers whole is dropped from the landing list. Breath of the Wild rewrites the same 64 bytes before every draw group, so the list held up to 160 repeats that every binding lookup scanned: the port cost 16,800 instructions a draw against main's 13,200, and costs 13,500 with the drop.
- The encoding thread records encoder labels (DM_NVN_ENC_LABEL) and counter heap timestamps (DM_NVN_GPUPROF): without them either diagnostic stopped the host on iOS.
- DM_NVN_UBP_CHECK waits for the copy worker before it reads a shadow. It compared unfilled shadows (293,447 "different"); now 232,000 equal and 0 different with the encoding thread on, 234,000 and 0 with it off.

Left out: Breath of the Wild above 60 fps and above 1080p (rewriter cuts for its build and a profile key), the Mac GPU filler and screen mode switch, and the iOS launcher.

Breath of the Wild on the Mac (the Great Plateau save, 60 fps cap, beside main under the same load): submit thread 4.30 against 4.48 ms a frame, GPU p95 6.2 against 7.0-7.3 ms, 1.000 of real time, no red lines; with the encoding thread the submit thread takes 3.16 ms (9,700 instructions a draw). t_nvn 100/100 with the encoding thread off and on; the hosts for TOTK and Hades build.

Co-authored-by: v0lumehi <[email protected]>
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
…e table of player-facing settings (dm/games/settings.tsv; GitHub PR seedds#62, issue seedds#64)

The launcher from v0lumehi's PR seedds#62 (Launcher.swift, SwiftUI: the game's icon, name and version, Play, and the settings), built as their issue seedds#64 proposes: dm/games/settings.tsv declares each player-facing setting once (the environment variable it sets, its kind: choice, range or toggle, its default and the condition under which a game offers it). build_ipa.sh runs dm/games/settings.py, which keeps the rows that hold for the game and fills in its defaults: the host's own from game_profile.h (DM_GAME_FPS_TARGET, DM_GAME_OPMODE), the build's (DM_LANG, DM_SHOW_FPS), the game's languages from its control data, and the render scale only for a build with the rewriter's render-scale stub, which patch_nso.py now records in main's table (RENDER_SCALE: Breath of the Wild 1.9.0, Tears of the Kingdom 1.4.3). The result goes into the app as dm/launcher.json, and the launcher draws one row per setting from it, so a new setting is one table row. Diagnostic switches stay environment-only. Breath of the Wild offers frame rate, render scale, console mode, 15 languages, the frame-rate counter and Apple's performance HUD.

Differences from the PR's launcher:
- The host's loading still starts at app launch. Only the loader read the frame rate and the render scale that early; it now just maps the frame step state page, and dm_fps_state_apply (main.c, when the game starts) writes both, so a boot is no slower with the launcher (the PR started all loading when Play was tapped). The game view, the pad and the frame-rate counter are made after Play, since they read the launcher's switches.
- The language choice applies: main.m sets the packed language as a default before the launcher runs, which the PR then took for a setting from env.txt and kept. main.m now lists the variables an env file set (DM_ENV_FILE_KEYS); only those are kept, and the launcher shows them greyed out.
- No new profile key for render scale (the rewriter's table tells), and the scale stops at 100 % (the above-1080p part is not in main). No Mac launcher.

The choices are kept in UserDefaults; DM_LAUNCHER=0 in Documents/env.txt skips the screen, as does an app without launcher.json. README: the settings screen in the Play section; dm/games/README.md and docs/development.md describe the table.

Checked: Launcher.swift type-checks against the iOS SDK and the Breath of the Wild IPA builds with it (launcher.json and RENDER_SCALE inside); the Mac host applies DM_FPS_TARGET=30 from the first present and DM_RENDER_SCALE=0.75 when the game starts. Not yet run on an iPhone.

Co-authored-by: v0lumehi <[email protected]>
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
…s#101): image atomics that are not followed go to a scratch buffer as large as the image, and the transform feedback draw ends the copy encoder before it opens its own

On the Mac, the fresh-save route of the docs crashed at about frame 3390 and from about frame 5300 page-faulted or crashed on corrupted pointers, with the encoding thread on and off; issue seedds#101 reports an iPhone 17 freezing on kIOGPUCommandBufferCallbackErrorPageFault.

- tf_draw opened its render encoder while the copy encoder (g_blit) was open: ubd_land's inline updates leave it open, as does a copy or a dispatch just before. Metal validation: "Command buffer already has an open command encoder"; the driver then crashed in -[AGXG18GFamilyComputeContext_mtlnext performEndEncoding] (or its dealloc on the encoding thread). Every other helper pass ends g_blit before it opens its own encoder; tf_draw now does too. A host built from before PR seedds#62 crashed the same way.
- A block-linear image's atomics went to the 64 KB dummy buffer, but SPIRV-Cross indexes them by the image bound in the same slot (spvImage2DAtomicCoord: x + y × its width). Z-A's atomic max into a 480x270 r32ui 2D array (texture ID 302, fragment shader 2bd5037003980716) ran about 1.4 MB past the dummy: into zero-copy pools over the game's heap (pointers in the game's objects and the host's program objects had their upper 4 bytes replaced by packed values, rewritten every frame) and into unmapped addresses (the page fault, after which macOS ignores the process's command buffers). MTL_SHADER_VALIDATION=1, which stops out-of-bounds accesses, let the scene play. Such atomics now go to a scratch buffer at least as large as the image (atom_scratch: width × height × layers × texel size, at least the NVN storage size; 3 MB here), grown when a larger image needs it; the results are discarded as before. An unbound image keeps the 64 KB dummy, since its slot holds the 1x1 dummy image. The bring-up host (d34e044) with today's shaders page-faulted the same way.

Three headless Mac runs of the whole route (encoding thread on, off, on) reached frame 12,300 with no GPU error and no crash; before, every run crashed or page-faulted between frames 5230 and 5480. t_nvn 102/102, t_ub 47/47, t_geometry 95/95, t_vbuf 43/43. docs/agents/04-graphics.md and Z-A's notes in docs/development.md say so.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants