mirror of
https://github.com/seedds/nxnative.git
synced 2026-11-23 11:39:42 -10:00
Compile and archive format-unspecialized Metal 4 mesh pipeline bases (task + mesh + pixel), specialize them across attachment/blend/depth states at draw time, proactively prefetch them on NVN program creation, and prebuild static (task, mesh, pixel) triples offline and on device via mesh_pairs.tsv. - Reflection & chain: mark mesh shaders that emit per-primitive outputs with mesh_stage.prim in dmsh_meshstage.py / dmsh_build.py and bump DMSH_CHAIN to 3fe2e3787fdf. - Host Metal 4 mesh bases (nvn_geometry.inc, nvn_mtl.m): build, deduplicate, archive, compact, and specialize Metal 4 mesh bases (preserving mtk_spill payload clamping and tagging dm_mesh_nop); fall back to whole pipelines for mesh_stage.prim and reads_prim_id as a workaround for an Apple Metal 4 compiler/driver bug (verified on Apple M6, macOS 27.2.1 / Metal 32023.922) that non-deterministically zeroes per-primitive outputs and [[primitive_id]] on specialized mesh bases; skip recording M manifest rows when a base hits archive; prefetch mesh bases from mtl_prog_prefetch() on a bounded background queue (DM_NVN_MESH_PREFETCH=0 disables). - Static mesh triples & prebuild (shader_split.py, pso_offline.py, pack_app.py, build_ipa_from_nsp.py, build_ipa.sh, regress.py, nvn_mtl.m): emit mesh_pairs.tsv (M\t<task or ->\t<mesh>\t<pixel or ->), compile eligible mesh bases into MTL4Archive via metal-tt, route depth-only / non-default-constant triples to rest_pairs.tsv, and load mesh_pairs.tsv / DM_MESH_PAIRS in pso_prebuild(). - Tests & docs: extend t_pso_archive, t_pso_bundle, test_pso_offline, test_dmsh_meshstage, test_dmsh_pairs, and test_nsp_incremental; update env_switches.tsv, docs/reference/shaders.md, and Ocarina of Time's note. Checked: Mac host build, Metal 4 GPU tests (t_pso_archive 441/441 + 15/15 restarts, t_pso_bundle 118/118, t_mesh_first_use, t_pso_stall 124/124), Python suites (test_pso_offline, test_nsp_incremental, test_nsp_mac_app, test_docs, test_env_switches, test_nsp_chain, test_game_profile, test_dmsh_pairs, test_dmsh_meshstage prim checks), regress.py on Fast Fusion (PASS), and regress.py + 3-way cold-start A/B/C on Ocarina of Time (mesh stall 15,847.5 ms -> 6,056.4 ms with prefetch -> 2.6 ms with offline mesh bundle). Front-ends: break: shader libraries must be rebuilt for chain 3fe2e3787fdf. Co-authored-by: Eric Schaal <[email protected]>