Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion dm/games/040074A01BF12000/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Donkey Kong Bananza (`040074A01BF12000`)

A Switch 2 game: update v458752 over the base game, SDK 20.5.19 built for the Switch 2 (`sdk` names its spec `Ounce`), NVN2. Nintendo EPD's engine (sead / agl / gsys, Phive), modules `main` + `sdk`. **Plays on the Mac** (M4 Pro): three play sessions of about 5 minutes each and scripted runs of up to 15,900 frames, through the opening, the mining tunnel and the areas after it, with the guide movies in their panel, at 60 fps; in busy scenes the game drops itself to 30 fps for a few seconds ([Open](#open)). The first start with no pipeline archive builds the pipelines for about 4 minutes, once. The Mac tests cover only the first level's opening areas. See the [community iOS reports](#ios-community-report) for iPhone 18 Pro and M4 iPad Pro testing.
A Switch 2 game: update v458752 over the base game, SDK 20.5.19 built for the Switch 2 (`sdk` names its spec `Ounce`), NVN2. Nintendo EPD's engine (sead / agl / gsys, Phive), modules `main` + `sdk`. **Plays on the Mac** (M4 Pro): three play sessions of about 5 minutes each and scripted runs of up to 15,900 frames, through the opening, the mining tunnel and the areas after it, with the guide movies in their panel, at 60 fps; in busy scenes the game drops itself to 30 fps for a few seconds ([Open](#open)). The first start with no pipeline archive builds the pipelines for about 4 minutes, once. The Mac tests cover only the first level's opening areas. See the [community iOS reports](#ios-community-report) for iPhone 18 Pro and M4 iPad Pro testing. The update also runs a saved gameplay spot on an iPhone 17 Pro Max; what was measured there, and what was not, is in [iPhone measurements](#iphone-measurements).

## iOS community report

Expand Down Expand Up @@ -90,6 +90,22 @@ Each step below stopped the boot before its fix:
5. Switch 2 SDK calls through services the host does not serve: `hid::InitializeJcms` and the Joy-Con mouse sensor (`hle_hid.c`), `oe::GetCurrentGraphicsScale` (`hle_oe.c`), `audio::IsDeviceOutputVolumeAutoTuneModeEnabled` (`hle_audren.c`), `streamplay` (GameShare, `hle_misc.c`), `vi` HDR / VRR / extended swap interval (`dm/gfx/hle_vi.c`).
6. `nv::InitCheck` (from `main+0xe19d04`, the start of a video decoder, after the first punch) tested the SDK's own flag, which `nv::InitializeGraphics` sets and the host's version of it does not: `hle_nv.c` answers it from the host's record. The same function then starts a video decoder: the Switch 2's `nn::codec` video API and sync point events, served on the host ([`nn::codec` video decoders taken over](../../../docs/reference/movies.md#nncodec-video-decoders-taken-over)).

## iPhone measurements

All of this was measured on one physical iPhone 17 Pro Max (A19 Pro GPU, iOS 27.2) with update v458752, from the title screen through Continue into the saved level and then a scripted 70-second route of jumping, movement and attacks. The logs are the app's `log.txt` and `memstat.tsv`. The runs used local builds that carried changes not on `main`, so the numbers say what the game did on the phone, not what `main` does. Features named below that are not on `main` are marked with their PR.

**Scene size and the upscaler.** Docked (`DM_OPMODE=1`), `DM_UPSCALER=metalfx`, `DM_PSO_MTL4=1`, `DM_NVN_GPU_TS=submission` and shader chain `95ba69b5403e`: the log shows the MetalFX spatial scaler at 1676×943 → 2304×1296 (`upscaler: MetalFX spatial scaler (HDR) 1676x943 → 2304x1296`, after an earlier 1536×864 one), and the game's passes in that run are 1676×943. The player judged gameplay sharper than with the game's own NDSR upscaler in the same docked mode, and still saw jagged edges. That is a subjective comparison, not a measured antialiasing gain. Depth is present, but the game's motion vectors and camera jitter have not been established, so no MetalFX Temporal replacement is possible yet. The handheld mode (`DM_OPMODE=0`) scaled 1397×786 → 1920×1080 in a later run.

**The window.** The game still owns a 2880×1620 window (`WindowInitialize` says `first 2880x1620`) that the host presents into a 2346×1320 drawable. The game's last pass samples the 2304×1296 scene into that window with fragment shader `e9c6f339b7550c71_b`; the vertex shader is `a6430615519b0e2f`, and a diagnostic logged its position attribute as format 41 (read as RGBA16F) and index type 0 (read as unsigned bytes). The drawable size is the logged `present dimensions` line (PR #1136), and PNGs captured from the drawable (PR #1136) measured 2346×1320; a screenshot with a changed `DM_NVN_SHOT_OUT` size is not evidence of the drawable's size. Drawing that last pass at the drawable's size (PR #1140) is a separate, experimental change; in that build 16 consecutive 300-frame windows (frames 20100–24600) held p99 33.34 ms with no drops at thermal state 1. The size log line `upscaler: size at frame …` is PR #1167.

**Where the GPU time goes.** With `DM_NVN_GPUPROF=every:60` in the window-copy build, 33 sampled frames of a 70-second route at thermal state 2 had a median summed encoder time of 27.38 ms and a first-to-last span of 30.26 ms. The summed times come from relaxed timestamps, so they are not exclusive GPU utilization, and MetalFX's own encoders are not instrumented. In the five samples at frames 7920–8160 the eight 1676×943 three-colour scene passes took about 13.0 ms of that, and the 2346×1320 final draw about 0.39 ms. All 33 samples had 1676×943 scene targets, but a sample every 60 frames cannot show that no frame changed size. In that route the game briefly chose present interval 3 (20 fps) and went back to 2 (windows 8700 and 9000 had p99 50 ms).

**Combined local build, shader chain `215a6d278114`.** A build with the border-colour shader split (PRs #1032 and #1203, unmerged), mesh runs and the window copy (PR #1140) completed the same 70-second route. Its six complete 300-frame windows (frames 9600–11400) held p99 33.34 ms with no drops or discards at thermal state 0. The scaler logged 1676×943 → 2304×1296 at frame 4847, with no later size line; the drawable was 2346×1320. The memory report ended at 5131 MiB footprint with 3060 MiB headroom. The bundled A19 Pro Metal 4 pipeline archive opened and 16 of 16 probed bases were found. One early audio callback timeout (209 ms) was logged. This run does not isolate the shader split's effect: the mesh-only run before it was at thermal state 1 (five windows, four at 33.34 ms and one at 58.34 ms), and the views were not pixel matched.

**Handheld.** The same binary in handheld mode ran 1397×786 → 1920×1080, and all six complete windows were 33.34 ms p99. Back in docked mode at thermal state 1, five windows gave three at 50 ms p99 and two at 33.34 ms, with one dropped frame. A cooler run that succeeds therefore says nothing about 30 fps after the phone warms up. Docked is the sharper setting tried, and no setting has a solved frame rate.

**Not established.** Sustained 30 fps under heat; every-dispatch scene-size coverage; a handheld frame rate above 30 fps (the handheld runs above stayed at 33.34 ms); and any improvement to the fur's shimmer: the logs show no change in it, so it stays open. No run above used a build of `main` as it stands.

## Open

- **Video decoding:** the guide movies are VP9 and play (a 180-picture clip on loop in the tutorial's panel, read back as NV12). The player also imports the VP8, H.264 and AV1 decoders: VP8 and H.264 are served too (checked by `t_codec_video` only), AV1 is not ([`nn::codec` video decoders taken over](../../../docs/reference/movies.md#nncodec-video-decoders-taken-over)).
Expand All @@ -107,6 +123,7 @@ Each step below stopped the boot before its fix:
- **Frame drops on Sublayer 1200 (Mac, found 2026-11-21, resolved 2026-11-22):** in a 106,000-frame session, 53 of the 300-frame windows dropped 10-81 frames (47-58 fps) and 172 dropped at most one. The slow windows drew about 1,175 geometry draws a frame through the compute path (up to 2,300; about 300 in the good ones), with GPU p50 / p95 13.8 / 17.3 ms against 10.7 / 12.7 and submission p50 / p95 7.7 / 11.0 ms against 4.0 / 4.9; no pipeline or library creation, texture upload or thermal limit in any of them. Every one of those draws was `no mesh library`: vertex `2550852980a24249` (`SilverStarMaterial` var28; 275 windows) or `b84459700ab292a9` (var18; 8 windows) with kernel `5d537f7630ec3671`, pairs no recording had reached. Fix (resolved): the split names every vertex / geometry pair of a variation (`geo_pairs.tsv`), so all of them get mesh libraries ([Passthrough geometry shaders drawn by the vertex shader](../../../docs/reference/shaders.md#passthrough-geometry-shaders-drawn-by-the-vertex-shader)). With it (Mac, 2026-11-22, a 132,000-frame session through Sublayer 1200, on an intermediate chain `35fc22a338b6` whose build had 11 of the 31 pair libraries: all 10 with kernel `5d537f7630ec3671`, which every geometry draw there used): no geometry draw through the compute path in any window (833 mesh draws a frame in the busy windows, in about one dispatch a window's frame), windows with 10 or more dropped frames 15% → 2% (1,817 → 546 dropped frames in all), and in windows of more than 5,000 draws 33% → 12%, with submission p50 / p95 7.5 / 9.6 → 6.3 / 7.6 ms. The two routes differ (147 such windows then, 26 now). No `[RED]` line in the session.
- The NVN2 device values the driver reads from the GPU at run time (17 items: scratch scale factors, L2 size, texture layers and sizes, linear stride alignment, pool page size, …) are still the Switch 1 ones; the constant ones are NVN2's ([The Switch 2's device values](../../../docs/reference/nvn-objects.md#the-switch-2s-device-values)).
- iOS validation on current main and broader device coverage remain open. See the [community reports](#ios-community-report).
- iPhone: sustained frame rate and the fur's shimmer are open ([iPhone measurements](#iphone-measurements)).

## Found on this game

Expand Down
1 change: 1 addition & 0 deletions docs/agents/symptoms.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ One line per symptom in the [subsystem references](../reference/): what you see
- graphics memory stays above the earlier steady state after frame-wide command allocator sharing, with many mostly empty 4 MB arena blocks retained. → [Per-frame arena blocks made for every submission in flight](../reference/memory.md#per-frame-arena-blocks-made-for-every-submission-in-flight)
- GPU memory grows with repeated `nvnTextureReadTexels` calls on a long-lived game thread, even after each readback completes. → [GPU readback without an autorelease pool](../reference/memory.md#gpu-readback-without-an-autorelease-pool)
- process footprint and Metal allocation grow during stationary gameplay even after readback fences complete; the deferred-release queue and command allocator sizes remain bounded. → [Completion readbacks survive a guest waiter's pool](../reference/memory.md#completion-readbacks-survive-a-guest-waiters-pool)
- the game plays its menu and movies, then at the first 3D load `GPU allocated` jumps by about 5 GB. The log has `[RED] GPU out of memory`, then a GPU page fault and `kIOGPUCommandBufferCallbackErrorSubmissionsIgnored`. The game keeps running with audio and a black screen, because every later submission is refused. Without guest files (`DM_GUEST_FILE`), the same load can instead end in a Jetsam report with reason `vm-pageshortage` on nearly every process. → [A Switch 2 game's first 3D load on an iPhone](../reference/memory.md#a-switch-2-games-first-3d-load-on-an-iphone)
- `footprint` shows `Malloc Large` about the size of `pso_archive/` (the log's `pipeline archive …: N files, … MB`), resident or swapped for the whole run. `MallocStackLogging=1` with `malloc_history <pid> -allBySize` gives `newArchiveWithURL` → `MTL4ArchiveImpl::loadFromURL` → `LoaderGlobalState::loadFile` → `-[NSData initWithContentsOfFile:options:maxLength:error:]` → malloc. → [A pipeline archive on an external drive is read into memory](../reference/memory.md#a-pipeline-archive-on-an-external-drive-is-read-into-memory)
- a save load aborts in `pthread_create` or a host `realloc` with the footprint far below the memory limit; turning off Metal 4 pipelines lets the save load. The crash's address-space census, rather than the footprint alone, distinguishes this from the physical-memory limit. → [Pipeline archives exhaust a restricted task map](../reference/memory.md#pipeline-archives-exhaust-a-restricted-task-map)
- startup's `Preparing shaders` aborts after many `failed to load shader ... mmap failed` lines, or an on-demand render-pipeline allocation later aborts with `NSMallocException`, despite a low physical footprint. Turning off Metal 4 and pipeline prebuild does not disable manifest prewarm; `DM_PSO_MANIFEST=off` skips startup's list but the reported game still aborted after about 27 minutes. → [Shader library mappings exhaust a restricted task map](../reference/memory.md#shader-library-mappings-exhaust-a-restricted-task-map)
Expand Down
8 changes: 8 additions & 0 deletions docs/reference/memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,14 @@ The guest address space, heaps, pools, virtual address memory and the allocators
- **Check:** `make -C dm/gfx/tests GAME=<id> check_t_readback` (`store_completion`) gates real GPU feedback and exercises both `DM_NVN_FAST_WAKE=1` guest-owned completion and `0` callback-owned completion, with the guest waiter's outer pool open throughout. It checks literal copied pixels in the storage and event visibility at a successful wait, and delayed-feedback idempotence. Its buffer-lifetime assertion went with the readback into storage (2026-11-10, now [stored on the GPU](nvn-objects.md#gpu-textures-in-storage-the-cpu-can-read)), whose landed buffer it watched; the pool still covers the visibility buffers `post_run` reads, which no test watches.
- **Found on:** [Tears of the Kingdom](../../dm/games/0100F2C0115B6000/README.md#memory), M2 Pro stationary cave route. A bounded paired diagnostic on chain `d1043b780a74` showed footprint growth of 617 MiB over about 86 seconds without the pool versus 1 MiB over about 83 seconds with it. This is route-local memory evidence, not an FPS improvement, complete allocation census or verified fix for an iPhone termination.

### A Switch 2 game's first 3D load on an iPhone

- **Symptom:** the game plays its menu and movies, then at the first 3D load `GPU allocated` jumps by about 5 GB. The log has `[RED] GPU out of memory`, then a GPU page fault and `kIOGPUCommandBufferCallbackErrorSubmissionsIgnored`. The game keeps running with audio and a black screen, because every later submission is refused. Without guest files (`DM_GUEST_FILE`), the same load can instead end in a Jetsam report with reason `vm-pageshortage` on nearly every process.
- **Cause:** the first raw global memory table makes every memory pool resident at once, and that charges each zero-copy buffer's whole length to the GPU. Measured on the failing run: 8,163 MB in the residency set against 8,192 MB of `recommendedMaxWorkingSetSize`, with 5,793 MB of shared buffers (2,432 MB of it the alias region pool as one buffer) and 1,973 MB of textures. The error came just under the recommended size, so that value is not an exact limit. The three kernel memory entitlements did not raise it.
- **Status:** the failing run is from before the pool fixes below, and later Duo runs did not reach the wall again. Main now leaves the [shader-code pools](#shader-code-pools-wired-by-the-raw-pool-table) (PR #1971) and the [GPU-only render-target pool](#gpu-only-render-target-physical-pool-wired-whole-by-texture-addresses-and-small-lookups) (PR #2566) out of the raw pool table, and the runs of 2026-11-07 to 11-10 in [the game note](../../dm/games/0400486024DEC000/README.md) (with a build from main `04811a63`) played through the first 3D load; which change removed the wall on the Duo was not isolated. On the failing run, guest files took the footprint during a movie from about 4,700 to 555 MB, and the load then got further, but they do not change what the residency set charges, and they added 60 to 80 ms frames during movies. A smaller application pool (the cap of PR #1104) does not help this game: its heap request falls with the pool, and caps of 7 and 8.5 GB both crashed at boot. The remaining work then was to charge less for each pool and to stop [holding textures twice](https://github.com/seedds/nxnative/issues/1281).
- **Check:** `res_top`'s `GPU out of memory` line gives the totals by kind and the largest objects. Read the `reason` of the Jetsam report, because a process limit and a system-wide page shortage need different fixes.
- **Found on:** The Legend of Zelda: Ocarina of Time (`0400486024DEC000`, v131072), iPhone Duo (iPhone19,4), iOS 27.3, docked, with PRs #1299, #1300 and #1312 (since closed) applied.

### A pipeline archive on an external drive is read into memory

- **Symptom:** `footprint` shows `Malloc Large` about the size of `pso_archive/` (the log's `pipeline archive …: N files, … MB`), resident or swapped for the whole run. `MallocStackLogging=1` with `malloc_history <pid> -allBySize` gives `newArchiveWithURL` → `MTL4ArchiveImpl::loadFromURL` → `LoaderGlobalState::loadFile` → `-[NSData initWithContentsOfFile:options:maxLength:error:]` → malloc.
Expand Down