Repository navigation
A sparse mapping rebuilds the texture tables and starts a new ID cache epoch only when it is new - #2408
Closed
Sennbon-99 wants to merge 1 commit into
Closed
A sparse mapping rebuilds the texture tables and starts a new ID cache epoch only when it is new#2408Sennbon-99 wants to merge 1 commit into
Sennbon-99 wants to merge 1 commit into
Conversation
…e epoch only when it is new pool_gpu refused to patch a texture table over any storage note once any sparse mapping existed (nvn_sparse_gen() non-zero), and ser_sync started a new epoch of the texture ID cache on every change for the same reason. Ocarina of Time maps its virtual pool once at boot, so every storage note after that rebuilt its 33,024-ID table whole and sent every ID down the slow path. Both now compare the sparse generation with the one seen when the table was built (pool_snap.vgen) or at the last sync (g_ser_vgen). The pool table log line counts the rebuilds a sparse mapping caused. t_pool_notes covers both cases.
2 of 3 tasks
Author
|
The same change came independently in #2489 (bymaxmarc), found on Nintendo Switch Sports Resort's two-player skate: the texture table built whole about 3 times a frame after the game's first sparse mapping (M2 Max). Two games hit it; either PR fixes both. |
Author
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
In a long Ocarina of Time (
0400486024DEC000, v131072) session, area loads (Lake Hylia, the Kakariko graveyard, the Kakariko gate from Hyrule Field) stalled in runs of 150 ms to 1 s frames. Asampleof the host during ten of those stalls had the submit thread inpool_gpu→pool_entry→tex_by_id→tex_mtlfor half of its time, and the[nvn] pool tables up to frame …lines showed the 33,024-entry texture table built whole up to 3 times a frame (8.4 ms).Cause:
pool_gpupatches a table over storage notes unless a sparse texture's page table may have changed, and the test for that wasnvn_sparse_gen()being non-zero, i.e. whether any sparse mapping had ever been made.ser_syncstarted a new epoch of the texture ID cache on the same test. Ocarina of Time maps its virtual pool once at boot (oneMapVirtualline), so for the rest of the session every storage note built the texture table whole and sent every ID down the slow path.Change (
nvn_mtl.m, every game; no chain change): a table keeps the sparse generation it was built at (pool_snap.vgen) andser_syncthe one of its last sync (g_ser_vgen); only a sparse mapping made since then builds the table whole or starts a new epoch, as before. The pool table log line counts those builds (a sparse mapping since the build).Reference entry: A sparse mapping made once kept the texture tables from being patched; the two entries it amends now say "made since" instead of "any".
Checked
make -C dm/gfx/tests GAME=0400486024DEC000 runpasses (OK, noFAIL).make -k -C dm/host/tests GAME=0400486024DEC000 run: the tests pass but two do not build on this Mac,t_hid(undefineddm_gfx_addr_note,dm_gfx_bufsnap,probe_atrace) andt_codec_video; this branch changes nothing underdm/host.t_pool_notesgains 9 checks: a storage note after a new sparse mapping builds the table whole and starts an epoch; one with no mapping since builds nothing and keeps the epoch; the kept table matches a table built whole.t_sparse_tiles(4,253 checks),t_pool_retire,t_pool_standin,pool_seen_replaceand the alias tests pass.--allow-damagedfor three damaged.bntx.zs), played by hand through Lake Hylia and Kakariko, Dynamic resolution on before, off after:b149a1e4, chain2afd39090b76, 40 min): texture table built whole about 20,300 times, 59 s in all, 0.142 a frame, up to 3.16 a frame;b149a1e4+ nvn/pool: age read marks once they cover a quarter of the working set (Ocarina of Time: late-session area-load freezes) #2344 + this change, 64 min): about 1,960 times, 8 s in all, 0.009 a frame;a sparse mapping since the build0 for the whole session;pool_gpuin the stall samples: 51 % of the submit thread before, 26 % after.DM_NVN_POOL_CHUNKS=0, the places played differ, and at full resolution the GPU sits near 16.7 ms at the lake. A 50 sscripts/bench.pyroute from the same save at Lake Hylia (3 runs each, base host against this one) measured the same (about 38 fps, GPU p50 16.6–17 ms) and showed almost no whole builds either way (0.01 a frame): the rebuilds pile up with storage notes over a long session, which a short route does not reach.regress.py check --games: not run; Ocarina of Time is the only game built on this Mac. The change can only make a table be patched where it was built whole; a game with sparse pools that maps while it runs keeps rebuilding on each new mapping, as before.Docs
docs/reference/nvn-objects.mdentry, andpython3 dm/tools/docs_symptoms.pywas run (the symptom index)