d3d12: cache GPU tile spans apart from single pages (#666) #667
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/667"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-12-03T01:30:46Z.
Summary
Fixes #666.
Since
106120ca, RADV backs queue page mappings with private memory, andgpu_tileimports a lot of pages one at a time. Those single-page pieces stay live while a GpuTile holds them, and they shared thepiecesPageCache with the cluster windows fromshared_window. Once 4,096 were live the cache stopped indexing new keys, so every page in a new window imported the whole window again. On my RX 6700 XT, ProjectScarlett hit 18 GiB of GTT a minute after the setup screens and then lost the device (Not enough memory for command submission).This keeps single pages and spans in separate caches (
PieceCaches), each with the existing bound. It also releases the cache lock before opening a piece that has no cache key, as the old code did.DrArroway found this first, on an RX 6900 XT, and their local
fix10stack adds a separatecluster_piecescache for the same reason (https://github.com/brcly/TuxBox/issues/533#issuecomment-7358936475). This PR is the same split, so credit to them. Their stack also limitsshared_window()toMEM_MAPPEDpages and holds whole private cluster windows. Neither is in this PR, which only splits the cache.The single-page cache can still fill, but in practice that hardly matters. With a trace on top of this branch, the title opened 14,499 single-page pieces for 14,241 distinct pages, so at most 258 were opened again, and that count includes pages reopened after their last holder let go. About 13,000 single-page heaps (plus about 1,000 cluster heaps) are live at once, each a buffer on every submit. That does cost something, which this PR doesn't change: it comes from 106120ca's single-page imports, not from the cache split. An earlier version of this description said the queue thread's kernel time didn't rise with them; that was the wrong place to look. Timed around the shared init queue, each
initialize_gpu_tilessubmission took about 1.5 ms while fewer than 1,000 single-page imports were live and 10–41 ms at 8,000–13,000, and the title's threads spent about 114 s of a 250 s load waiting on it. Details in https://github.com/brcly/TuxBox/issues/669#issuecomment-7380503963).Tested
GPU, driver and backend: RX 6700 XT (
1002:73df), RADV / Mesa 26.3.1, GE-Proton11-15,section-import=substitutedThe
Evidence:linetuxbox.py checkprints last, one per card (it names the commit it tested; run it on this pull request's head):Commands run and their results:
The new test is a unit test on the cache, not a Lanes scenario: reproducing it in Lanes would need more than 4,096 live single-page queue mappings.
The exit 5 that remains is not from this PR and not from older builds either: on this card
6d4f1cd7(before the queue page mapping series) doesn't hit it. It's the per-submission cost tracked in #669 (bisect).Imported from brcly/TuxBox. Originally posted by turboheadcrab on 2026-12-03T06:55:40Z.
Tested
2898c907on an RX 9070 XT (RADV from Mesa 26.3.1, kernel 7.3.5, GE-Proton), packaged profile. I started a new game from the intro, under the same conditions as a run on106120cajust before it.106120cadrm-total-gtt)Not enough memory for command submission, device lost, exit 3 at 750 sexe+0x23CF683, exit 5 at 938 sThe runaway is gone on this card, so this looks like it fixes #666 here.
The watchdog afterwards seems to be a separate problem, filed as #669. Every userptr import is walked by amdgpu on each CS, at about 8.4 ms per GiB. With #667, GTT still grew from 1.4 to 4.3 GiB after the new game started. The median CS time went from 13 to 56 ms, and the frame rate fell to 1–1.7 fps, after which the title's 30 s watchdog fired. That matches the exit 5 you saw after your local fix.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.