Skip to content

nvn/fstep: judge frames around display-link events by their GPU time - #3156

Closed
Eriksrevenge1 wants to merge 1 commit into
seedds:mainfrom
Eriksrevenge1:pr/fstep-link
Closed

Eriksrevenge1 wants to merge 1 commit into
seedds:mainfrom
Eriksrevenge1:pr/fstep-link

Conversation

@Eriksrevenge1

Copy link
Copy Markdown
Contributor

What and why

While the display link is silent the acquire waits for a present the link never takes, and that wait counted as the frame's CPU cost; after a rescue or a pacing mode change the first frames wait for the screen the same way. Three such frames raised the hold 1 -> 2 -> 3 (20 fps) for up to a second each time a window was covered or shown again.

nvn_mtl.m counts the link's events (stall start and end, rescue start and end, pacing mode change; mtl_link_events). While the link is silent and for 30 frames after an event, fstep_tick takes a frame whose GPU time fits its hold as on time; a GPU-bound frame is judged as before.

Ocarina of Time, field-run with DM_TEST_LINK_STALL=95,3, two runs a side on an M6 Mac mini: 56.4 -> 59.4 fps, frame p99 51.2 -> 17.8 ms, frames over budget 91 -> 15. t_fstep: 119 checks pass.

Checked

  • Tests:
  • Games run: The Legend of Zelda: Ocarina of Time (0400486024DEC000, 1.1.1), a Mac app built from this branch, fullscreen on a DELL S2725QC (120 Hz, variable refresh), about 2 minutes from a Hyrule Field save with a scripted walk: no crash, no [RED] line, 60 fps (p50 16.67 ms, every 300-frame window under 17.5 ms). The before/after measurement in the commit (56.4 -> 59.4 fps under DM_TEST_LINK_STALL=95,3) was on a build with the same code.
  • Devices and OS: Apple M6 Mac mini, macOS 27.0.1, Xcode 27.2
  • Not run: lint_c locally (no LLVM release installed here; CI runs it); regress.py check (no local game has a smoke route).

Docs

  • The finding is in its docs/reference entry or game note, and python3 dm/tools/docs_symptoms.py was run
  • 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 game: 0400486024DEC000 A game labels Nov 21, 2026
@Eriksrevenge1

Copy link
Copy Markdown
Contributor Author

Rebased on current main (a README conflict only); the host builds. The earlier Tool tests failure came from a stale merge base: test_patches and test_nvn_rt_api pass on current main with this change.

While the display link is silent the acquire waits for a present the link
never takes, and that wait counted as the frame's CPU cost; after a rescue
or a pacing mode change the first frames wait for the screen the same way.
Three such frames raised the hold 1 -> 2 -> 3 (20 fps) for up to a second
each time a window was covered or shown again.

nvn_mtl.m counts the link's events (stall start and end, rescue start and
end, pacing mode change; mtl_link_events). While the link is silent and
for 30 frames after an event, fstep_tick takes a frame whose GPU time
fits its hold as on time; a GPU-bound frame is judged as before.

Ocarina of Time, field-run with DM_TEST_LINK_STALL=95,3, two runs a side on
an M6 Mac mini: 56.4 -> 59.4 fps, frame p99 51.2 -> 17.8 ms, frames over
budget 91 -> 15. t_fstep: 119 checks pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Eriksrevenge1

Copy link
Copy Markdown
Contributor Author

Rebased on current main (conflicts in nvn_mtl.m with the probation change: kept main's code, link_event() added at the same events plus the probation's rescue); the host builds, test_docs and test_patches pass. Not run: GPU and game checks (no Metal 4 here).

@seedds

seedds commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Thanks @Eriksrevenge1 for isolating the pacing drop, measuring it, and rebasing the patch. I'm closing this PR because #3174 landed as 6ef18a1f and handles the reported window-cover and fullscreen cases. The host signals window uncover, focus return, and fullscreen changes directly. The frame step ignores the pause when deciding whether to increase the hold or make up lost time. The frame-step and NVN tests cover those transitions.

The Ocarina of Time forced-stall run on the M6 Mac mini is a good baseline to keep. With DM_TEST_LINK_STALL=95,3 it went from 56.4 to 59.4 fps and from 51.2 to 17.8 ms at p99 on the earlier code. A short display-link interruption with no window or focus change could still fall below the eight-vsync stall threshold on main. If it still raises the frame hold, please share a current-main run and log so we can address that case.

@seedds seedds closed this Nov 23, 2026
Kayyluhh added a commit to Kayyluhh/nxnative that referenced this pull request Nov 23, 2026
Kayyluhh added a commit to Kayyluhh/nxnative that referenced this pull request Nov 23, 2026
…nk events by their GPU time): closed, superseded by seedds#3174, on main as 6ef18a1 (the host signals window uncover, focus return and fullscreen changes; the frame step ignores the pause)
Kayyluhh added a commit to Kayyluhh/nxnative that referenced this pull request Nov 23, 2026
… and seedds#3156 reverted first (on main in its own form / superseded by seedds#3174); chain 6cc6fc49af97 -> 3fe2e3787fdf

Conflicts, both sides kept:
- hle_nvn.c: main's deferred acquire wait (c17a549, acq_wait bound to the sync) takes the batch's
  acquire fence (seedds#1847's 81c6189: the image's own last present, pfence, snapshotted with the ticket
  under acq_mu; DM_NVN_ACQ_FENCE=last the old one) as aw->gpu_fence, and DM_NVN_FRAME_LAG's wait at
  the acquire's start; the present notes the lag ring before publishing its ticket, and @lag_ms
  stays beside main's atomic @wait_ms / @pq_wait_ms. nvn_obj.h win_t has pfence and pending_acq.
- nvn_mtl.m: the pool cache keeps seedds#1847's last-hit entry in front of main's 64 KB region table
  (a359f9e); ubd_conflict_scan's partial look walks main's buffer binding list (e49e481).
- shader_lib.py: seedds#2140's shared payloads with main's on_progress (seedds#2684).
- hle_fs.c: the profile's RomFS files beside main's releasable mounts (seedds#3217).
- game.py (main's mem_map_limit default), pack_app.py (--tweaks and --mesh-pairs), env_switches.tsv,
  frame-rate.md, services.md, Ocarina's note: both entries.
- dm/host/tests/Makefile: t_crash_diag (new on main) links memstat.m, which seedds#2261's GPU share line
  makes use IOKit: -framework IOKit.
Chain header is main's (dmsh_chain.py --header agrees); symptom index, game-patches.md and
env_switches.tsv order regenerated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation game: 0400486024DEC000 A game 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