Skip to content

Two guest-memory reclaim layers for NVN: pool page renew and static packaged-texture source reclaim - #103

Closed
4202217 wants to merge 2 commits into
seedds:mainfrom
4202217:feature/memory-reclaim
Closed

4202217 wants to merge 2 commits into
seedds:mainfrom
4202217:feature/memory-reclaim

Conversation

@4202217

@4202217 4202217 commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Two guest-memory reclaim layers for NVN, each behind its own profile key and off unless a profile turns it on. Split out of #86 on the reviewer's advice — the vibration work is now its own PR, and this one carries the two memory features alone.

1. Pool page renew (pool_renew) — a zero-copy MTLBuffer lives as long as the guest pages it wraps, and the guest never unmaps, so every finalized pool's buffer stayed in GPU memory for good. On nvnMemoryPoolFinalize the pool's interior guest-heap pages are replaced with fresh anonymous pages carrying the same bytes, which lets Metal drop the old mapping. Guest heap only (dm_guest_renewable), never a boundary page, never a page another live pool's buffer covers (checked twice), with a GPU wait before the pages move.

2. Static packaged-texture source page reclaim (tex_reclaim) — a packaged texture keeps its source bytes in guest memory and a GPU-private copy. Once the private copy exists and the source is provably static (all registered textures packaged, no read-back flags, no guest write since the upload stamp, no zero-copy view used within the idle window, guest heap only, no other live pool overlaps), the guest pages go back to the OS. Zero-copy views of such a pool are dropped with it, and the upload / mtl_read_texels paths are guarded against reading a reclaimed source; a stale no-copy buffer is released and recreated on demand. Rejections are counted by reason (hit, dirty, cover, shared-view, overlap, not-uploaded, outside-heap, write-use, untracked, re-upload, object, budget) and reported in one line per tick. The budget is live bytes, not cumulative — with a cumulative total the reclaim switched itself off for good once a session had reclaimed the budget in sum.

Measured on Hades II (base game, Mac host built from this branch, title → save, 95 s of scripted play with swings and hits, at frame 1200; the two runs differ only in DM_TEX_RECLAIM):

resident GPU allocated
reclaim off 3332 MB 2765 MB
reclaim on 2341 MB 2413 MB

Screenshots at the same present frames are the same picture (0.7-1.7% of pixels differ by more than 8 levels — animation drift between two independent runs, not a different frame). On the iPhone, the same change took this title from 3432 MB / 2743 MB to 2508 MB / 1815 MB. Hades II's profile turns tex_reclaim on; pool_renew stays off there — it is worth a few MB against a GPU wait per batch of finalizes (renewing 4 pools: 6 MB, 2.1 ms in total).

New profile keys (both validated in dm/games/game.py's header() and documented in dm/games/README.md), off unless a profile says otherwise, so no other game changes:

  • tex_reclaim: off / dryrun / on — DM_TEX_RECLAIM, DM_TEX_RECLAIM_DRYRUN, and DM_TEX_RECLAIM_MB / _MIN_MB / _PURITY / _BACKLOG_MB / _GRACE_FRAMES / _MAX_POOLS / _MAX_MB / _LOW_MB / _VIEW_IDLE (DM_RC_VIEW_IDLE) tune it.
  • pool_renew: on / off — DM_POOL_RENEW.

Verification

  • make -C dm/gfx/tests GAME=0100A00019DE0000 run — t_nvn, t_dirty_slots, t_dirty_race, t_readback, t_linear_readback and the rest pass. t_fuse_check (1), t_reorder_chain (30), t_defer_chain (1), t_mip_extent (2), t_rt_range (5), t_pfv (1), t_rt_range_ro (SIGABRT) and t_refl (2, needs ~/dm-work's libraries) fail identically on the base commit on this Mac — checked by running them on upstream/main here.
  • make -C dm/host/tests GAME=0100A00019DE0000 run — passes.
  • Mac, Hades II: static-source reclaim: on and reclaims pools from frame ~200; pool page renew (D1): on with renewed pages logged; the reclaim prints one line per tick with its block counters; no [RED] line from either feature over a 95-s run.

Not verified here: no game other than Hades II was run with either key on. I have not run the two keys together on a device beyond the iPhone figures above.

On the reviewer's LM3 note: their investigation points to many private render-target variants over shared NVN storage. That is not what this reclaim targets — it targets packaged textures whose source bytes are still resident in a guest pool after a private copy exists. It is not evidence that this fixes the LM3 workload, and I have not tested LM3.

🤖 Generated with Claude Code

seedds and others added 2 commits October 24, 2026 09:51
A zero-copy MTLBuffer is built on the guest's pool pages, and Metal keeps the
buffer (and its GPU pages) alive for as long as those pages stay mapped.
Dropping every host reference is not enough: the guest never unmaps, because
its heap is one mmap and a heap shrink is only an mprotect. Every "enter a
save, quit to the menu" therefore left the dead buffers behind for good, and
the next session's pools at the same guest addresses overlapped the stale GPU
pages.

On Finalize (mtl_pool_del) the pool's interior pages -- whole pages inside the
pool storage, since a boundary page may hold a neighbour -- are now replaced
with fresh anonymous pages and the bytes copied across. The guest sees the same
contents (its allocator may keep free-list data inside the block) and Metal's
old pages are orphaned, so they go away with the buffer.

Safety:
- only guest heap memory the game's own allocator owns (dm_guest_renewable,
  hle_svc.c): alias-region pages can be the same physical memory at a second
  address, and stack and module pages belong to other bookkeeping;
- never a page another live pool's buffer covers -- checked under the pool
  lock before the GPU wait and again after it, since a pool can land on the
  range while the lock is dropped;
- the GPU is waited for (the same fence the deferred release would have waited
  for anyway) before the pages move; a timeout falls back to the ordinary
  deferred release and leaves the pages alone;
- all-zero pages are skipped on the copy, so an untouched page costs no
  footprint.

Off by default: profile key pool_renew, or DM_POOL_RENEW=1. DM_POOL_RENEW=0
forces it off and =2 renews while leaving the pages zeroed -- measurement only,
it can corrupt the game's allocator.

Also asserts the regenerated buffers' lengths in the pool table (buflen), which
the overlap checks need.

Co-Authored-By: Claude Code <[email protected]>
…ith their pool

A packaged (block-linear) texture is uploaded into a GPU-private Metal texture, and the guest
memory pool keeps the original bytes as well: the same texels exist twice, once in guest pages
and once in GPU memory. Once the private copy exists and the source is provably static, the guest
pages are only a backup nothing reads again, so this returns them to the OS: the pool leaves the
residency set, its pages are replaced with anonymous zero pages, and phys_footprint falls by the
pool's size. Hades II measured on the Mac from this tree (base game, title -> save, 70 s of play,
frame 1200): resident 2480 MB and GPU allocated 2459 MB with the reclaim on, against 3460 MB and
2860 MB with it off in the same scene, same picture. On the iPhone the same change took the title
from 3432 MB / 2743 MB to 2508 MB / 1815 MB.

What makes a source "provably static" is checked per pool, under the locks, on snapshots taken
outside them: every texture registered on the pool is packaged; none carries a flag that means
the source is read back (linear, display, video decode, sparse, adaptive zcull, minimal layout,
multisample); nothing the pool holds had a guest write since the upload stamp of its batch; no
zero-copy view of the pool was used within the idle window; the bytes are guest heap the host may
replace (dm_guest_renewable); and no other live pool's buffer covers any page of it. A texture
uploaded again (pk->reuploads) is never a candidate: its content changed after the first copy.

The source is still the ground truth in two places, and both are guarded: a texture upload never
takes the zero-copy path over a reclaimed range, and ReadTexels reads the private copy instead of
the (now zero) guest bytes. If a reclaimed range is written anyway, the pool is invalidated with a
[RED] line and never reclaimed again; the textures it held keep their private copies and a later
re-upload of them starts from the zero pages, which is why a pool that had an upload after its
batch is refused in the first place.

A pool's zero-copy views are dropped with it (mtl_alias_drop_pool now returns how many, sweeps the
serial entries that point at them, takes them out of the residency set and forgets their use
slots). Without that the sharing table would keep them, and through them the pool's buffer, so the
memory would never come back. The same drop now happens on memory-pool Finalize, before
mtl_pool_del touches the pages.

The feature is off by default (profile key tex_reclaim off / dryrun / on; DM_TEX_RECLAIM and the
DM_TEX_RECLAIM_* tunables override it), so every other profile behaves exactly as before. On iOS
the memory readout line also doubles as the low-memory warning: under DM_TEX_RECLAIM_LOW_MB (384 by
default) it asks for a reclaim pass, since the system gives no notice before it kills a process.
Hades II's profile turns it on.

Co-Authored-By: Claude Code <[email protected]>
@Jpkovas

Jpkovas commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Follow-up to the LM3 distinction in this description: #111 now carries a separate, default-off draft that physically shares eligible compressible render-image aliases through placement heaps. It targets repeated resolution descriptors at the same NVN pool/offset/format/size class; it does not release guest source pages or renew their mappings.

The synthetic regression passes 659 checks with normal encoding and another 659 with deferred encoding, including literal GPU pixels, indirect Metal4 access with heap-only residency, depth/stencil, pool separation and contiguous-virtual/sparse exclusion. The bounded LM3 iPhone result and its limits are recorded in #100. This still needs broader alias/lifetime review and is not presented as a generally safe default.

The ACNH Mac route did not show a memory reduction; no benefit to Hades II or from combining this with pool_renew/tex_reclaim is claimed. The two approaches address different allocations, and I have not tested them together. No game assets, private traces or saves are included.

@seedds

seedds commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Thanks for measuring the memory savings. They are substantial, but I can’t accept the static-source reclaim approach as implemented. No writes since upload and an idle period do not establish that the guest will never read or reuse those bytes. The reclaim replaces them with zero pages, and rc_unreclaim_pool() recreates the Metal buffer without restoring the original contents. Suppressing subsequent texture uploads also cannot preserve the semantics of later guest reads or partial writes.
The separate pool-renew feature preserves contents, but the reported 6 MB saving does not currently justify the added machinery and GPU waits. I’m closing this PR. A future proposal should preserve guest-visible contents, either through a reliable restoration mechanism or evidence that the guest has actually released the storage.

@seedds seedds closed this Oct 24, 2026
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
…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
…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.
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.

3 participants