Repository navigation
Conversation
Umbrella plan for the deep performance work: measured baseline (GPU-bound, draw/pass-bound; 51 fps real with DRS on the M2, 60 displayed via MetalFX), and six ranked workstreams with acceptance criteria - W1 mesh stage at 64/128 threads per threadgroup (bench -71 % on M2, PoC in ly05010419#2391 with the crash-repro), W2 render distance/LOD rows, W3 shadow resolution row, W4 compute-encoder merging, W5 texture pre-warm against load spikes, W6 CPU headroom for high-refresh Macs. Testing rules per CONTRIBUTING.
…tride), M2 mesh limits (256 verts / 32 KB per threadgroup) The real mesh body parallelizes over one 32-lane SIMD group per instance and hardcodes the 32-lane stride, so extra threads duplicate lane ids and race (the SIGSEGV). Metal caps at 256 vertices / 32 KB mesh per threadgroup on the M2, so one 128-vertex instance per group is the only option; the fix is flattening the lane id in the translator IR (<<5 -> <<6/<<7, subgroup masks per 32 lanes) behind TOTK_MESH_THREADS_SCALE, validated per shader by probe-gpu-mesh + screenshot equality vs the 32-thread build.
…45.6 ms at 32/64/128 threads vs lid-strided 13.6 ms at 128
nvnTexturePoolRegisterTexture queues sampled 2D texture slots (>= the min size); the submit thread drains the queue at the start of every submission with a per-submission byte budget (full budget during registration bursts), uploading through the same first-bind path (tex_mtl_p/pkg_upload) on the same thread. Measured on the M2: 27k+ textures / 29 GB pre-uploaded, fps unchanged (50.0 vs 50.6), area-entry spike 681 -> 586 ms; the entry-frame remainder is registered+bound in the same frames and partly CPU-side. Off by default (OOT_TEX_PREWARM=1); OOT_TEX_PREWARM_MB / OOT_TEX_PREWARM_MIN_KB tune it.
|
W5 (texture pre-warm) is implemented on this branch, opt-in ( |
…and the re-creation churn finding The 1000x1000 shadow atlas size is read from a config struct's u16 fields (+0x48/0x4a/0x4c) by main+0x244bb8 (SetWidth/Height/Depth thunk calls); the struct arrives as x0 via indirect dispatch. The atlas is re-created ~1.3x/frame, so HLE-level scaling causes re-upload churn and measured worse (44.5 vs 50.6 fps). A fix must patch the size at the game's computation site so viewport, sampling and atlas layout follow.
|
W3 (shadow resolution row) investigated and blocked with leads documented in |
… default on) is worth +5 % on the M2 (48.1 -> 50.6 fps); the rest needs the conservative range analysis extended to texture/descriptor writes, probe-gated
|
W4 measured and documented: the shared compute encoder ( |
The camera far plane (parameter struct +0x138, loaded every frame at main+0x4c52ec, verified word 0xbd413a60) branches to a veneer that multiplies it by a data-page factor (cell +60), like the aspect veneer: the effects page's 渲染距离 row (25/50/75/100 %), 'flag oot_far <percent>', OOT_FAR_SCALE, graphics-far.txt. At 100 % the far plane is the game's own bit for bit (fmul by 1.0f is exact). Fewer distant draws when shortened; measured neutral in a static forest view (expected — it matters when looking across open areas). unittest 2398 OK, oot+totk build.
|
W2 (render distance for OoT) is implemented on this branch: the camera far plane (struct +0x138, loaded every frame at |
…guest JIT is 90%; at DRS the M2 is guest-CPU-bound (2.04M instr/frame, GPU busy p50 4.4 ms); TOTK_AB_SAME A/B neutral (44.0 vs 43.5 fps); no safe host win, closed as measured-no-op
|
W6 (CPU headroom) closed as measured no-op, with numbers: |
…f4 deadlocks the guest at world entry Review caught two bugs and one hard blocker: (1) the stub word 0x1e222800 is FADD not FMUL, and s2/s10 liveness was only linear-scan-verified; fixed with save/restore of d8 + fmul. (2) Even a semantically identical no-op stub (original ldr + branch back) at stub offsets +372/+400/+2000, and a variant branching at the store main+0x4c52f4, all hang the game at world entry (~frame 680) while main / W5-only builds and the aspect veneer at main+0x4c5334 in the same loop run fine — the game depends on that exact code. W2 code reverted (measured neutral in a static view anyway); the doc records the evidence and the next step (scale at the +0x138 writer). Also fixes the pw_enqueue lock-order comment. unittest 2398 OK, oot+totk build OK, bench after revert: 3300 frames / 40.9 fps at fixed 720p.
|
Final review pass done, PR marked ready. What changed in this pass:
Board: W5 shipped (pre-warm, opt-in, 27k tex/29 GB, spike 681→586 ms), W4 mostly shipped (+5 % measured), W1 root-caused + bench-proven (#2391), W2/W3 blocked with RE evidence, W6 measured no-op. Shippable perf (DRS default M1/M2, 60 FPS displayed) is in #2388. |
…prewarm_default); OOT_TEX_PREWARM / graphics-prewarm.txt override Measured fps-neutral and picture-identical on the M2 (default run 50.6 fps with 900 textures / 1516 MB pre-uploaded during load; forced-off run identical fps, no prewarm activity), and it removes most of the 100-680 ms area-entry spike (681 -> 586 ms measured earlier) — the visible freezes. Shared nvn_mtl.m calls a weak nvn_prewarm_default(); only OoT's runtime defines it (sysctl brand check, like the DRS default). Doc records the frame-budget finding: real fps on the M2 is resolution-independent (~50 at DRS, ~40 fixed) — the wall is per-frame CPU (submit encode 14-16 ms + 46M guest instructions), so real 60 needs W1/W4/W2.
|
Two updates from the live-game check (2026-11-26):
|
Umbrella plan for constant 60 FPS on the baseline Mac (M2) — workstream results
Full, measured plan in
games/oot/docs/60fps-project.md. All six workstreams are now at a decided state (shipped / measured / blocked with evidence):<<5lane stride; M2 Metal caps 256 verts / 32 KB per mesh threadgroup; lid-strided body at 128 threads = 13.6 ms vs 45–53 ms (−73 %). Remaining: per-shader IR lane flattening + chain v29 + re-seed (the long pole).batmain+0x4c52ec(or the storemain+0x4c52f4) deadlocks the guest at world entry — even a semantically identical no-op stub at offsets +372/+400/+2000 — while the aspect veneer atmain+0x4c5334in the same loop works. Evidence in the doc; next step = scale at the camera-struct+0x138writer. Review also caught and fixed a FADD-vs-FMUL encoding bug in the first version.main+0x244bb8via indirect dispatch; the atlas is re-created ~1.3×/frame so HLE scaling measured worse (44.5 vs 50.6 fps, re-upload churn). A fix must patch the game's size computation.TOTK_DISPATCH_REUSE, default on) = +5 % measured (48.1 → 50.6 fps). Remainder needs the conservative range analysis extended to texture/descriptor writes (probe-gated).OOT_TEX_PREWARM=1): registration queues slots, submit thread drains at submission start with a per-submission budget (full budget during load bursts). Measured: 27k+ textures / 29 GB pre-uploaded, fps unchanged, area-entry spike 681 → 586 ms (remainder is same-frame registration + CPU-side). Next: hook the area-load state.sample15 s → 90 % of CPU is guest JIT, host ~10 % (mostly waits; busy host = 0.6 ms translate + 0.66 ms submit/frame). At DRS the M2 is guest-CPU-bound (2.04 M instr/frame, GPU busy p50 4.4 ms).TOTK_AB_SAMEA/B neutral. Closed with numbers.Shippable perf so far is in #2388 (DRS default on M1/M2 + settings row: 41 → 49–51.5 fps real on the M2, 60.0 displayed with interpolation; app rebuilt and signed from it).
Verification on this branch:
python -m unittest discover -s tests2398 OK, oot and totk build (sharednvn_mtl.m), GPU probes pass (probe-gpu-ubo-snapshot16 409,probe-gpu-tex-slots37 152,probe-gpu-texture-retire35 021), post-revert bench 3300 frames / 40.9 fps at fixed 720p, GitGuardian pass, CONTRIBUTING self-check clean (shared-file references are comments only / the acceptedd2r_gfxsymlink).Measured M2 baseline (Kokiri, main@786ddc00): fixed 720p 41 fps, DRS 49.3–51.5, fixed 1080p 34.9; ~1 210 draws / 114 passes / ~31 compute passes per frame; render kernels ~15 ms vs compute ~4.5 ms; first-visit texture streaming up to 383 tex / 280 MB / 146 ms per frame.