Skip to content

nvn: merge contiguous gmem pool runs and harden MTL4Archive pipeline loading - #1730

Open
ksolenk38ze wants to merge 1 commit into
seedds:mainfrom
ksolenk38ze:pr/nvn-gmem-runs-and-pso-archive
Open

ksolenk38ze wants to merge 1 commit into
seedds:mainfrom
ksolenk38ze:pr/nvn-gmem-runs-and-pso-archive

Conversation

@ksolenk38ze

@ksolenk38ze ksolenk38ze commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

What and why

  1. Contiguous gmem pool run merging: Shaders that access guest memory through raw 64-bit pointers search the gmem pool table (pool_gpu_raw) by (guest_va, len, gpu_va). When a game allocates many adjacent NVN memory pools inside one virtual reservation, the gmem table grows and its binary search deepens. Merging contiguous (lo, hi) pool ranges whose Metal gpuAddress values are equally contiguous compresses adjacent runs into a single entry without altering address translation.
  2. Pulling-base MTL4Archive retention and zero-length slice guard: When dm_pso_prewarm builds vertex-pulling base render pipelines (pull=1) into a .mtl4a archive, storing only the derived state or mixing vd == 0 and vd != 0 epochs caused pulling bases to be dropped on compaction or recompiled on reload, and .mtl4a archives with a zero-length reflection slice crashed MTL4ArchiveImpl::newArchiveReplyForKey. Separating ArchEpoch by ep->kind, probing pulling bases in pso_prebuild, carrying the OP_CALL return stack across shader_prefetch_rest / pso_predict_rest_, and validating _archiveReader slices on open (arch_entries_ok) avoids startup stalls and archive crashes.
  3. Reference documentation: Adds ### Contiguous gmem pool run merging and pulling-base archive retention in docs/reference/rendering.md and updates docs/agents/symptoms.md.

Related

Checked

  • Tests: make -C dm/gfx/tests GAME=0400486024DEC000 t_pso_archive, make -C dm/gfx/tests GAME=0400486024DEC000 run, python3 dm/tools/docs_symptoms.py
  • Games run, with title ID and version: The Legend of Zelda: Ocarina of Time (0400486024DEC000, v131072, SDK 22.2.8), verified cold and warm startup with 40,154 prewarmed pipelines and 60 fps gameplay.
  • Devices and OS: Apple Silicon Mac, macOS 26.2

Docs

  • The finding is in its game note or its docs/reference/<subsystem>.md entry, and python3 dm/tools/docs_symptoms.py was run (the symptom index)
  • No game files, keys or data extracted from a game in the change or the attachments

@github-actions github-actions Bot added nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) docs Documentation labels Nov 7, 2026
…loading

Merge adjacent GPU memory pools with contiguous guest virtual addresses and
matching GPU address deltas into single gmem_map run entries (up to
GMEM_RUN_MAX = 1,024 runs) backed by a reusable MTLBuffer ring
(gmem_table_take / gmem_table_give), and reuse g_gmem_buf across encode_args_
calls within a submission since gmem_commit_patch updates the table at commit
time. Also zero-fill
unmapped virtual pool spans with PROT_READ | PROT_WRITE in vpool_map so late
CPU reads do not fault.

For MTL4Archive pipeline caches (related to PRs seedds#1307, seedds#1488, seedds#1493, seedds#1546),
separate vertex-descriptor (vd) and pulling (non-vd) archive epochs so
specialized vertex-descriptor pipelines are not written into the pulling archive
set; guard against macOS 27's crash in MTL4ArchiveImpl::newArchiveReplyForKey
when deserializing an archive entry with a zero-length function reflection
string; preserve the active OP_CALL return stack when starting
shader_prefetch_rest and pso_predict_rest_; and support falling back to the
bundled shader chain directory when DMSH_CHAIN advances.

Verified in The Legend of Zelda: Ocarina of Time (0400486024DEC000) on Apple
M-series (macOS).
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.

1 participant