Repository navigation
Description
With the default XCL_WATCH_HOT looks, a submit does not see a CPU write into a 2 MiB block that nothing wrote to in the last 1.5 s, unless the xcl-watch-walk thread reaches the block between the write and the submit. The texels go up with a later submit. This is also the cause of an intermittent e2e failure on main.
How it shows on main (d8bd9a38)
The test title's check D3D12.X: a texture in title memory (XG layout, #44) follows CPU writes fails now and then with subresource 2 row 0 differs from the title memory. Here it failed in 2 of 4 whole-suite runs today, once in test_title_draws_with_a_root_signature_under_the_debug_layer and once in test_title_runs_under_the_debug_layer_with_dred. The e2e target alone passed 6 of 6 runs right after (3 on main, 3 on a PR tree; one of the two failures was in that PR tree, which does not touch this code). @thisguyStan reported the same line in #42 on 26 Nov (1 of 4 full runs, in test_title_runs_and_game_folder_is_untouched).
Cause
The check (tests/testtitle/src/gpu.rs, around line 886) reads the texture back, rewrites subresource 2 with CopyIntoSubresource and submits at once. Subresource 2 is the only one it rewrites, which is why it is always the one that differs.
In title_textures.rs, a look before ExecuteCommandLists calls take_hot when hot_looks() is on (the default). take_hot asks the write watch only about blocks where a write was seen in the last hot_for() (1500 ms, XCL_WATCH_HOT_MS). The other blocks are left to the walk thread, which marks a block hot when it finds a written page there. The comment on hot_looks says that takes about 10 ms. A submit that comes sooner than that after a write into a cold block goes to the GPU with the old texels. When the suite keeps the machine busy, more than 1.5 s passes between the look that last saw the block written and the rewrite, so the block is cold at the moment that matters.
The hot looks came in with 7c18bc41.
Proof by forced timing
With a sleep added in the test title between the first readback and the rewrite (a local change, read from an environment variable, not pushed), test_title_runs_under_the_debug_layer_with_dred, 5 runs each, debug build:
| setting | check failed |
|---|---|
| sleep 2000 ms | 5 of 5, same message |
| sleep 1000 ms | 0 of 5 |
sleep 2000 ms, XCL_WATCH_HOT=0 |
0 of 5 |
| no sleep | 0 of 5 |
The change between 1000 and 2000 ms matches the 1500 ms window, and with the hot looks off the failure is gone. With XCL_WATCH_HOT_MS=20 and no sleep, another check of the test title fails as well (async ring-buffered sparse uploads ... submit N head mismatch: got 0x0), so this is not limited to title textures.
Without the sleep I could not make it fail outside a whole-suite run: 0 of 90 runs of the three e2e tests, alone or with two loops in parallel.
What it means for a title
A title that writes texels (or anything else the looks carry to the GPU) into memory it left alone for more than 1.5 s and submits within the walk's delay gets the old contents for that submit. Streaming into a pool slot after a pause fits that. I have not traced any artifact in a retail title to this.
Possible fixes, none written
- A look also takes the pages behind title textures that are bound or copied in the lists being submitted, hot or not. That adds write-watch calls per submit, the cost the hot looks were made to cut.
- A trap on cold blocks, so the first write makes the block hot at once. Closed D3D12.X: XCL_WATCH_TRAP=1 leaves memory nobody writes out of the write-watch looks (off by default) #2934 (
XCL_WATCH_TRAP) went that way.
Both trade frame time against this gap, so I am leaving the choice to whoever owns the hot looks (@theaustinayers by the commit). Until then the e2e check will keep failing now and then under load; XCL_WATCH_HOT=0 in the e2e environment would hide it there without fixing the default.
Tested on: Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 5070 Ti 16 GB (driver 617.42), AMD Ryzen 7 9800X3D, 32 GB RAM, rustc 1.100.0, debug.
Not tested: AMD or Intel; a retail title with XCL_WATCH_HOT=0 against the default for visible differences; how long the walk really takes under load (the 10 ms is from the code comment).
Related: #582 (the cost the hot looks address), #3180 (other intermittent test failures), #3242 (open, changes write-watch ranges, not the hot window).
AI use: Claude Code (Claude Fable 5.2) wrote this issue; Claude Opus 5.5 read the code and ran the forced-timing runs.
Activity
tiagonleal commentedon Nov 29, 2026
#3437 covers one part of this:
CopyIntoSubresourcenow marks the blocks it wrote hot, so the next look takes them. That is the write behind the intermittent e2e failure; with the forced 2 s pause the check went from failing 5 of 5 to passing 5 of 5.It does not touch raw stores by the title's own code into a block idle for more than 1.5 s. Those still wait for the walk, so the question in this issue stays open for them.
andrewDoing commentedon Nov 29, 2026
I reproduced the remaining raw-store case on an RTX 5070 12 GB (616.92) and Ryzen 7 5700X3D. The fixture first filled a registered 64×64 R8 texture through its write-watched CPU mirror and checked the initial native readback. It let the block age past 1.5 s, then used ordinary CPU stores to change exactly 64 texels in one row. It called the production submit-preparation helper (
refresh_for) and fenced a native texture read on that queue. The readback helper did not run a second refresh.0fe06eb0, normal background walker: the first read held all old texels in 6 of 6 fresh processes, split evenly between look-ahead off andXCL_LOOK_AHEAD=2. After the walker made the block hot, the next submit returned all 64 changed texels and preserved the other 4,032.f4f2bff7and D3D12.X: XCL_LOOK_AHEAD takes written pages between submits by default #34360ef9307a: the raw-store read was stale once on each exact head with the walker running normally. In a second control on each head, I held the periodic walker until after that read and waited for a complete look-ahead round to start after the write. The first read still held the old values. On D3D12.X: XCL_LOOK_AHEAD takes written pages between submits by default #3436 the look-ahead setting was unset, so this exercised the proposed 2 ms default.cargo test --locked --offline -p xcl --lib -- hle::d3d12x::title_textures::tests::gpu_raw_cold_write_first_submit --exact --test-threads=1 --nocapture. Each of the 14 fresh processes passed its expected outcome with zero skips (debug, Windows 11 26300.10075, Rust 1.100.0). This extends the reproduction to raw CPU stores and fenced readback. It covers the production preparation helper and a native copy. Retail frequency, frame cost, and complete guest command-stream coverage remain unmeasured. Codex with GPT-6.2 Sol adapted the test-only fixture and ran the controls.tiagonleal commentedon Nov 29, 2026
I looked for a fix for the raw-store case that would cost the submit nothing, and did not find one. What I ruled out, so nobody repeats it:
hot_looksintitle_textures.rsgives 4.3 to 4.9 ms for a look over 8 GiB however few pages were written, and that cost is what the hot looks were made to avoid.refresh_forgets the queue and the list pointers and nothing about what the lists read. Descriptor tables are title memory that the shaders index themselves (console_heap.rs), and a root view comes without a size (view_want.rs).That leaves trapping the write itself (#2294 is an open attempt at that for physical-page views, #2934 was a closed one for the looks), which is not a small change. So for raw stores the behaviour stays as the comment on
hot_looksdescribes it: the write is seen once the walk has found the block, and it is late for the submits before that, never lost. #3437 covers theCopyIntoSubresourcecase behind the e2e failure.