d3d12: every batch gathers every reserved image in a GPU reservation again (about 50 GiB of copies a frame in ProjectScarlett gameplay on an RTX 5090) #678
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 NickStallman on 2026-12-03T17:38:12Z.
What happens
Once ProjectScarlett reaches gameplay, frames take 14–24 s on an RTX 5090 while the GPU's pipelines are almost idle. The time goes into
QueuedCopies::recordand the copies it queues: before each batch, every placed texture that lives in a GPU reservation is copied from its pages into its image again, and no texture is ever skipped as unchanged.A build from before the page-mapping rework (
9494fdb8,106120ca) runs the same scene on the same machine at about 0.7 s a frame.Setup
wave=32-32 section-import=aliased descriptor-bytes=32/32 mesh=yes rays=yes doubles=yes.106120caplus local fixes that keep the device alive into gameplay (#677 among them). The runs below are without #676; with #676 the frame time was the same (posted there).QueuedCopies::recordis asked for and times its steps. I can open it as a PR if it is useful.Numbers
Per report window of the trace. In gameplay one window is about one frame:
recordSo each batch in gameplay gathers about 1,800 textures (about 1.4 GiB), 33–38 batches a frame. A frame also records about 225,000 detile dispatches and 580,000 image copies.
Around it, per frame after the first 200 s (old build in brackets):
TUXBOX_GPU_TIMING: 11–23 ms of timed pipeline work per second of wall time.Why nothing is skipped
A second run tallied, for each texture read, which condition kept it from being skipped. Two runs, 485 s and 305 s; the split of the first row is from the second run:
All of these textures are reserved images. A record of the gather was kept for every one of them. XMem's range classification does not know the first host page the GPU reads under each texture.
Did the bytes change? For one texture in 64, the trace kept a digest of the first 4 KiB the GPU reads and compared it at the next gather: 38,407 the same, 30 changed (485 s run); 20,469 the same, 119 changed (305 s run). That is a sample of a prefix, not of whole textures, but it says the copies mostly refresh bytes that did not change.
Where the two conditions are
runtime/d3d12/src/device/placement/queue_use.rs,Batch::execute: with phases,record(part, may_skip && index == 0). Every phase after the first of an ordered batch gathers all its reads, because an earlier phase's write is not in flight yet when the skip is decided.runtime/d3d12/src/device/placement/queue_copies.rs,unchangedandnote_gather: the watches are made over the host pagesgpu_hostsreturns (watch_pages). On this machine XMem reports those ranges as not mapped, so the watch never reads clean or held and the texture is gathered again.runtime/d3d12/src/device/placement.rs:may_skip = !gpu_mappings.bindings_pending(). This one is rarely the reason.Ideas, not a plan
I have not tried any of these. #668 looks at the neighbouring exclusivity gate and assumes reads are normally fresh, which they never are here, so the two may interact.
Not covered
shared_pages.rs,chunk_view), whichTuxBoxAcquireGpuTileBackingreturns. XMem's watch only resolves the title's own mappings (tracking.rs,mappings.get(&at)), so for that address it answers "not mapped" (cell 10, reason 1) every time. If that's right, the skip can't pass under section backing on any vendor, only with private backing. A run withTUXBOX_XMEM_PRIVATE_VIEWS=1is going now, and I'll add its result here.section-import=value in the host profile line, and whether private views are on)? That may be the whole difference.🤖 Generated with Claude Code
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-12-03T17:40:38Z.
A control run for the mechanism above: the same build and settings as the 305 s tally run, plus
TUXBOX_XMEM_PRIVATE_VIEWS=1.It only covers loading and the intro. The run ended after 172 s on the title's own watchdog (exit 5), after about a minute without a presented frame, so there are no gameplay frame times to compare. I don't know yet whether that stall is the known cost of private views (#456) or something else.
For the part it did cover:
QueuedCopies::recordSo with private views the watch is no longer refused as "not mapped", and about a third of the reads are skipped. That fits the reading that under section backing the watch is asked for an address XMem does not resolve. The later-phase rule is still the largest reason left (46 % of the reads in this run).
One run, loading only.
🤖 Generated with Claude Code