D3D12.X: forget a command list before the runtime frees it #2691

Open
github-bot wants to merge 1 commit from github-bot/gh-2691 into main AGit
Owner

@⁠SergeAx on GitHub · 2026-11-26 06:27 UTC · original
SergeAx:d3d12x-forget-lists-before-release → main · +70 −5 · 1 files · 1 commits · draft

Fixes #2690.

real::cl_release dropped what XCL keeps by a command list's address only after the runtime's final Release had freed the list, so a list created on another thread in between could get the address and lose its bind state, allocator, last submit and DRED marks. As res_release and #2422 do, the last reference (AddRef returns 2) now forgets the list first. When two last-but-one releases race, both miss it and the list is forgotten after its release, as before.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: cl_release forgets the list before the runtime's final Release (forget_command_list).
  • crates/xcl/src/hle/d3d12x/real.rs (list_release_tests): a_new_list_at_a_released_lists_address_keeps_its_state, a fake list whose Release hands its address to a new list at once.

Tested

  • NVIDIA GeForce RTX 5080, driver 621.14; AMD Ryzen 5 3500X; Windows 10 Pro 22H2 (19045.6466), D3D12 Agility SDK 1.620.2; Rust 1.100.0, debug
  • cargo test --workspace --no-fail-fast -- --test-threads=4 at 008fc961 (on main b49be183), with a retail title running on the same GPU: 1430 passed, 6 failed, 47 ignored. The 6: #1905 (fuzz_validate_and_gpu_0.._3); vram::tests::d32s8_targets_take_their_own_size_of_video_memory (#2588, which #2593 fixes); list_x::tests::a_reset_while_the_last_submit_runs_records_on_another_pc_list (#42, parallel-only; not explained by this change, see #2690).
  • SKIPPED (25): 21 × no wave64; 3 × wave32 per-lane form refused (V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32); heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
  • The new test fails with main's cl_release (the new list's bind state is gone) and passes with this change.
  • The lib test binary as --test-threads=4 hle::d3d12x::list_x, builds alternating: a_dispatch_with_a_pipeline_still_building_waits_at_the_submit failed in 13 of 200 runs on main and 6 of 200 with this change. Most of it is title_list::release's longer window, which #1453 closes (0 of 400 with #1453, 0 of 400 with both).

Regression run

  • Pending: the title is busy with another run; the two xcl-smoke blocks follow.

Not tested

  • AMD and Intel GPUs, Windows 11
  • A title run that shows the race: it was found with the test above, not in a title
  • Merging with #2138, which reorders the same three calls in cl_release: the two conflict there textually (forget_command_list would take #2138's order)

AI use

  • Claude Code (Claude Opus 5.5) found the cause, wrote the change and the test, ran the tests and measurements, and wrote this description.
**@⁠SergeAx** on GitHub · 2026-11-26 06:27 UTC · [original](https://github.com/xcl-dev/xcl/pull/2691) `SergeAx:d3d12x-forget-lists-before-release` → `main` · +70 −5 · 1 files · 1 commits · draft Fixes #2690. `real::cl_release` dropped what XCL keeps by a command list's address only after the runtime's final `Release` had freed the list, so a list created on another thread in between could get the address and lose its bind state, allocator, last submit and DRED marks. As `res_release` and #2422 do, the last reference (`AddRef` returns 2) now forgets the list first. When two last-but-one releases race, both miss it and the list is forgotten after its release, as before. **What is in it** - `crates/xcl/src/hle/d3d12x/real.rs`: `cl_release` forgets the list before the runtime's final `Release` (`forget_command_list`). - `crates/xcl/src/hle/d3d12x/real.rs` (`list_release_tests`): `a_new_list_at_a_released_lists_address_keeps_its_state`, a fake list whose `Release` hands its address to a new list at once. **Tested** - NVIDIA GeForce RTX 5080, driver 621.14; AMD Ryzen 5 3500X; Windows 10 Pro 22H2 (19045.6466), D3D12 Agility SDK 1.620.2; Rust 1.100.0, debug - `cargo test --workspace --no-fail-fast -- --test-threads=4` at `008fc961` (on `main` `b49be183`), with a retail title running on the same GPU: 1430 passed, 6 failed, 47 ignored. The 6: #1905 (`fuzz_validate_and_gpu_0`..`_3`); `vram::tests::d32s8_targets_take_their_own_size_of_video_memory` (#2588, which #2593 fixes); `list_x::tests::a_reset_while_the_last_submit_runs_records_on_another_pc_list` (#42, parallel-only; not explained by this change, see #2690). - SKIPPED (25): 21 × no wave64; 3 × wave32 per-lane form refused (`V_MUL_F16`, `V_PK_MUL_F16`, `V_CVT_F16_F32`); `heap_window_out_of_memory_falls_back_to_the_switch_form`: no heap windows - The new test fails with `main`'s `cl_release` (the new list's bind state is gone) and passes with this change. - The lib test binary as `--test-threads=4 hle::d3d12x::list_x`, builds alternating: `a_dispatch_with_a_pipeline_still_building_waits_at_the_submit` failed in 13 of 200 runs on `main` and 6 of 200 with this change. Most of it is `title_list::release`'s longer window, which #1453 closes (0 of 400 with #1453, 0 of 400 with both). **Regression run** - Pending: the title is busy with another run; the two `xcl-smoke` blocks follow. **Not tested** - AMD and Intel GPUs, Windows 11 - A title run that shows the race: it was found with the test above, not in a title - Merging with #2138, which reorders the same three calls in `cl_release`: the two conflict there textually (`forget_command_list` would take #2138's order) **AI use** - Claude Code (Claude Opus 5.5) found the cause, wrote the change and the test, ran the tests and measurements, and wrote this description.
cl_release dropped what XCL keeps by a PC command list's address
(list_x::on_release, bind::forget, dred::forget_list) only after the
runtime's final Release had freed the list, so a list created on
another thread in between could get the address and lose its bind
state, allocator, last submit and DRED marks. As in res_release and
#2422, the last reference (AddRef returns 2) now forgets the list
first.

A fake list whose Release hands its address to a new list at once
loses the new list's state on main. The parallel flake
a_dispatch_with_a_pipeline_still_building_waits_at_the_submit failed
13/200 on main and 6/200 with this change alone; #1453 closes the
longer window in title_list::release (0/400).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:34:40 +00:00
Author
Owner

@⁠SlopTart on GitHub · 2026-11-26 06:50 UTC · original · edited 2026-11-26 07:02 UTC

Tested on the Linux/Wine lane, full standard env (AMD rig: Ryzen 9 9900X, 96 GB DDR5, RX 7900 XT 20 GB, Arch kernel 7.2.15, Mesa 26.2.5 RADV, wine-11.0 Proton, rustc 1.94.0; d3d12,d3d12core,dxgi,d3d11,d3d10core=n,b overrides, official DXC kit, VKD3D_CONFIG=ignore_shared_fence, threads=2), head 008fc961, mergeable against main b49be183:
non-gpu suite (--skip gpu::): 597 passed, 3 failed, 4 ignored, 733 filtered.
The failure set is identical to bare main b49be183 measured on the same rig the same day (596 passed, 3 failed): gpu_promoted_uav_clear (our #2490), xma2_source_voice (#2481, vendored-FAudio gate). The third red, the sparse tile video-memory test, is a known batch flake (green solo).
Zero delta from this PR; every test it adds passes inside the suite.
Not tested: gpu suite, Windows native.
Correction: an earlier version of this row reported three extra reds; those runs lacked the d3d12,d3d12core=n,b DLL overrides and hit stub-DLL NOTIMPL artifacts. Re-ran with the standard env, artifacts gone.
AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.

**@⁠SlopTart** on GitHub · 2026-11-26 06:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/2691#issuecomment-7184842423) · edited 2026-11-26 07:02 UTC **Tested** on the Linux/Wine lane, full standard env (AMD rig: Ryzen 9 9900X, 96 GB DDR5, RX 7900 XT 20 GB, Arch kernel 7.2.15, Mesa 26.2.5 RADV, wine-11.0 Proton, rustc 1.94.0; `d3d12,d3d12core,dxgi,d3d11,d3d10core=n,b` overrides, official DXC kit, `VKD3D_CONFIG=ignore_shared_fence`, threads=2), head `008fc961`, mergeable against main `b49be183`: non-gpu suite (`--skip gpu::`): **597 passed, 3 failed, 4 ignored, 733 filtered**. The failure set is identical to bare main `b49be183` measured on the same rig the same day (596 passed, 3 failed): gpu_promoted_uav_clear (our #2490), xma2_source_voice (#2481, vendored-FAudio gate). The third red, the sparse tile video-memory test, is a known batch flake (green solo). Zero delta from this PR; every test it adds passes inside the suite. **Not tested**: gpu suite, Windows native. **Correction**: an earlier version of this row reported three extra reds; those runs lacked the `d3d12,d3d12core=n,b` DLL overrides and hit stub-DLL NOTIMPL artifacts. Re-ran with the standard env, artifacts gone. **AI use**: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 07:09 UTC · original

RX 6800M verification at exact PR head 008fc9618549088436a454a2247bfd4d62aeb5cc against current main b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 (Windows 11, AMD driver 30.0.13002.13003, Rust 1.99.0 MSVC):

  • cargo test --locked -p xcl --lib -j 1 hle::d3d12x::real::list_release_tests::a_new_list_at_a_released_lists_address_keeps_its_state -- --exact --test-threads=1 --nocapture: 1 passed, 0 failed, 0 ignored, 1,336 filtered. This is the synthetic pointer-reuse fixture.
  • cargo build --locked --release -p xcl -j 1: passed; head executable SHA-256 D81895D827BCDFEEAB5C971FAADC03D381C521690D74C7C40E36AFC948BD8F81.
  • Paired guarded release smoke with scripts/smoke.ps1 -Seconds 12, XCL_ADAPTER=6800M, and separate data/DXIL cache directories, on the same locally owned title build (hash 2ef5fd64):
Main b49be183 PR 008fc961
Exit 0x0 0x0
Frames shown / PresentX 147 / 147 153 / 153
Last three 2-second present windows 27, 60, 60 33, 60, 60
Device removals / crashes 0 / 0 0 / 0
Peak commit 7,512 MB 7,499 MB

I attempted a longer 60-second clean-main control. A separate low-memory monitor stopped that control after about 22 seconds when available commit fell to 1,015 MB, so there is no comparable 60-second result. These short runs show startup and presentation; they do not trigger the command-list address-reuse race or establish world-load/performance behavior. I did not run the full workspace suite on this head. AI-assisted test report with Codex.

**@⁠luckyteagirl** on GitHub · 2026-11-26 07:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/2691#issuecomment-7185153241) RX 6800M verification at exact PR head `008fc9618549088436a454a2247bfd4d62aeb5cc` against current main `b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7` (Windows 11, AMD driver `30.0.13002.13003`, Rust 1.99.0 MSVC): - `cargo test --locked -p xcl --lib -j 1 hle::d3d12x::real::list_release_tests::a_new_list_at_a_released_lists_address_keeps_its_state -- --exact --test-threads=1 --nocapture`: **1 passed, 0 failed, 0 ignored**, 1,336 filtered. This is the synthetic pointer-reuse fixture. - `cargo build --locked --release -p xcl -j 1`: passed; head executable SHA-256 `D81895D827BCDFEEAB5C971FAADC03D381C521690D74C7C40E36AFC948BD8F81`. - Paired guarded release smoke with `scripts/smoke.ps1 -Seconds 12`, `XCL_ADAPTER=6800M`, and separate data/DXIL cache directories, on the same locally owned title build (hash `2ef5fd64`): | | Main `b49be183` | PR `008fc961` | | --- | ---: | ---: | | Exit | `0x0` | `0x0` | | Frames shown / PresentX | 147 / 147 | 153 / 153 | | Last three 2-second present windows | 27, 60, 60 | 33, 60, 60 | | Device removals / crashes | 0 / 0 | 0 / 0 | | Peak commit | 7,512 MB | 7,499 MB | I attempted a longer 60-second clean-main control. A separate low-memory monitor stopped that control after about 22 seconds when available commit fell to 1,015 MB, so there is no comparable 60-second result. These short runs show startup and presentation; they do not trigger the command-list address-reuse race or establish world-load/performance behavior. I did not run the full workspace suite on this head. AI-assisted test report with Codex.
Author
Owner

@⁠sage-sage on GitHub · 2026-11-26 07:40 UTC · original

Test report: passes on NVIDIA, and with #1453 the dispatch flake from #2690 did not show in 300 parallel runs. Exact head 008fc961 (its base is current main b49be18, so head = merged).

Tested

  • RTX 4080 SUPER (driver 621.40), Ryzen 5 7600X, Windows 11 26H2 build 26300.10075, rustc 1.100.0 MSVC, DXC 1.9.2602.17 (Windows SDK 10.0.26100), debug build
  • cargo test --workspace -- --test-threads=4 on this head: 1436 passed, 0 failed, 47 ignored; on main + #2691 + #1453: 1438 passed, 0 failed, 47 ignored
  • SKIPPED: 29 lines, the same as on main on this machine (wave64, debug layer, Developer Mode, heap windows)
  • main + #2691 + #1453 merged locally (fc8561d), the lib test binary with hle:: --test-threads=12, 300 runs: a_dispatch_with_a_pipeline_still_building_waits_at_the_submit failed 0 times. On main (with only a test-only acphal change, #2700) the same setting failed it 32 times in 300 runs. The other failures in the 300 were acphal::tests::xapu_connect_returns_oom_and_cleans_up_on_failure (5), a test-only flake #2700 fixes.

Not tested

  • This PR without #1453 under the stress run (#2690 measured that one); no game; AMD / Intel.

Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

**@⁠sage-sage** on GitHub · 2026-11-26 07:40 UTC · [original](https://github.com/xcl-dev/xcl/pull/2691#issuecomment-7185709350) **Test report: passes on NVIDIA, and with #1453 the dispatch flake from #2690 did not show in 300 parallel runs.** Exact head `008fc961` (its base is current `main` `b49be18`, so head = merged). **Tested** - RTX 4080 SUPER (driver 621.40), Ryzen 5 7600X, Windows 11 26H2 build 26300.10075, rustc 1.100.0 MSVC, DXC 1.9.2602.17 (Windows SDK 10.0.26100), debug build - `cargo test --workspace -- --test-threads=4` on this head: 1436 passed, 0 failed, 47 ignored; on `main` + #2691 + #1453: 1438 passed, 0 failed, 47 ignored - SKIPPED: 29 lines, the same as on `main` on this machine (wave64, debug layer, Developer Mode, heap windows) - `main` + #2691 + #1453 merged locally (`fc8561d`), the lib test binary with `hle:: --test-threads=12`, 300 runs: `a_dispatch_with_a_pipeline_still_building_waits_at_the_submit` failed 0 times. On `main` (with only a test-only acphal change, #2700) the same setting failed it 32 times in 300 runs. The other failures in the 300 were `acphal::tests::xapu_connect_returns_oom_and_cleans_up_on_failure` (5), a test-only flake #2700 fixes. **Not tested** - This PR without #1453 under the stress run (#2690 measured that one); no game; AMD / Intel. Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
Author
Owner

@⁠KDenKC on GitHub · 2026-11-26 09:12 UTC · original

A data point from our AMD iGPU (RDNA2), list_x with --test-threads=4. The flaky a_dispatch_with_a_pipeline_still_building_waits_at_the_submit (stand-in lost, 0x0 skipped) failed 3 of 5 runs on main, 3 of 11 with this PR alone, 0 of 50 with #1453, and 0 of 50 with both. So on this fixture the remaining failures come from the title_list path #1453 fixes. The two merge cleanly together. Details are in #1453: #1453

AI use: Claude Code (Claude Opus 5.5) ran the arms and wrote this.

**@⁠KDenKC** on GitHub · 2026-11-26 09:12 UTC · [original](https://github.com/xcl-dev/xcl/pull/2691#issuecomment-7187584953) A data point from our AMD iGPU (RDNA2), `list_x` with `--test-threads=4`. The flaky `a_dispatch_with_a_pipeline_still_building_waits_at_the_submit` (stand-in lost, `0x0` skipped) failed 3 of 5 runs on `main`, 3 of 11 with this PR alone, 0 of 50 with #1453, and 0 of 50 with both. So on this fixture the remaining failures come from the `title_list` path #1453 fixes. The two merge cleanly together. Details are in #1453: https://git.gtahub.st/github/xcl-dev--xcl/pulls/1453 AI use: Claude Code (Claude Opus 5.5) ran the arms and wrote this.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2691/head:github-bot/gh-2691'
git switch 'github-bot/gh-2691'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2691'
git switch 'github-bot/gh-2691'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2691'
git switch 'github-bot/gh-2691'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2691'
git switch 'main'
git merge --squash 'github-bot/gh-2691'
git switch 'main'
git merge --ff-only 'github-bot/gh-2691'
git switch 'main'
git merge 'github-bot/gh-2691'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.