Skip to content

D3D12.X: retain deferred Write64 until the producer fence completes - #850

Open
Abuudiii wants to merge 2 commits into
xcl-dev:mainfrom
Abuudiii:xcl-deferred-write64
Open

Abuudiii wants to merge 2 commits into
xcl-dev:mainfrom
Abuudiii:xcl-deferred-write64

Conversation

@Abuudiii

@Abuudiii Abuudiii commented Nov 24, 2026 •

Copy link
Copy Markdown

Follow-up to #708. A non-UMA Write64BitValueBottomOfPipeX progress value could become visible when its producer fence was still pending. Wait for confirmed completion before publishing the 64-bit word, without changing the upstream GPU wait bridge.

What is in it

  • Publish immediate 64-bit progress atomically after the producer fence completes. Retain the late write and its ordered suffix on the originating queue's worker so other queues can keep publishing.
  • Add a real-fence regression for publication after the legacy timeout and progress on an independent queue.
  • Merged main at 1ec4c98: D3D12.X: name XCL's own tile-mapping lists and say when a wait for a queue gives up #873’s throttled warning still reports the legacy fallback, without suggesting that a deferred 64-bit progress value was published early.

Tested

  • Local Core i9-12900K / RX 9070, RADV 26.2.5, GE-Proton 11-7 / vkd3d-proton 3.1, Rust 1.99.1 Windows GNU debug: the regression on beaa245 observed 0x123456789abcdef0 while the producer fence was still zero. With the patch, cpu_writes::tests:: reported 3 passed, 0 failed, 0 ignored, including independent queue progress.
  • Independent native Windows report: Ryzen 7 9800X3D / RX 9070 XT, driver 32.0.32015.16001, Rust 1.100.0. On the local integration with main a1672ef, cargo test --workspace -- --test-threads=4 reported 714 passed, 0 failed, 41 ignored, no GPU skips. cargo test -p xcl --lib cpu_writes reported 4 passed, 0 failed.
  • Conflict resolution at a314f04: on the RX 9070 / GE-Proton setup above, cargo test --locked --offline --target x86_64-pc-windows-gnu -p xcl --lib hle::d3d12x::cpu_writes::tests:: -- --test-threads=1 --nocapture reported 3 passed, 0 failed, 0 ignored, no skips. The regression exercised both the legacy fallback warning and the 64-bit pending-producer warning while the fence was still pending.

Regression run
The previous native Windows report contains the clean main baseline below and a smoke for the prior PR head 8ad4155. That PR-head smoke does not apply after the merge. A fresh run at a314f04 is pending; the baseline is reusable for the same setup, title, and duration.

xcl-smoke v1
commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2
gpu: AMD Radeon RX 9070 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1660 (PresentX 1660)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14862 MB

Not tested

  • Native Windows tests and exact-head retail smoke after the merge at a314f04; wave32-only GPUs and gameplay past the menus.

AI use

  • omp (GPT-6.2 Sol) implemented the change, resolved the merge, ran the local Proton checks, and drafted this description. The linked pre-merge Windows results were reported independently.

Do not publish a CPU-visible 64-bit progress value when its GPU fence has not reached the submission. Keep the timed-out progress write and its suffix ordered on the originating queue’s worker; other queues can still publish.
On base beaa245 the real-fence regression observed 0x123456789abcdef0 before fence completion. With the fix, three deferred-write tests pass on RX 9070 / GE-Proton, including the independently completing second queue. Native Windows and a retail smoke pair were not run.
Refs: xcl-dev#708
Assisted-by: omp (GPT-6.2 Sol)
@eizispark

eizispark commented Nov 24, 2026 •

Copy link
Copy Markdown

Hardware check of a314f04d798d6d73c65096d317e1369f045c1ac9 (verified clean merge with main 1ec4c98): pass.

Tested

  • Hardware: AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11, rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profile
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 713 passed, 3 failed, 41 ignored (GPU tests skipped on this adapter: none); the 3 failures were the known concurrent --test-threads=4 VRAM contention flake in hle::d3d12x::title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels plus two downstream mutex PoisonError cascades (transitions_apply_when_their_list_is_submitted and d32s8_targets_take_their_own_size_of_video_memory)
  • cargo test -p xcl --lib hle::d3d12x -- --test-threads=1: 115 passed, 0 failed, 1 ignored (GPU tests skipped on this adapter: none)
  • Verified hle::d3d12x::cpu_writes::tests::write64_bottom_progress_waits_past_legacy_timeout, hle::d3d12x::cpu_writes::tests::writes_land_after_the_queue, hle::d3d12x::cpu_writes::tests::readback_u64_lands_after_the_queue, and hle::d3d12x::list_x::tests::timestamps_outside_unified_memory_land_after_the_queue (ok)

Regression run
main (beaa245):

xcl-smoke v1
commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1660 (PresentX 1660)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14862 MB

PR (a314f04):

xcl-smoke v1
commit: a314f04d798d6d73c65096d317e1369f045c1ac9
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1666 (PresentX 1667)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14855 MB

Not tested

  • wave32-only GPUs (NVIDIA / Intel); gameplay past the menus

AI use

  • Antigravity (Gemini 4 Carbon) ran the build, test suite, and scripts/smoke.ps1 harness on this machine and formatted this report.

@badoomtch

badoomtch commented Nov 24, 2026 •

Copy link
Copy Markdown

Updated head a314f04d on native Windows

I ran the unmodified 60-second smoke script from clean release checkouts of main and the updated PR head, on the same RTX 5080, with fresh offline state for each run. Both exited cleanly.

Main

xcl-smoke v1
commit: 1ec4c98cda119432a4b3f205e146fba2d6f8379a
gpu: NVIDIA GeForce RTX 5080
title: ScarlettGame
seconds: 60
exit: 0x0
frames shown: 196 (PresentX 196)
presents per 2 s (last 3): 10 10 11
device removals: 0
crashes: 0
peak commit: 15081 MB

Updated PR head

xcl-smoke v1
commit: a314f04d798d6d73c65096d317e1369f045c1ac9
gpu: NVIDIA GeForce RTX 5080
title: ScarlettGame
seconds: 60
exit: 0x0
frames shown: 190 (PresentX 190)
presents per 2 s (last 3): 8 9 9
device removals: 0
crashes: 0
peak commit: 15069 MB

On the local integration containing both changed Rust files byte-for-byte from a314f04d, all three deferred-write tests passed. In the mixed-write test the legacy prefix reached the 10-second fallback. The following 64-bit progress write stayed pending until its producer fence completed. The 60-second retail tests ended before the later world-loading transition.


Tested on native Windows 11 build 26300, Core Ultra 7 265, RTX 5080 (610.88), Rust 1.96.0 MSVC.

At the exact PR head 8ad4155, all three hle::d3d12x::cpu_writes::tests passed in debug (0 failed, 0 ignored). The real-fence test crossed the 10 s deadline with the first queue's write still unpublished, allowed the independent queue to complete, and then verified the first queue's ordered writes after its fence signalled.

60-second retail regression pair. Clean release builds of the PR parent and head. Each checkout's unmodified scripts/smoke.ps1 ran through the same local launcher, which adds a network-isolated Windows AppContainer and passes through the real process exit status and log. Both used fresh title state and the script's default 60 s duration.

Parent:

xcl-smoke v1
commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2
gpu: NVIDIA GeForce RTX 5080
title: ScarlettGame
seconds: 60
exit: 0x0
frames shown: 200 (PresentX 200)
presents per 2 s (last 3): 8 9 8
device removals: 0
crashes: 0
peak commit: 15089 MB

PR head:

xcl-smoke v1
commit: 8ad4155fcf6b90e0e2295780548e27b099478d39
gpu: NVIDIA GeForce RTX 5080
title: ScarlettGame
seconds: 60
exit: 0x0
frames shown: 185 (PresentX 185)
presents per 2 s (last 3): 11 10 9
device removals: 0
crashes: 0
peak commit: 15071 MB

Longer integration runs. On our separate integration build based on beaa245, the control recorded 1,450 presents and hit the title watchdog at 111.469 s. Adding the two runtime files from 8ad4155 to that same build gave 1,325 presents and the same abort at 110.386 s. Its last saved capture, frame 1,320, was fading loading artwork. Both logged one command-list split, five GPU wait bridges, and zero legacy Wait64 timeout messages. The PR's ten-second producer warning did not appear in the game run. Outstanding GPU waits at exit were not measured. This pair establishes native ordering in the regression fixture; the longer runs still stop during loading.

AI use: Codex (GPT-6) ran the tests, checked the captured reports and drafted this comment.

@SlopTart

Copy link
Copy Markdown

Linux / AMD RDNA3 datapoint.

Merged state: head 8ad4155 onto main beaa245, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 704 passed, 10 failed, 41 ignored. Failures are the known Wine-lane set from my #42 rows plus #718 trio members; nothing here fails because of your change. Deferred Write64 retention tests green; no new failures against the known Wine-lane set.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

Keep the legacy fallback warning from xcl-dev#873 and hold deferred 64-bit progress until its producer fence completes. Focused cpu_writes suite: 3 passed on RX 9070 / GE-Proton with both paths exercised.

Assisted-by: omp (GPT-6.2 Sol)
@iggyvilla

Copy link
Copy Markdown
Collaborator

Read of a314f04 (not built or run by me; the loop below is unchanged since 8ad4155), one point on the new wait in cpu_writes.rs:

In spawn_queue_worker, once the 10 s wait has timed out for a Write::ImmediateU64, the worker loops on fence::completed_value every 20 ms until the value reaches job.value, with no deadline. It leaves the loop only when the fence completes or completed_value returns an error (a removed device). If the producer's queue is stuck but the device is not removed, that worker never leaves the loop, holds the device and fence, and every later write queued on that queue waits behind it; forget_queue only disconnects the channel after the outstanding jobs drain, so it does not end it either. Before this change the worker wrote after 10 s and moved on.

Holding the value back is the point of the PR, so a very long wait may be the right call. A hard upper bound (a few minutes, then an error log and either dropping the write or writing it) would keep one hung queue from keeping a thread and the queue's later writes forever. Whether the title can produce a producer fence that never completes without a device removal I don't know.

AI use: read with Claude Code, Claude Sonnet 5.5, against the PR head; the point is mine.

wondercrash pushed a commit to wondercrash/xcl that referenced this pull request Nov 24, 2026
wondercrash pushed a commit to wondercrash/xcl that referenced this pull request Nov 24, 2026
… split

xcl-dev#708 predates xcl-dev#795 (GPU-fence bridge) and xcl-dev#797 (mid-list split) and was
not rebased. Resolution keeps main's split machinery (xcl-dev#797 + xcl-dev#851) and
cpu_writes from xcl-dev#850 (the xcl-dev#708 per-queue workers with xcl-dev#873's
diagnostics), and ports xcl-dev#708's core change onto it:

- wait_gate.rs (from xcl-dev#708): a queue-side gate the CPU opens once it
  sees the progress value.
- PendingWait::gate: a Wait64 GE, full mask, on a non-sparse value the
  CPU can read, in a direct/compute title list, that starts its PC
  segment (split by xcl-dev#797/xcl-dev#851, or nothing recorded before it).
- execute_with_waits_on / KickoffX: gated waits arm a wait_gate instead
  of the xcl-dev#795 GPU-fence bridge; with sparse writes at or after the list
  in the batch they take the bounded CPU wait (xcl-dev#708's rule). Other waits
  keep the xcl-dev#795 bridge. Arming failure stops the title (xcl-dev#708).
- Dropped from xcl-dev#708: its own title_list piece/split machinery,
  split_recording, restore_after_reopen, open-query / split-barrier
  tracking and the Result-returning execute_with_waits.
- wait_tests.rs (from xcl-dev#708) adapted to push_segments /
  execute_with_waits_on.
@iggyvilla

Copy link
Copy Markdown
Collaborator

Read of a314f04 (not built or run by me; the loop below is unchanged since 8ad4155), one point on the new wait in cpu_writes.rs:

In spawn_queue_worker, once the 10 s wait has timed out for a Write::ImmediateU64, the worker loops on fence::completed_value every 20 ms until the value reaches job.value, with no deadline. It leaves the loop only when the fence completes or completed_value returns an error (a removed device). If the producer's queue is stuck but the device is not removed, that worker never leaves the loop, holds the device and fence, and every later write queued on that queue waits behind it; forget_queue only disconnects the channel after the outstanding jobs drain, so it does not end it either. Before this change the worker wrote after 10 s and moved on.

Holding the value back is the point of the PR, so a very long wait may be the right call. A hard upper bound (a few minutes, then an error log and either dropping the write or writing it) would keep one hung queue from keeping a thread and the queue's later writes forever. Whether the title can produce a producer fence that never completes without a device removal I don't know.

AI use: read with Claude Code, Claude Sonnet 5.5, against the PR head; the point is mine.

@throny

throny commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Two world-loading runs of a314f04 on an RTX 4080 with XCL_PSO_WAIT_MS=50, against two runs of main with the same settings. Both runs of this PR were still presenting when my memory guard ended them, later than any main run has lived here, but with more timed-out GPU waits and more memory.

Tested

  • Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 4080 16 GB (driver 610.88, 32-lane waves), Intel i9-12900K, 64 GB; Rust 1.100.0 stable-x86_64-pc-windows-msvc; release. a314f04 merged onto main 47efa2e (clean merge); the main runs are on 384f7f7.
  • xcl run <folder> with XCL_NETWORK=0, XCL_ACTIVITY=1, XCL_PSO_WAIT_MS=50, XCL_PRESS_AT for the profile prompt, 420 s limit, warm DXIL and driver-blob caches. Retail title 1.0.2.1.
this PR, run 1 this PR, run 2 main, run 1 main, run 2
last present 188 s 204 s 132 s 114 s
presents after 82 s 20 39 24 20
GPU queue.Wait … did not complete within 5000 ms 110, from 107.2 s 246, from 121.2 s 78, from 122.3 s 29, from 112.4 s
end my memory guard (free commit on the machine under 4 GB) my memory guard my memory guard at ~134 s watchdog at 170.0 s
draws / dispatches skipped 16 384 / 3 848 17 756 / 4 096 12 899 / 2 048 6 922 / 333
peak commit 34.3 GB 34.1 GB 33.9 GB 32.7 GB
video memory, local (peak) 16.2 GB 15.9 GB 15.7 GB 15.6 GB
  • No device removal, and no watchdog stop in either run of this PR within 188 s and 204 s; main has never got past 174 s here. Neither run shows where the title would stop with this PR: my guard ended them when the machine's free commit fell under 4 GB (the process at 34 GB; this PC's commit limit is about 68 GB and another job was running).
  • The timed-out waits do not go away: 110 and 246, the most I have counted in a run.

Not tested

  • More than two runs; the test suite on this head; AMD; without XCL_PSO_WAIT_MS.

AI use

  • Claude Code (Claude Fable 5.2) read the diff, built the tree, ran the title and wrote this report. Counts and XCL's own log text only.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
@JJAutoCompare

Copy link
Copy Markdown

Empirical test report (a314f04)

Verified PR #850 at a314f04d798d6d73c65096d317e1369f045c1ac9.

Hardware / environment

  • Windows x64 build 26200, AMD CPU (family 23, model 113), Intel Arc A770 (PCI 8086:56A0). A D3D12 probe confirmed the A770 as the default adapter used by the fixtures' device creation path.
  • Rust 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2609.5 (01b62ad47). Unoptimized Cargo test profile with debug info and incremental compilation disabled.

Commands and results

  • cargo test --workspace --no-run finished with exit code 0 outside the Arc test lock.

  • Ran the prebuilt library test executable inside Invoke-ArcTest.ps1 with XCL_ADAPTER=A770 and RUST_TEST_NOCAPTURE=1:

    xcl-77aca8ccb20e299f.exe hle::d3d12x::cpu_writes::tests:: hle::d3d12x::list_x::tests::timestamps_outside_unified_memory_land_after_the_queue --test-threads=2
    
  • Exit code 0. 4 passed, 0 failed, 0 ignored, 0 skipped, with 692 filtered out. The focused run took 11.19 s.

Observed behavior

  • The timeout regression logged the legacy fallback at 10,000 ms with the producer fence at 0 and a target of 1. It also logged that the deferred 64-bit write was still waiting. The fixture verified that the legacy prefix and an unrelated queue's write landed while the producer was held. Its trailing marker stayed pending, and after the fence was signaled the marker exposed the expected 64-bit progress value.
  • The regular CPU write, the 64-bit readback write, and the non-UMA top- and bottom-of-pipe timestamp fixtures also passed.

Not tested

The full GPU workspace suite and game smoke runs were omitted.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr850-focused.log and published.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

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

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants