Skip to content

DM_NVN_POOLPEAK: how full a game's render target pool gets - #303

Open
v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:pool-peak
Open

v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:pool-peak

Conversation

@v0lumehi

@v0lumehi v0lumehi commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Update (2026-10-27): rebased on main 75065df (only the gfx tests' run list and .gitignore conflicted). t_poolpeak (13 checks), the env and docs tests and the BotW host build pass. Thanks @Xipzer for the iPad numbers above.

A diagnostic for how much of a large memory pool textures take

Some games sub-allocate every render target from one large memory pool and crash when it runs out. Breath of the Wild does this with gsys's 115 MB render buffer pool: at a 2560x1440 output (with the MetalFX scene upscale, not yet a PR) its inventory crashed in RenderBufferContext. The host had no way to see how close a scene came to that limit. The highest offset in use says little, because the game allocates from both ends of the pool.

DM_NVN_POOLPEAK=<MB> watches every memory pool of at least that size. In nvnTextureInitialize, it records which 64 KB pages of the pool textures have ever been placed on. Each time that set grows, it logs one line:

[nvn] pool peak: pool <address> (<size> MB): <used> MB of it used so far, largest range never used <gap> MB (ser=<serial> <w>x<h> format <format> at <offset>)

It's off by default and costs nothing unless it's set.

  • The page set. It lives in dm/gfx/nvn/nvn_poolpeak.h, a pure-C header with no host state: mark a range, count new pages, find the largest unused run.
  • The hook. hle_nvn.c calls the header for up to 8 pools.
  • The docs. docs/agents/04-graphics.md lists the switch with the other DM_NVN_* diagnostics.

Measured (Breath of the Wild 1.9.0, M2 Max, inventory, map and System menu opened)

Output Used of the 115 MB render buffer pool
1920x1080 78.8 MB
2346x1320 107.1 MB

Checked

  • t_poolpeak (new, in the gfx run list, 13 checks):
    • a page marked only once
    • a texture across a page boundary
    • allocations from both ends of the pool
    • a range split in the middle
    • nothing marked past the pool's end
    • a pool of 1.5 pages
  • ci.sh (host tests, CPU gfx tests, every gfx test built, dmhost for three profiles, the iOS compile check, the tool tests): no failures.
  • dmhost for Breath of the Wild, its iOS compile check, and t_nvn (154 checks).

@Xipzer

Xipzer commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

First iOS numbers for this, and they pin down a limit we had only guessed at.

iPad Pro 13" M4, Breath of the Wild 1.9.0, DM_NVN_POOLPEAK=64, docked, render scale 1.40, MetalFX on at 2.0 output, open world play with the inventory and map opened:

Pool Size Peak used Largest run never used
0x70c389f088 115.0 MB 112.8 MB (98.1%) 2.2 MB
0x70ba1d1be0 500.0 MB 256.0 MB (51.2%) 244.0 MB

The 115 MB render buffer pool is 2.2 MB from full.

That matches a crash we had already found by bisecting render scale on this device: 1.40 plays, 1.45 dies with SIGSEGV at main+0xed7128, address 0x20, while the field loads. That is RenderBufferContext taking a null back from a failed allocation, the same site you hit at 2560x1440 on the M2 Max. So the "about 1.3" in the docs can become a measured number, and your diagnostic is what turns a crash report into a capacity figure.

It also settles a review point on my #316: a render scale slider that reaches 2.0 can crash the game, and a per-profile render_scale_max is the right answer. This gives Breath of the Wild's value a basis rather than a guess.

Worth noting for anyone reading the numbers: the second pool is half empty with a 244 MB contiguous run free, so the pressure is specific to the render buffer pool rather than general.

Ran against an older main with this PR's nvn_poolpeak.h and hle_nvn.c hook applied by hand; the hook needed no change, it dropped straight in.

@v0lumehi

Copy link
Copy Markdown
Contributor Author

@Xipzer thanks! I'll check your comment later in detail

@v0lumehi

Copy link
Copy Markdown
Contributor Author

@Xipzer looks like this diagnostic flag actually helps to find issues like this. Thanks for checking! Is there an issue already for the TotK you mentioned?

…size, a line each time textures are first placed on more of the pool's 64 KB pages, with the largest range never used: how full a game's render target pool gets, also when it allocates from both ends. Breath of the Wild's 115 MB render buffer pool with the inventory, map and System menu opened: 78.8 MB used at a 1920x1080 output, 107.1 MB at 2346x1320

The page set is in nvn_poolpeak.h (pure C), which hle_nvn.c's nvnTextureInitialize fills; t_poolpeak.c checks it (pages marked once, a texture across a page boundary, both ends of the pool, a range split in the middle, nothing past the pool's end, a pool of 1.5 pages). docs/agents/04-graphics.md lists the switch.
@Xipzer

Xipzer commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

No TotK issue yet, and I don't think I mentioned one here, so I may be missing which report you mean. If it's the render pool question: I haven't run DM_NVN_POOLPEAK on TotK. I can run it on the iPad and open an issue with the figures if they show the same pressure.

Xipzer added a commit to Xipzer/nxnative that referenced this pull request Oct 30, 2026
The ceiling is what the platform can reserve, not which platform it is. iOS caps one reservation at
6 GB (hle_svc.c), and the pool's growth comes on top of the game's mem_reserve, so render_pool_max takes
the highest factor whose RESERVE fits. Breath of the Wild reserves 4 GB: every factor to 3.0 fits
(5.92 GB at 3.0). Measured on an iPad Pro 13" M4: 1.40 plays with the pool doubled (180 MB more), where
it crashed at 1.45 without the growth (seedds#303).
Xipzer pushed a commit to Xipzer/nxnative that referenced this pull request Nov 1, 2026
The clamp in the loader was 0.5 to 1.0 for every game, so a build whose rewriter
table has RENDER_SCALE could never render above the size the game picks itself,
even where it holds.

Above its own resolution a game renders into render target pools it sized for
that resolution, which the host cannot size from outside, so a scene eventually
needs more than a pool holds and the game takes a null allocation back. How far
that goes is per game and only measurement finds it, so the limit belongs in the
profile rather than in the host.

render_scale_max, 1.0 by default, is the highest DM_RENDER_SCALE the game
survives. The loader refuses anything above it and names the key in the message,
and the iOS launcher's slider stops there, because a slider that can crash a game
is not a setting. A range in settings.tsv may now take a bound from a
DM_GAME_<NAME> macro, which is how the slider learns the ceiling.

Breath of the Wild 1.9.0 is 1.35, measured rather than guessed. gsys
sub-allocates every render target from one 115 MB render buffer pool it sizes at
start. With seedds#303's DM_NVN_POOLPEAK on an iPad Pro 13" M4, docked, open world with
the inventory and map opened:

  render scale 1.40   112.8 MB of 115.0 MB used (98.1%), plays
  render scale 1.45   SIGSEGV at main+0xed7128 address 0x20 while the field
                      loads: gsys::RenderBufferContext takes a null back

1.40 is 2.2 MB from full, so the ceiling is the step below it.

No behaviour changes for any game that does not set the key: the default of 1.0
gives the clamp and the slider exactly the range they had.
@github-actions github-actions Bot added nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) docs Documentation labels Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants