You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
D3D12.X: every draw re-syncs buffer mirrors on the CPU (VirtualQuery, whole-buffer copies, index scan) #2389
Some titles bind vertex and index buffers in their own memory, outside the unified-memory windows. XCL gives each such buffer a mirror in unified memory (#637), and list_x::sync_title_buffers (crates/xcl/src/hle/d3d12x/list_x.rs:3539 on main3f4495a) brings the mirror up to date on every draw. Once one mirror exists, every DrawInstanced, DrawIndexedInstanced and DrawIndexedX on every list goes through it. Per draw, it:
copies the whole vertex buffer for instanced draws, and the used range otherwise, even when the title has not written it;
reads every index of an indexed draw on the CPU to find the vertex range;
writes the copy into a mirror that usually sits in a sparse window, so the next submit's write-watch look finds the pages dirty and uploads them again.
Seen: in my title's menus (RTX 2070 SUPER, Ryzen 5 3600XT, Windows 11 26300, main3f4495a release), the first two mirrors appear 36 s in: a 384 KiB index buffer and a 1.1 MiB vertex buffer. Draw counts in a world are far higher than the ~600 a second in those menus. I have no measurement of the function's cost yet, which is why the first part below is a counter.
None of the open work changes this path: #825 frees idle mirrors, #1995 re-keys MIRRORS, and #1488 covers the DrawIndexedX re-sync as a correctness bug.
Measured: the sync is cheap on average, but readable() stalls the render thread for ~5 ms every few seconds. The copies are all redundant. Mirrors only appear while the coherent window is too small.
Setup: my title; main3f4495a plus local timers and counters (not committed); release; RTX 2070 SUPER (32.0.16.2140), Ryzen 5 3600XT, Windows 11 26300. Two scripts/smoke.ps1 runs of 120 s each, both in menus (30 fps, ~390 draws/s).
When mirrors exist at all. With the learned coherent window (uma_coherent.txt, 4095 MB), the run made no mirrors, so sync_title_buffers returned at its first check. Mirrors only appeared after I removed that file for one run, which gives the 512 MB first-run window of #284. That run made two mirrors at 32.7 s, the same as my first report: a 448 KiB index buffer and a 1.2 MiB vertex buffer, both in a sparse window. So on this title, this issue is a first-run problem.
First-run window, 50–118 s, per 2 s, very steady:
per 2 s
draws through the sync / with a mirror
780 / 660
copies (whole buffers)
1,200 (0)
bytes copied
10.5 MiB, in 2.5 ms
indices scanned for the vertex range
1.98 M, in 0.55 ms
readable() calls (over 16 pages)
1,800 (0), 1.3 ms when none is slow
total time in the function
4.7 ms typically (~7 µs a mirrored draw), 9–18.6 ms with a slow readable()
D3D12.X: the per-draw mirror sync checks its source with readable() at every draw #2392 (readable per draw): no range was over 16 pages, so the VirtualQuery fallback I expected for large ranges never fired. But in 18 of the 43 2-s windows that had mirrors (34–118 s), a single readable() call on ≤16 pages took 1.1–8.8 ms, most of them 4–5 ms. That is presumably resident_and_readable failing on a page that is not resident, followed by the VirtualQuery walk. It happens on the render thread inside a draw, so it is a hitch worth ~15 % of a 33 ms frame roughly every 4 s. This is the largest cost found here.
Result so far: the stack (#2416 → #2437 → #2478) makes the mirror sync slower on my title, not faster. #2478 is the reason.
Compared:bb01e85 (#2416's head, the counters on main3f4495a) against 2bdfb90 (#2478's head, which holds #2437 too).
Setup:
RTX 2070 SUPER (32.0.16.2140), Ryzen 5 3600XT, Windows 11 26300, release builds.
Four scripts/smoke.ps1 runs of 120 s each, alternating bb01e85, 2bdfb90, bb01e85, 2bdfb90, each built from a clean tree of its commit.
Each run started without uma_coherent.txt, so the two mirrors of my first report are made (at 35–41 s).
Menus only. Numbers are the means of the XCL_ACTIVITY lines per 2 s once the mirrors exist (~40 windows a run).
bb01e85 run 1
bb01e85 run 2
2bdfb90 run 1
2bdfb90 run 2
frames shown (120 s)
2433
2451
1889
2056
draws through the sync
702
697
533
583
copies / KB copied
1,079 / 9,704
1,072 / 9,644
819 / 7,369
895 / 8,047
indices scanned
1.78 M
1.77 M
1.35 M
1.48 M
readable() calls, time
1,619, 29.6 ms
1,609, 24.5 ms
0
0
slowest readable() / windows with one over 1 ms
18.4 ms / 41 of 41
11.2 ms / 33 of 39
–
–
time in the sync: median, mean, max
23.1, 33.3, 126 ms
21.8, 28.1, 116 ms
103.8, 101.2, 228 ms
41.4, 75.3, 243 ms
device removals / crashes
0 / 0
0 / 0
0 / 0
0 / 0
These are not comparable with my first report's numbers (4.7 ms in the sync per 2 s, 1.3 ms in readable()). This machine has been much slower since this afternoon, with a device hang on main as well. The four runs above were made back to back and alternated, so they compare with each other.
D3D12.X: the per-draw mirror sync copies only the pages the title wrote #2478 (copy only pages the write-watch says were written): this is a regression on this title. Copies fell only ~20 %, because the title rewrites these buffers every frame. A check against the source found no stale pages, and copies stayed at ~1,100–1,200 per 2 s; the bytes are the same, as found above. The GetWriteWatch call per draw costs more than the copies it saves. The sync time went up 2–4×, and frames fell 19 % (2433/2451 → 1889/2056), with the title also drawing fewer draws per 2 s.
#2437 on its own, on a second machine: removing readable() saves about 1.1 ms of render-thread time per 2 s here, and the sync as a whole costs ~4 ms per 2 s. Frames don't move, because the menus are capped at 30 fps and the sync is ~0.2 % of the frame budget on this CPU.
This is the run of #2437 alone that #2389's last comment lists as not done, on different hardware.
Setup
RTX 4070 Ti SUPER 16 GB (driver 32.0.16.1088), Ryzen 7 7800X3D, 32 GB DDR5-6000, Windows 11 26300, Rust 1.100.0, release builds.
Four scripts/smoke.ps1 runs of 120 s, alternating fdbb6fe, c24fbbf, fdbb6fe, c24fbbf. Each started without uma_coherent.txt, and there was no input (menus only).
Means of the buffer mirrors (2 s) lines from the first window with a mirror on (47–48 windows a run).
fdbb6fe run 1
c24fbbf run 1
fdbb6fe run 2
c24fbbf run 2
frames shown (120 s)
2,939
2,925
2,949
2,948
draws through the sync
778
765
764
764
copies / KB copied
1,197 / 10,757
1,177 / 10,577
1,175 / 10,563
1,175 / 10,559
indices scanned
1.98 M
1.94 M
1.94 M
1.94 M
readable() calls, time
1,795, 1.05 ms
0
1,763, 1.11 ms
0
slowest readable() (max over the run)
0.12 ms
–
0.56 ms
–
sync time in all
4.24 ms
3.69 ms
4.23 ms
4.26 ms
peak commit
14,781 MB
14,811 MB
14,808 MB
14,830 MB
No device removal and no crash in any run.
The four xcl-smoke blocks
xcl-smoke v1
commit: fdbb6fe7ec0027a5b0274364475f0204684a8c5e
gpu: NVIDIA GeForce RTX 4070 Ti SUPER
title: 333fa394
seconds: 120
exit: 0x0
frames shown: 2939 (PresentX 2939)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14781 MB
xcl-smoke v1
commit: c24fbbff5e1bcebfee2b24fd4399592664927da6
gpu: NVIDIA GeForce RTX 4070 Ti SUPER
title: 333fa394
seconds: 120
exit: 0x0
frames shown: 2925 (PresentX 2925)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14811 MB
xcl-smoke v1
commit: fdbb6fe7ec0027a5b0274364475f0204684a8c5e
gpu: NVIDIA GeForce RTX 4070 Ti SUPER
title: 333fa394
seconds: 120
exit: 0x0
frames shown: 2949 (PresentX 2949)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14808 MB
xcl-smoke v1
commit: c24fbbff5e1bcebfee2b24fd4399592664927da6
gpu: NVIDIA GeForce RTX 4070 Ti SUPER
title: 333fa394
seconds: 120
exit: 0x0
frames shown: 2948 (PresentX 2948)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14830 MB
The sync time in all doesn't fall consistently: 3.69 and 4.26 ms with D3D12.X: the per-draw mirror sync copies without asking readable() #2437 against 4.24 and 4.23 ms without. The ReadProcessMemory copy seems to cost about what the check saved here; two runs a side can't separate a 0.5 ms difference from noise.
Frames: no effect is measurable. The menus present at a steady 30 fps (60 a 2 s window) in all four runs, so a 2 ms/s saving can't show up there.
Not tested
The world, and draws with instances (none in these menus, so no whole-buffer copies).
Activity
KOLESNiii commentedon Nov 25, 2026
Measured: the sync is cheap on average, but
readable()stalls the render thread for ~5 ms every few seconds. The copies are all redundant. Mirrors only appear while the coherent window is too small.Setup: my title;
main3f4495a plus local timers and counters (not committed); release; RTX 2070 SUPER (32.0.16.2140), Ryzen 5 3600XT, Windows 11 26300. Twoscripts/smoke.ps1runs of 120 s each, both in menus (30 fps, ~390 draws/s).When mirrors exist at all. With the learned coherent window (
uma_coherent.txt, 4095 MB), the run made no mirrors, sosync_title_buffersreturned at its first check. Mirrors only appeared after I removed that file for one run, which gives the 512 MB first-run window of #284. That run made two mirrors at 32.7 s, the same as my first report: a 448 KiB index buffer and a 1.2 MiB vertex buffer, both in a sparse window. So on this title, this issue is a first-run problem.First-run window, 50–118 s, per 2 s, very steady:
readable()calls (over 16 pages)readable()What this means for each part:
readableper draw): no range was over 16 pages, so theVirtualQueryfallback I expected for large ranges never fired. But in 18 of the 43 2-s windows that had mirrors (34–118 s), a singlereadable()call on ≤16 pages took 1.1–8.8 ms, most of them 4–5 ms. That is presumablyresident_and_readablefailing on a page that is not resident, followed by theVirtualQuerywalk. It happens on the render thread inside a draw, so it is a hitch worth ~15 % of a 33 ms frame roughly every 4 s. This is the largest cost found here.Not measured: the world (never reached), and any draw with instances (none here, so no whole-buffer copies).
Measured and written with Claude Code (Claude Opus 5.5).
D3D12.X: XCL_ACTIVITY counts and times the per-draw buffer mirror sync
D3D12.X: per-draw mirror sync copies without readable() VirtualQuery
D3D12.X: per-draw mirror sync copies only pages the title wrote
KOLESNiii commentedon Nov 25, 2026
Result so far: the stack (#2416 → #2437 → #2478) makes the mirror sync slower on my title, not faster. #2478 is the reason.
Compared:
bb01e85(#2416's head, the counters onmain3f4495a) against2bdfb90(#2478's head, which holds #2437 too).Setup:
scripts/smoke.ps1runs of 120 s each, alternatingbb01e85,2bdfb90,bb01e85,2bdfb90, each built from a clean tree of its commit.uma_coherent.txt, so the two mirrors of my first report are made (at 35–41 s).XCL_ACTIVITYlines per 2 s once the mirrors exist (~40 windows a run).bb01e85run 1bb01e85run 22bdfb90run 12bdfb90run 2readable()calls, timereadable()/ windows with one over 1 msThese are not comparable with my first report's numbers (4.7 ms in the sync per 2 s, 1.3 ms in
readable()). This machine has been much slower since this afternoon, with a device hang onmainas well. The four runs above were made back to back and alternated, so they compare with each other.What each part did:
readable()per draw): the stalls show up clearly in this state of the machine: 25–30 ms per 2 s, single calls of 11–18 ms, a call over 1 ms in almost every window. D3D12.X: the per-draw mirror sync copies without asking readable() #2437 removes all of it. I have no run of D3D12.X: the per-draw mirror sync copies without asking readable() #2437 alone from this session, so I can't say how much of that comes back as the cost of its fault-tolerant copy (ReadProcessMemory). In this morning's runs, on a faster machine, the total stayed the same: 4.74 ms before and after.GetWriteWatchcall per draw costs more than the copies it saves. The sync time went up 2–4×, and frames fell 19 % (2433/2451 → 1889/2056), with the title also drawing fewer draws per 2 s.Next:
Not measured:
Measured and written with Claude Code (Claude Opus 5.5).
D3D12.X: the per-draw mirror sync copies only the pages the title wrote
D3D12.X: XCL_ACTIVITY counts and times the per-draw buffer mirror sync
D3D12.X: XCL_ACTIVITY counts and times the per-draw buffer mirror sync
D3D12.X: the per-draw mirror sync copies without asking readable()
D3D12.X: the per-draw mirror sync copies only the pages the title wrote
D3D12.X: the per-draw mirror sync writes only mirror pages whose byte…
GXLD-N commentedon Nov 26, 2026
#2437 on its own, on a second machine: removing
readable()saves about 1.1 ms of render-thread time per 2 s here, and the sync as a whole costs ~4 ms per 2 s. Frames don't move, because the menus are capped at 30 fps and the sync is ~0.2 % of the frame budget on this CPU.This is the run of #2437 alone that #2389's last comment lists as not done, on different hardware.
Setup
fdbb6fe(D3D12.X: XCL_ACTIVITY counts and times the per-draw buffer mirror sync #2416's head, counters only) againstc24fbbf(D3D12.X: the per-draw mirror sync copies without asking readable() #2437's head, which holds D3D12.X: XCL_ACTIVITY counts and times the per-draw buffer mirror sync #2416), each built from a clean tree of its commit.scripts/smoke.ps1runs of 120 s, alternatingfdbb6fe,c24fbbf,fdbb6fe,c24fbbf. Each started withoutuma_coherent.txt, and there was no input (menus only).buffer mirrors (2 s)lines from the first window with a mirror on (47–48 windows a run).fdbb6ferun 1c24fbbfrun 1fdbb6ferun 2c24fbbfrun 2readable()calls, timereadable()(max over the run)No device removal and no crash in any run.
The four
xcl-smokeblocksWhat this shows
readable()calls, the same work otherwise (copies, KB and indices match within 2 %).readable()was cheap: about 1.1 ms per 2 s, never over 0.56 ms in a single call, and no calls over 16 pages. That is far from the 1.1–8.8 ms single calls (18.4 ms at worst) on the Ryzen 5 3600XT in D3D12.X: every draw re-syncs buffer mirrors on the CPU (VirtualQuery, whole-buffer copies, index scan) #2389.ReadProcessMemorycopy seems to cost about what the check saved here; two runs a side can't separate a 0.5 ms difference from noise.Not tested
uma_coherent.txt" is the only restart here.readable()costs more.Measured and written with Claude Code (Claude Opus 5.5).
D3D12.X: the per-draw mirror sync writes only mirror pages whose byte…
D3D12.X: the per-draw mirror sync copies only the pages the title wrote
D3D12.X: the per-draw mirror sync writes only mirror pages whose byte…
D3D12.X: the per-draw mirror sync copies only the pages the title wrote
D3D12.X: the per-draw mirror sync copies only the pages the title wrote
D3D12.X: the per-draw mirror sync copies without asking readable()
D3D12.X: XCL_ACTIVITY counts and times the per-draw buffer mirror sync
D3D12.X: the per-draw mirror sync copies only the pages the title wrote