Repository navigation
Conversation
Symptom: Nintendo Switch Sports Resort's (04008E001F098000, v65536) dynamic resolution fell to 854x480-1280x720 in a table tennis match and stayed there for minutes (560 of 600 frames at 854x480), while its GPU p50 stayed about 12 ms, the same as at full size: the picture was upscaled from a quarter of the pixels or less. Whether it fell was chance, and a fall was for good: of four runs of the route, one held full size. Cause: a Switch GPU starts a submission as soon as the previous one ends, or when the game submits it if that is later. Here the host translates a submission after the game submits it, and the GPU waits for that too. The game submits a frame's three submissions within 0.2 ms (from two threads; the submit lock waits were 0-0.7 ms), and the GPU then waited 1.3-2.6 ms before each. Its frame-start TIMESTAMP_TOP (first submission) and frame-end TIMESTAMP (third) spanned about 14.3 ms for about 12 of GPU work. agl's dynamic resolution steers by that span, and no resolution shortens the host's translation, so once a long frame took it down the span stayed over its threshold at every size. The wait between the command buffers of one submission was already left out (seg_idle_before). Fix (every game; host only, no shader or pipeline archive rebuild): sub_lag in nvn_mtl.m places each submission where the Switch would have run it, at the later of the previous one's end there and its ready time, and its reports move back by the difference. The ready time is the game's nvnQueueSubmitCommands (nvn_queue_submit, recorded on the queue job), or the passing of a queue wait the submission was held for (mtl_sub_ready). Reports never move before the game submitted, so the game's own waits stay in, and a lag is at most the time from the submit to the GPU's start. Out of order, with no ready time, or with its first command buffer's feedback missing, nothing moves. DM_NVN_GPU_TS=segment_submit_gaps keeps the wait (the earlier default). Ruled out on the way: timestamp reports at their own place in the stream (a heap stamp per report) made agl's per-pass reports exact but left the span and the fall; taking out every gap between the submissions of a guest frame failed, as the game presents a frame after submitting part of the next. Checked: t_counter_clock (34 checks; with segment_submit_gaps the 8 placement checks fail); make -C dm/gfx/tests GAME=010015100B514000 run on this branch; test_docs, test_env_switches, test_pr_areas. In the game on an M2 Max (the host from this change on the fork's branch, the playtest save's table tennis route, 330 s, 1280x720 window on a 75 Hz screen): the frame's span about 12.1 ms; DM_UPSCALER=game full size in 92% of the frames and back within 600 presents after a fall; DM_UPSCALER=metalfx with DM_PRESENT_UPSCALE=metalfx 99.4% against 61% without, MetalFX scalers made 13 times against 34. Frame time p50 16.0-16.3 / p95 20-24 ms and GPU p50 about 12.0 / p95 13.6 ms at full size, as without. Avioneta's tutorial (GPU 27.6 ms a frame): 30 fps at 854x480 with and without, same frame and GPU times. In an 11-minute session on 2026-11-12 with a build of the fork's branch that has this change and the fork's other fixes (not the keep-busy switch), a player played two-player skate (the practice zone, then leaving it) and two-player Avioneta with no crash. Not run: other games, regress.py, lint_c tidy (no LLVM release here), iOS (the encode thread). Docs: frame-rate.md (The GPU's wait for the host's translation between submissions), DM_NVN_GPU_TS's row, the game note, symptom index regenerated.
bymaxmarc
force-pushed
the
pr/timestamp-submit-lag
branch
from
November 13, 2026 16:41
ecd5f6b to
29dc65b
Compare
seedds
added a commit
that referenced
this pull request
Nov 15, 2026
…r translation between submissions leaves the span a game's dynamic resolution reads (PR #2491) Timestamp reports already left out the gaps between command buffers of one submission (seg_idle_before), but not the GPU's wait for the host's translation between submissions. agl's dynamic resolution steers by the span between its frame-start and frame-end reports, so on a slow host it read the translation as GPU time: Switch Sports Resort on an M2 Max read 14.3 ms where the GPU took 12.1 ms and stepped down to 854x480 in 560 frames of 600 (PR author's measurement). Reports now follow one timeline in fence order: each submission starts at the later of the timeline's end and the time it was ready (the queue's submit time or the end of a held wait, mtl_sub_ready), and its reports move back by how much later the real GPU started it (sub_place, place_back). A report never moves before its submission was ready, nor later than the GPU ran it. A submission that cannot be placed (no first feedback, no ready time) stays where it is, and the timeline goes on from its end, so no later report reads earlier than one of its own. DM_NVN_GPU_TS=segment_submit_gaps keeps the old reports. t_counter_clock: 37 checks, 11 of them fail with segment_submit_gaps. regress check on an M4 Pro (macOS 27.2.1), main against this: Mario Kart World 60.0 fps, p99 20.63 against 20.62 ms (its scene stayed 2560x1440, so its dynamic resolution was not exercised); Breath of the Wild 59.7 against 59.8 fps; both PASS, no new red line. Co-authored-by: bymaxmarc <354601562+bymaxmarc@users.noreply.github.com>
Owner
|
Landed on main as c4aa24c, with you as co-author. Thanks for the diagnosis and the Switch Sports Resort measurements. What changed from the PR:
The resolution benefit so far rests on your Switch Sports Resort runs. If you can rerun that on main on the M2 Max and post the time at full resolution, that would confirm it for the version that landed. |
Kayyluhh
added a commit
to Kayyluhh/nxnative
that referenced
this pull request
Nov 15, 2026
…#2341's held-commit time, which also raises the submission's ready time (seedds#2491's timeline) to the release, since its wait was taken ahead of the game's signal
bymaxmarc
added a commit
to bymaxmarc/nxnative
that referenced
this pull request
Nov 17, 2026
Main landed two of the branch's changes in its own versions, which are taken whole: the Switch 2 Mii stand-in (15316fd, PR seedds#2488: one shared <DM_TEMP>_sysdata/mii directory) and the timestamp reports on one GPU timeline (c4aa24c, PR seedds#2491: sub_place / place_back). The branch's own hle_mii.c, hle_fs.c, t_mii_sysdata.c, nvn_queue.inc, t_counter_clock.m and its timestamp code in nvn_mtl.m are dropped, and the game note, symptoms, frame-rate.md and services.md lines for them are main's. Kept and adapted to main: compute pipelines built off the replay thread (cps-async: CpsJob beside main's NvShader fields, cps_build through main's dev_cps compile gate, the slow-compile watch around main's plain_rps, cps_get before main's loop containment and dispatch_), the GPU keep-busy switch DM_NVN_GPU_BUSY, CMDSTAT's control memory (its dump at the first null-pool buffer after main's physical pool check), the upscaler size log, the present minify filter, scripted swings (main's object-per-source host Makefile needs no header list) and the HLE_FORCE uniqueness test. The pipeline archive split (compile_split, LEFT_OUT_EXIT) is dropped: it no longer applies to main's pso_offline.py (prewarm-host, vol_space), so pso_offline.py, its tests, build_ipa.sh, the NSP script and their docs are main's. Kept from the branch beyond those: the 9 task / mesh pipelines of other sports in the prewarm list and the two Switch Sports Resort notes on model heaps in memory.md.
bymaxmarc
added a commit
to bymaxmarc/nxnative
that referenced
this pull request
Nov 18, 2026
Symptom: Nintendo Switch Sports Resort (04008E001F098000, v65536) looks blurry for stretches of play, and nothing in the log said at what resolution it was rendering: the upscaler lines appear only when MetalFX makes a scaler for a new size, and not at all with the game's own upscaler. Cause: no record of a game's dynamic resolution frame by frame. Change (diagnostic, no behaviour change): for a game whose profile names upscaler shaders (DM_GAME_UPSCALER_KEYS), each dispatch of one notes its input rectangle (push constants, as up_mfx_encode reads them), with DM_UPSCALER=game or metalfx alike; each present takes the last size noted since the previous one, or none (full size). Every 600 presents one line, `game upscaler input over 600 presents: none (full size) N, WxH n, ...` (8 sizes, the rest as other sizes), once the game has upscaled at all. What it showed (M2 Max, Switch Sports Resort's pointer calibration screen, DM_UPSCALER=game, one 150 s run): most windows at full size (2560x1440) at a GPU p50 of about 12.4 ms, then windows at 854x480-1280x720 (one with 333 frames at 854x480) while the GPU p50 stayed 12.2-12.4 ms; that led to the timestamp change of PR seedds#2491 (landed as c4aa24c: the GPU's wait for the host's translation between submissions). Checked: t_upscaler_mfx with GAME=040074A01BF12000 (a profile with upscaler keys; DM_UPSCALER=metalfx with and without the encoding thread, and game): an unnamed shader notes nothing, the named one notes 2134x1200, the present takes it (3 new checks); make -C dm/gfx/tests GAME=010015100B514000 run on this branch; test_docs, test_env_switches, test_pr_areas. Not run: lint_c tidy (no LLVM release here), the iPhone. Docs: the game note lists the sizes and names the line, and the reference entry (The GPU's wait for the host's translation between submissions) quotes it for its 560 frames of 600 at 854x480; symptom index regenerated.
Contributor
Author
|
Reran it on main on the M2 Max. On this route, the version that landed does not keep full size. Setup
Results
GPU time at 854x480
The profile fix is a re-split with main's |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Nintendo Switch Sports Resort's (04008E001F098000, v65536) dynamic resolution fell to 854x480-1280x720 in a table tennis match and stayed there for minutes (560 of 600 frames at 854x480), while its GPU p50 stayed about 12 ms, the same as at full size. Whether it fell was chance, and a fall was for good.
Cause: a Switch GPU starts a submission as soon as the previous one ends, or when the game submits it if that is later. The host translates a submission after the game submits it, and the GPU waits for that too. The game submits a frame's three submissions within 0.2 ms, and the GPU then waited 1.3-2.6 ms before each, so its frame-start
TIMESTAMP_TOPand frame-endTIMESTAMPspanned about 14.3 ms for about 12 of GPU work. agl's dynamic resolution steers by that span, and no resolution shortens the host's translation. The wait between the command buffers of one submission was already left out (seg_idle_before).The change (every game; host only, no shader or pipeline archive rebuild):
sub_laginnvn_mtl.mplaces each submission where the Switch would have run it, at the later of the previous one's end there and its ready time (the game'snvnQueueSubmitCommands, or the passing of a queue wait it was held for:mtl_sub_ready), and its reports move back by the difference. Reports never move before the game submitted, so the game's own waits stay in. Out of order, with no ready time, or with its first command buffer's feedback missing, nothing moves.DM_NVN_GPU_TS=segment_submit_gapskeeps the wait (the earlier default).Ruled out: a heap stamp per report made agl's per-pass reports exact but left the span and the fall; taking out every gap between the submissions of a guest frame failed, as the game presents a frame after submitting part of the next.
Reference entry: The GPU's wait for the host's translation between submissions;
DM_NVN_GPU_TS's row; the game note. The symptom quotes thegame upscaler input over 600 presentslog line, which is added by the separate PRnvn/upscaler: count the frames rendered at each upscaler input size.Checked
t_counter_clock(34 checks; withsegment_submit_gapsthe 8 placement checks fail).make -k -C dm/gfx/tests GAME=010015100B514000 runon this branch: all pass (t_counter_clock 34 / 0).dm/tools/teststest_docs, test_env_switches, test_pr_areas.DM_UPSCALER=gamefull size in 92% of the frames and back within 600 presents after a fall (four runs before: 75%, 98%, 33%, 44%);DM_UPSCALER=metalfxwithDM_PRESENT_UPSCALE=metalfx99.4% against 61%, MetalFX scalers made 13 times against 34. Frame time p50 16.0-16.3 / p95 20-24 ms and GPU p50 about 12.0 / p95 13.6 ms at full size, as before. Avioneta's tutorial (GPU 27.6 ms a frame): 30 fps at 854x480 with and without. In an 11-minute session on 2026-11-12 with a build of the fork's branch that has this change and the fork's other fixes (not the keep-busy switch), a player played two-player skate (the practice zone, then leaving it) and two-player Avioneta with no crash.regress.py check(every game's timestamp reports go through this change; no other game was run),lint_c.py tidy(no LLVM release on this Mac), iOS (the encode thread).Docs
docs/reference/<subsystem>.mdentry, andpython3 dm/tools/docs_symptoms.pywas run (the symptom index)