Repository navigation
Compute dispatches can be ordered by the game's own barriers (profile key dispatch_barriers game): Kirby Air Riders' particle systems go from 6.6-9.8 ms to 0.4-1.2 ms a frame - #2250
Closed
FifteenPen wants to merge 1 commit into
Conversation
… key dispatch_barriers game): Kirby Air Riders' particle systems, about 230 dispatches a frame that the GPU ran one at a time, go from 6.6-9.8 ms to 0.4-1.2 ms a frame
seedds
added a commit
that referenced
this pull request
Nov 12, 2026
Compute dispatches are ordered by the game's own barriers, for every game (PR #2250): dispatch_enc put a barrier before every dispatch in the shared copy encoder, so the GPU ran them one at a time, while NVN makes a dispatch's writes visible to later work only when the game issues nvnCommandBufferBarrier. Now a dispatch (dispatch_enc_cs) gets a barrier when the game issued one since the dispatch before it, or when one of the host's copies meets its ranges in either direction (uniform updates and uploads keep their order; copies are checked against what dispatches wrote and read, g_dw / g_dr); a dispatch with a binding whose reach is no memory range (an image, a buffer texture, a handle in a uniform slot, untraced global memory) and the host's own dispatches keep the full order on both sides. Kirby Air Riders' particle systems, about 230 dispatches a frame that share the buffers they write (91 % meet an earlier one's range, so ranges alone gain nothing): the encoder 6.6-9.8 → 0.4-1.2 ms, GPU p50 over alternating race phases 9.0 → 5.3 ms, the heaviest phase's frame p90 19.36 → 16.75 ms (PR author, M4 Pro, with PR #2254's loop guard). The PR made it a profile key for Kirby; it is the host default here, as the rule is NVN's: DM_NVN_DISPATCH_BARRIER=full brings back the barrier before every dispatch (diagnostic), ab alternates with the DM_AB phases. It replaces PR #1901's dispatch_overlap for Ocarina of Time. Also fixed on top of the PR: a new copy encoder empties the dispatch range sets (ranges from a closed encoder put needless barriers before its copies; t_dispatch_barrier's new case 6 fails without it), and bufsnap's copy is recorded as writing everything, so a later dispatch cannot overwrite what it still reads. The periodic [nvn] line counts dispatches after a game barrier, after a copy's range, in the full order and with none. Reference entry Compute dispatches that wait for each other (frame-rate.md), rendering.md's two dispatch entries point to it, Kirby's note lists it, env switch row, symptom index regenerated. Checked: t_dispatch_barrier in both orders with the encode thread on and off (27 / 31 checks), t_dispatch_own, t_copy_alias, t_tg_spill, t_cpu_tex, test_docs, test_env_switches, test_game_profile, lint_c.py tidy (at the baseline); regress.py check against 8a5c5e7 (M4 Pro): Mario Kart World PASS, 69,367 of about 1.02 M dispatches with no barrier, 59.8 / 60.0 fps, no new red line; OCTOPATH TRAVELER II PASS, but all its dispatches have a rangeless binding and keep the full order. Not run: Kirby Air Riders and Ocarina of Time in this form (no files / no route here), the iPhone Co-authored-by: FifteenPen <354289956+FifteenPen@users.noreply.github.com>
Owner
|
Landed as 547c5db, with you as co-author. Thank you: the rule, the test and the Kirby diagnosis are yours. What changed from the PR:
Checked:
Not run here: Kirby Air Riders and Ocarina of Time in this form, and the iPhone. A Kirby race with |
2 of 3 tasks
Kayyluhh
added a commit
to Kayyluhh/nxnative
that referenced
this pull request
Nov 14, 2026
…losed, superseded by seedds#2250, on main as 547c5db (compute dispatches ordered by the game's barriers for every game) Ocarina of Time's profile drops dispatch_overlap; the barrier op records the game's bits without g_cs_gbar; dispatch_enc is main's as it was before seedds#2250. seedds#2226's ind_split and seedds#2341's replay_ahead stay.
Kayyluhh
added a commit
to Kayyluhh/nxnative
that referenced
this pull request
Nov 14, 2026
…ered by the game's barriers (547c5db, seedds#2250) in place of seedds#1901 Kirby's note, hle_nvn.c's periodic lines (seedds#2261's GPU share and main's dispatch counts) and the tests Makefile keep both sides. Checked: t_dispatch_barrier (full and game, encode thread off and on), t_dispatch_own, t_copy_alias, t_tg_spill, t_replay_ahead, t_cpu_tex 107, t_view_cache 44, t_serial_owner 167, all dm/gfx/tests programs build, test_docs, test_env_switches, test_game_profile, test_nsp_chain, the Mac host for 0400486024DEC000.
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
This makes Kirby Air Riders hold 60 FPS under the heaviest scenes.
Symptom. Kirby Air Riders (
040077201BE50000, 1.3.3) drops under 60 fps in races wherever its particle systems are busy.DM_NVN_GPUPROFshows one compute / copy encoder at the start of each frame with 170–290 dispatches taking 6.6–9.8 ms, about 30 µs a dispatch, more than all of the frame's rendering (about 6 ms).Cause.
dispatch_encorders every dispatch after everything before it in its encoder (a barrier before each, as for a texture copy), so the GPU runs them one at a time. NVN does not ask for that: a dispatch's writes are visible to later work when the game issuesnvnCommandBufferBarrier, which the host already follows for draw passes (draw_barriers game).Two things I tried first and dropped, because they show why the game's barriers are the right source of order:
DM_NVN_BLIT_ORDER=0): the same encoder takes 0.13–0.18 ms, but the game's real dependencies race and the GPU faults.Change. A profile key,
dispatch_barriers game(defaultfull, unchanged), set for Kirby Air Riders. With it a dispatch gets a barrier:nvnCommandBufferBarriersince the operation before it;DM_NVN_DISPATCH_BARRIER=game/fulloverrides the key, andabalternates the two with theDM_ABphases.With the key at its default nothing changes: the dispatch sets stay empty and dispatches take
dispatch_encas before.Reference entry: Compute dispatches that wait for each other.
Measurements
M4 Pro (48 GB), macOS 27.2, Air Ride races, window at 2560x1440.
Both orders in one race (
DM_AB=600 DM_NVN_DISPATCH_BARRIER=ab, 450 measured frames a phase; the race phases):full(5 phases)game(4 phases)The particle encoder (
DM_NVN_GPUPROF=every:300, separate races):fullgameWhere the barriers went (600,000 dispatches): 7 % a barrier of the game's, 2 % a copy's range, 6 % a binding with no range, 85 % none.
Checked
t_dispatch_barrier, run in both modes and with the encode thread on and off (21 checksfull, 25game): a chain of 64 dispatches behind the game's barriers gives the sequential result; dispatches the game did not order get no barrier ingameand one each infull; a fill before a dispatch and a copy after one stay ordered; a rangeless dispatch keeps the full order. With the line that records the game's barrier removed, it fails (0 of 63 barriers, the chain's result wrong).t_dispatch_own,t_copy_alias,t_tg_spillpass.test_docs.py,test_env_switches.py,docs_symptoms.py.[RED]line, no GPU error, and no visible change in the particle effects (not compared frame by frame).regress.py checkwas not run: this Mac has no builds of the manifest games.regress.py impactlists every NVN game, as the change is in the copy encoder's path; with the key off that path is the same as before.Docs
docs/reference/frame-rate.mdentry, andpython3 dm/tools/docs_symptoms.pywas run