Skip to content

present_interval display above 60 Hz: one display-link tick per frame - #324

Closed
v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:present-display-hz
Closed

v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:present-display-hz

Conversation

@v0lumehi

Copy link
Copy Markdown
Contributor

present_interval display above 60 Hz: one display-link tick per frame

Symptom. With present_interval display, DM_PRESENT_HZ=120 and a 120 Hz display link (DM_PRESENT_LINK=2), a game stays at 60 fps although its frame takes 8 ms, and the display link logs about two ticks per present.

Cause. The acquire waits on the display link for the present interval's vsyncs (mtl_link_wait_tick), counted in 60 Hz vsyncs. On a 120 Hz link that is two ticks per frame, even though display mode's interval is 1.

Fix. In display mode above 60 Hz, the acquire waits for as many link ticks as one tick of the present rate takes, which is one at 120 Hz.

  • link_wait in hle_nvn.c makes that choice.
  • mtl_link_wait_ticks counts in the link's own ticks; mtl_link_wait_tick now goes through it.
  • mtl_link_rate reports 120, 60 or 30 Hz.

Every other case waits as before. The reference entry is in docs/reference/frame-rate.md ("One frame per tick of a 120 Hz display link"), and the symptom index is regenerated.

Measured

Batman: Arkham Knight 1.0.5 (Unreal Engine 3, present_interval display, DM_PRESENT_HZ=120 DM_PRESENT_LINK=2, its frame-rate cap at 120): 119.8 fps in the opening cutscene on an M2 Max, at 60 fps before. The game's speed matched real time. Arkham Knight's profile and note come in a PR of their own.

Checked

  • t_link_ticks (new, in the gfx run list, 8 checks). A host thread stands in for the display link's callback:

    • a 60 Hz vsync waits two ticks of a 120 Hz link and one tick of a 60 Hz one;
    • a wait in the link's own ticks takes one tick per frame (1.00) or two (2.00);
    • mtl_link_rate reports 120, 60 and 30.

    It does not reach link_wait's choice in hle_nvn.c itself.

  • make -C dm/gfx/tests GAME=010015100B514000 run.

  • ci.sh (host tests, CPU gfx tests, every gfx test built, dmhost for three profiles, the iOS compile check, all tool tests): no failures.

  • dmhost for Breath of the Wild and Arkham Knight, the iOS compile check, test_docs.

… at DM_PRESENT_HZ=120

The acquire waited for the present interval's vsyncs on the display link, counted in 60 Hz vsyncs,
so a 120 Hz link (DM_PRESENT_LINK=2) waited two ticks per frame and display mode never went past
60 fps. In display mode above 60 Hz it now waits as many link ticks as one tick of the present
rate takes (link_wait, mtl_link_wait_ticks, mtl_link_rate). Batman: Arkham Knight: 119.8 fps in the
opening cutscene on an M2 Max. docs/reference/frame-rate.md: One frame per tick of a 120 Hz display
link. Checked: make -C dm/gfx/tests run GAME=010015100B514000 passes; t_link_ticks (new) counts the waits in a 120 and a 60 Hz link's ticks
seedds added a commit that referenced this pull request Oct 26, 2026
Display mode at 120 Hz previously waited two display-link ticks per frame
and stayed at 60 fps. Count its acquire waits in the link's own ticks so
120 fps takes one tick. Carry fractional ticks across frames so requests
such as 90 fps on a 120 Hz link wait four ticks per three frames.

Keep game-interval and frame-step pacing in 60 Hz vsync units. Extend
t_link_ticks through the production acquire path, add it to CPU-only CI,
and document the behavior in the frame-rate reference and symptom index.

Validation: 20 link-tick checks, 154 NVN integration checks, pacing and
frame-step tests, Metal snapshot and display-link rescue tests, Mac host
build, iOS source compilation, and documentation checks passed. Physical
display gameplay and iPhone gameplay were not retested.

Co-authored-by: v0lumehi <[email protected]>
@seedds

seedds commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Thanks @v0lumehi. Integrated your change and the review fix into main in fb34a93, with you credited as co-author.

The review confirmed an additional fractional-rate bug: requesting 90 Hz on a 120 Hz link waited one tick per acquire and therefore allowed 120 fps. The conversion now carries the fractional remainder across frames (four ticks per three frames at 90 Hz). This is shared NVN pacing code, with no game-specific conditions; game intervals and frame-step caps keep their existing 60 Hz vsync semantics.

Extended t_link_ticks through the production acquire path and added it to CPU-only CI. On the final integration, all 20 link-tick checks, 154 NVN integration checks, pacing/frame-step tests, Metal snapshot and display-link rescue tests, the Mac host build, all 178 iOS source compile checks, and documentation checks passed. Physical-display gameplay and iPhone gameplay were not retested.

Closing as integrated into main.

@seedds seedds closed this Oct 26, 2026
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 26, 2026
…g_link_rate

The test from seedds#324 includes nvn_mtl.m and hle_nvn.c together, so it renames nvn_mtl.m's weak
nvn_var_fps as the other tests do, and sets g_link_rate beside g_link_mode, as link_range does:
the wait now counts ticks from the link's rate, which also covers a variable step's cap.
@v0lumehi
v0lumehi deleted the present-display-hz branch October 26, 2026 19:41
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 28, 2026
…g_link_rate

The test from seedds#324 includes nvn_mtl.m and hle_nvn.c together, so it renames nvn_mtl.m's weak
nvn_var_fps as the other tests do, and sets g_link_rate beside g_link_mode, as link_range does:
the wait now counts ticks from the link's rate, which also covers a variable step's cap.
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 29, 2026
…g_link_rate

The test from seedds#324 includes nvn_mtl.m and hle_nvn.c together, so it renames nvn_mtl.m's weak
nvn_var_fps as the other tests do, and sets g_link_rate beside g_link_mode, as link_range does:
the wait now counts ticks from the link's rate, which also covers a variable step's cap.
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 30, 2026
…g_link_rate

The test from seedds#324 includes nvn_mtl.m and hle_nvn.c together, so it renames nvn_mtl.m's weak
nvn_var_fps as the other tests do, and sets g_link_rate beside g_link_mode, as link_range does:
the wait now counts ticks from the link's rate, which also covers a variable step's cap.
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
Display mode at 120 Hz previously waited two display-link ticks per frame
and stayed at 60 fps. Count its acquire waits in the link's own ticks so
120 fps takes one tick. Carry fractional ticks across frames so requests
such as 90 fps on a 120 Hz link wait four ticks per three frames.

Keep game-interval and frame-step pacing in 60 Hz vsync units. Extend
t_link_ticks through the production acquire path, add it to CPU-only CI,
and document the behavior in the frame-rate reference and symptom index.

Validation: 20 link-tick checks, 154 NVN integration checks, pacing and
frame-step tests, Metal snapshot and display-link rescue tests, Mac host
build, iOS source compilation, and documentation checks passed. Physical
display gameplay and iPhone gameplay were not retested.

Co-authored-by: v0lumehi <[email protected]>
khalilgharbaoui pushed a commit to khalilgharbaoui/nxnative-ultimate that referenced this pull request Nov 15, 2026
… frame), DM_WINDOW_SIZE=WxH overrides

The Mac front end hardcodes a 1280x720-point window. On a Retina display the
backing store is 2x points, so 1080p points is a 3840x2160 backing that still
leaves the game's own dynamic resolution untouched; the frame-step controller
calibrated at 720p keeps its meanings at 1080p. Measured on M3 Pro with Tears
of the Kingdom and five other titles, 1080p costs ~1 ms/frame over 720p and all
six hold a locked 60 fps (p50 16.6-16.7 ms).

The size is clamped to the largest 16:9 rect that fits the visible frame, so
smaller MacBooks get a fitting window instead of an off-screen one, and
DM_WINDOW_SIZE=WxH (points) overrides both. Keep the window below 1440p points:
at >=1440p the game's own vsync acquisition starts failing on Metal (seedds#324),
which is what the focus-notify switch works around.

The chosen size is logged once at startup so support reports can see it.

(cherry picked from commit bc7edc4)

nxnative-ultimate: the window stays 1280x720 points by default (main's size); the
PR made 1920x1080 (shrunk to fit) the default. DM_WINDOW_SIZE=WxH sets another.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants