Repository navigation
Indirect-count multi-draws are copied when their pass opens: Mario Kart World's scene passes are no longer split for them - #1179
Closed
aksmith-git wants to merge 1 commit into
Closed
aksmith-git wants to merge 1 commit into
aksmith-git wants to merge 1 commit into
Conversation
Closed
2 of 3 tasks
aksmith-git
force-pushed
the
pr/mdx-prescan
branch
from
November 6, 2026 12:06
d247bb8 to
e9d91fc
Compare
2 tasks done
lossefanya
pushed a commit
to lossefanya/nxnative
that referenced
this pull request
Nov 6, 2026
…mit on): in free roam the game frees its own blocks, and its footprint stays near 4 GB with DM_GUEST_FILE Free roam streams the world, and the memory kept growing: on a 16 GB M1 Pro, handheld, a scripted drive into new areas took the footprint from 7.8 to 9.4 GB in 12 minutes (the game's charged memory 3.9 to 5.3 GB, 4.5 GB compressed, swap growing). Most of it was the game's own memory, which the host cannot give back without knowing what the game still needs. With mem_map_limit on, MapPhysicalMemory past the 9 GB pool fails as on Horizon, and the game's streaming frees its own blocks: its alias region peaked at 1.5 GB mapped where it had 3.0 GB, as issue seedds#1536 found on an 8 GB Mac. With DM_GUEST_FILE=1 as well, the footprint stayed at 3.8 to 4.4 GB over 13 to 17 minutes, compressed memory under 0.6 GB, swap flat, wired unchanged. The cost is more long frames: a 20-minute played windowed run (Grand Prix and free roam) had 1.35 long frames a second (21 over 100 ms) against 0.65-0.73 without the files. Measured on a branch that also had pull requests seedds#1179, seedds#1229, seedds#1230, seedds#1251 and seedds#1350. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 tasks done
…rt World's scene passes are no longer split for them mdx_run copied a multi-draw's records at its first draw. When the pass had already opened for an earlier draw, that split it, and the colour and depth (2048x1152, 20 MB) were loaded again. mdx_prescan runs the same scan, once per epoch and submission, when a draw that is not such a multi-draw opens a pass. Ranges (draw_multi) are not scanned ahead and behave as before. Mario Kart World, the Grand Prix route: - Pass dump at a race frame: masking splits 2 → 0, mergeable splits 5 → 2 (tbdr_pass_merge.py: 118 → 47 MB a frame). - 10 minutes on an iPad Pro (M5): 72,000 splits → 0. - GPU time on an M4 Pro (first-flyover shot runs): p50 13.0 ms against 13.65–14.1 in five runs without it. - GPU time on the iPad: unchanged within noise (race p50 about 14.3 ms), its bandwidth makes the reloads cheap there. - Pictures as before (only run-to-run differences). The reference entry is in docs/reference/rendering.md, with its line in the symptom index and Mario Kart World's note.
aksmith-git
force-pushed
the
pr/mdx-prescan
branch
from
November 8, 2026 04:55
e9d91fc to
93dc3f9
Compare
Contributor
Author
|
Rebased on main eed7c42 (the conflict was the game note's entry list). Builds with the Mario Kart World profile; check_t_large_mdi passes; docs_symptoms --check current; test_docs OK. |
seedds
added a commit
that referenced
this pull request
Nov 13, 2026
…(PR #1179) mdx_run copied a multi-draw's records at its first draw. When an ordinary draw had already opened the render pass, the copy's compute pass split it and the attachments were loaded again. mdx_prescan runs the same forward scan when a draw that is not such a multi-draw opens a pass, once per g_mdx_epoch and submission, so the multi-draws after it are copied before the pass. Ranges replayed through draw_multi are not scanned ahead. The rebase onto the mesh-grid changes keeps DMSH_MESH_GRID as an indirect mesh draw's limit in mdx_run's first take. Added here: - The scan runs only once the game has drawn such a multi-draw or an indirect mesh draw (g_mdx_runs), so other games do not walk their submissions for it. - A barrier with ORDER_INDIRECT_DATA after a draw with shader writes since the copies were made (g_mdx_wr against g_vbuf_write_epoch) bumps g_mdx_epoch, and the multi-draws after it copy again: a draw can write a record, and NVN orders that write for indirect fetch only by such a barrier. The copies made ahead now come before the pass-opening draw; the scan from a multi-draw's own first draw already had this gap for the draws between multi-draws. No game is known to write records from a draw. - DM_NVN_MDX_PRESCAN=0 turns the scan off, =ab alternates it with DM_AB. - t_mdx_prescan: split counts and pictures for the first multi-draw (split), a pass opened by an ordinary draw (none), count 0, an indirect barrier with and without a shader write before it, and a shader write with no barrier. It fails without the prescan and without the barrier rule. Mario Kart World 1.8.0 on an M4 Pro, the regression route: masking splits in pass dumps every 600 frames 12 and 10 in two runs without it, 0 and 0 with it. In one run alternating DM_NVN_MDX_PRESCAN=ab every 300 frames, the first ten race phases load 69 MB and store 47 MB less per frame with 2.2 fewer passes (8 of 8 comparisons); the last fifteen show no difference, as main hardly splits there. GPU time unchanged within noise (p50 about 9.6 ms). The author's pre-rebase M4 Pro gain (p50 13.65-14.1 to 13.0 ms at the first flyover) was not reproduced here. Checked: regress.py check on Mario Kart World, 2+2 runs PASS (59.3 fps both, p99 20.7/20.6 to 20.6/20.4 ms, no new red line, no shader change) and the A/B run; make -C dm/gfx/tests run (the whole suite, t_large_mdi, t_geometry_mesh and t_mesh_first_use among it); lint_c.py tidy on nvn_mtl.m and the test at the baseline; test_docs, test_env_switches. Not run: Ocarina of Time (indirect mesh draws reach the prescan; covered by the mesh tests), Monster Hunter Rise (not on this Mac), iOS and the iPad. Co-authored-by: aksmith-git <242086076+aksmith-git@users.noreply.github.com>
Owner
|
Landed on main as a4705fe, with you as co-author. Thank you for the diagnosis and the measurements. Changes on top of the PR:
Measured on main (1.8.0, M4 Pro, the regression route):
|
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.
mdx_runcopied a multi-draw's records at its first draw. When the render pass had already opened for an earlier draw, that split the pass, and the colour and depth attachments (2048x1152, 20 MB) were loaded again.mdx_prescanruns the same forward scan when a draw that is not such a multi-draw opens a pass, once per epoch and submission, so no copy is made inside the pass. Ranges (draw_multi) are not scanned ahead and behave as before.Mario Kart World, Grand Prix route:
tbdr_pass_merge.py: 118 → 47 MB a frame).Rebased on main 0f510fd
mdx_run's first take, where main added indirect task / mesh draws (DM_PRIM_MESH_TASKS, keyed by the record alone). Both are kept: a mesh draw takes its record as on main, an ordinary draw as before, and a call with neither (mdx_prescan) takes only the draws after it. The forward scan already takes mesh draws, so a pass an ordinary draw opens copies the indirect mesh draws after it too.make -C dm/host GAME=0400486024DEC000 dmhostbuilds;check_t_large_mdiandcheck_t_geometry_meshpass;docs_symptoms.py,test_docs.py.docs/reference/rendering.md(Indirect-count multi-draws split the pass an earlier draw opened), its line in the symptom index, and a line in Mario Kart World's note.