Skip to content

Retire obsolete NVN chunks after whole-pool mapping - #1417

Open
givethesourceplox wants to merge 1 commit into
seedds:mainfrom
givethesourceplox:fix/nvn-superseded-pool-mappings
Open

givethesourceplox wants to merge 1 commit into
seedds:mainfrom
givethesourceplox:fix/nvn-superseded-pool-mappings

Conversation

@givethesourceplox

Copy link
Copy Markdown
Contributor

What and why

Raw-address shaders require a contiguous mapping of each large NVN pool. gmem_map_gpu creates that mapping but leaves older overlapping chunk buffers, plus their replaced versions, alive and resident until the parent pool is destroyed.

After successful whole-map creation, remove the obsolete chunk entries and retire their buffers through the existing fence-deferred release. Repair swapped pool entries' indices and invalidate address caches. A failed whole-map allocation leaves existing chunks intact. The whole-pool mapping and its GPU addresses remain authoritative.

Reference finding. Found during Ocarina's scene-load investigation (#1299). This complements #1319's replacement-chunk retirement; it does not copy its threshold, reuse or raw-residency policies. The SDK-26 declaration shim matches #1404's build prerequisite for existing OS-27-guarded MetalFX setters.

Checked

Apple M1 Pro, macOS 26.5.2, Xcode 26.5:

  • t_pool_retire: 40 checks pass with Metal API validation. Covers two large pools, a separate small pool, lengthened chunks, whole-map consolidation, repaired swapped indices, shared-storage lookups, retirement only after the submitted fence, a GPU data copy from the surviving mapping, and parent teardown.
  • Documentation tests: 11 pass; chain tests: 17 pass; git diff --check passes.
  • LLVM static analysis: no new findings.
  • No shader chain/profile inputs changed; no game shader rebuild.

The fixture proves buffer lifetime and mapping behavior, not an isolated game-memory, FPS or thermal saving. No standalone game or iPhone run is claimed for this branch. The local harness finds only DK, MKW and Ocarina, with no stored baselines and no DK/Ocarina smoke routes on this base; no five-game regression report is available.

Docs

  • Reference finding added and symptom index regenerated.
  • Shader chain unchanged.
  • No game files, keys or extracted data included.

@github-actions github-actions Bot added nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) docs Documentation labels Nov 5, 2026
fpedrolucas95 pushed a commit to fpedrolucas95/nxnative that referenced this pull request Nov 6, 2026
… whole-pool mapping

# Conflicts:
#	dm/gfx/nvn/nvn_mtl.m
#	dm/gfx/tests/Makefile
#	docs/agents/symptoms.md
#	docs/reference/nvn-objects.md
fpedrolucas95 pushed a commit to fpedrolucas95/nxnative that referenced this pull request Nov 6, 2026
…mark the pools a buffer address was taken in

seedds#1394's table lists only the pools the game took a buffer address in, so the tests that make pools for the raw table (t_pool_chunks's 5,000 pools, t_gmem_raw's,
seedds#1417's t_pool_retire) mark them as nvnMemoryPoolGetBufferAddress would; seedds#1394's and seedds#1417's tests call gmem_map(), which replaced gmem_map_gpu() here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AnkMister added a commit to AnkMister/nxnative that referenced this pull request Nov 6, 2026
Revised brief: keep only PR seedds#1434 (9eeacbb), seedds#1332 (7f5f2fc), seedds#1417 (1c1d453), and seedds#1428 (f537147). Remove all other prior ports and their follow-ups while preserving published history. Other glass and Mac agents own those items. Update the scoped report and references; exclude disabled SDK hooks from hit diagnostics.

Python tools match the baseline failure set; 12 docs/environment checks pass. Portable SDK gate and diagnostic checks pass GCC ASan/UBSan. Mac and Metal checks remain open.
Aeonitis pushed a commit to Aeonitis/nxnative that referenced this pull request Nov 6, 2026
…er and shader chain, the branch's host services, movie clock, packing and Ocarina of Time additions

Upstream reached about 60 fps in Kokiri Forest with its own versions of most of the branch's merged PRs, so where both changed the same code upstream's is kept:
- The shader chain is upstream's (translator, lock, dmsh tools, Ryujinx sources), plus the branch's bracket-depth flattening (dmsh_depth.py, test_dmsh_depth.py); chain c732699d4fdb.
  Not carried: the LDSM subgroup fence (seedds#1376, needs a translator rebuild; upstream's HMMA/LDSM rework reports clean movies) and the shared raw-memory lookups (seedds#1405, superseded by upstream's last-entry lookups).
- The renderer (dm/gfx/nvn, dm/gfx/msl) and its tests are upstream's. Not carried: seedds#1390-seedds#1394, seedds#1404, seedds#1408, seedds#1409, seedds#1417, seedds#1418, seedds#1420, seedds#1427, seedds#1320, seedds#1331, seedds#1332, seedds#1368, seedds#1285 renderer parts, pool_skip_retired, and the branch's warning fixes and prewarm progress there. They stay on oot-integration.
- Ocarina of Time's profile is upstream's, with the branch's 12 movie compute rows in pso_manifest.tsv, PLAN.md and PR-AUDIT.md.
- shader_split.py is upstream's plus the BAHS record check (test_split_bahs_records.py).
- Host: upstream's EventFd, PlayReport send, audio lock and vibration answers; the branch's service sessions (hle_sf, hle_prepo), sync waits, AV1 movie clock and parallel decode, diag_abort frame fix and focus control are kept.
- Scripts: shader.noindex, tmp.noindex, notes outside the shader key, bench and regress changes.

Checked: the Mac host builds (GAME=0400486024DEC000); host unit tests pass; the Python tool tests pass on Python 3.13 except test_dmsh_pool_arrays, test_nro_pack, test_nsp_dump and test_nsp_incremental, which fail on upstream main as well. Not run: the full shader build on this chain, gameplay.
@nafields

nafields commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Data from Ocarina of Time (Switch 2, 0400486024DEC000, v131072), M2 Pro 16 GB, with this PR ported onto a tree with #1484, #1391/#1482, the render-target reclaim (#1588) and #1607:

cfryerdev pushed a commit to cfryerdev/nxnative that referenced this pull request Nov 8, 2026
…ures (seedds#1404)" and "Retire obsolete NVN chunks after whole-pool mapping (seedds#1417)"

They tank Ocarina of Time's submit thread: on the same route and save,
the host with them ran 12.4 fps with the submit thread at 56-78 ms CPU
(73-78 ms wall), and without them 58.6-59.1 fps with the GPU at 12 ms.
seedds#1393's pool_skip_retired stays (it is not implicated, and it fixes the
scene-change OOM); seedds#1394's bitmap stays reverted in favour of upstream's
address table.
@FifteenPen

Copy link
Copy Markdown
Contributor

big_full: [g_keep removeObject:p->buf]; defer_obj_release(p->buf);. p->buf is unretained, and when g_keep holds the chunk's last reference, the removal frees it before defer_obj_release touches it.

On our tree (with this PR's code merged), Ocarina of Time in Hyrule Castle Town, with its large pools in chunks, hit it. t_pool_chunks under NSZombieEnabled=YES reproduces it. Taking a strong reference first fixes it:

id<MTLBuffer> ob = p->buf; [g_keep removeObject:ob]; defer_obj_release(ob);   // strong first: p->buf is unretained, and g_keep may hold its last reference

The same pattern is in the retire loop (g_pools[i].buf).

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.

4 participants