Skip to content

D3D12.X: a submit misses a CPU write into memory idle for 1.5 s (hot write-watch looks); intermittent e2e failure #3382

Backlog

Description

@tiagonleal

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

  1. 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.
  2. 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

  1. tiagonleal commented on Nov 29, 2026

    @tiagonleal
    ContributorAuthor

    #3437 covers one part of this: CopyIntoSubresource now 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.

    • Tiago
  2. andrewDoing commented on Nov 29, 2026

    @andrewDoing
    Contributor

    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.

    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.

  3. tiagonleal commented on Nov 29, 2026

    @tiagonleal
    ContributorAuthor

    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:

    • Asking the write watch about the cold ranges at every submit is the full look again. The comment on hot_looks in title_textures.rs gives 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.
    • Looking only at the memory the submitted lists use: refresh_for gets 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).
    • A faster walk or a rotating slice of the cold space shortens the delay but the next submit can still miss the write.

    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_looks describes 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 the CopyIntoSubresource case behind the e2e failure.

    • Tiago
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions