Skip to content

Make deferred GPU reference cleanup linear - #1408

Closed
givethesourceplox wants to merge 1 commit into
seedds:mainfrom
givethesourceplox:fix/nvn-linear-retirement
Closed

givethesourceplox wants to merge 1 commit into
seedds:mainfrom
givethesourceplox:fix/nvn-linear-retirement

Conversation

@givethesourceplox

@givethesourceplox givethesourceplox commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Scene transitions can queue many GPU references whose fences complete out of order. defer_drain removed every completed reference from the middle of an NSMutableArray, repeatedly shifting pending entries. Interleaved fences make cleanup quadratic.

Partition ready and pending references once under the existing mutex. Release ready objects outside the lock in the same reverse order as before, retaining fence eligibility, pending order and keep-resident behavior. This is a CPU cleanup change, with no shader, pipeline or image changes. The small declaration shim for existing OS-27-guarded MetalFX setters is the same SDK-26 build prerequisite as #1404; runtime availability checks are unchanged.

Reference finding. Found while investigating Ocarina's scene-load stalls alongside #1299.

Checked

Apple M1 Pro, macOS 26.5.2, Xcode 26.5:

  • t_deferred_release passes: 100,000 references with interleaved completed/pending fences; exact pending order, reverse destruction order, retained lifetimes, second-fence completion and empty drain. The first half drains in about 7.8 ms on this machine. This is a synthetic result, not a gameplay FPS comparison.
  • Documentation tests: 11 pass; chain tests: 17 pass; git diff --check passes.
  • LLVM static analysis of production code and the fixture: no new findings.
  • No shader chain or profile inputs changed, and no game shader rebuild was performed.

No standalone gameplay or five-game regression report is available for this upstream-base branch. The Ocarina bring-up depends on other open changes; its integrated runs cannot isolate this patch. Cross-game runtime behavior and iPhone performance are unmeasured. This PR claims the cleanup complexity improvement only.

Docs

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

@seedds

seedds commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Thank you. The deferred release queue is linear on main now (6121fd7), so I'm closing this. Final checks on the rebased tree (full shader build, walks, regression) are still running, so please report anything you see.

@seedds seedds closed this Nov 6, 2026
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.
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.

2 participants