D3D12.X: clear dispatch_chain shared scratch on list lifecycle transitions #2543

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

@⁠ramon-victor on GitHub · 2026-11-25 22:25 UTC · original
ramon-victor:fix/dispatch-chain-shared-scratch-reset → main · +78 −0 · 3 files · 1 commits · open

Clears dispatch_chain::SHARED entries when command lists are created, released, recycled as split segments, or reset/closed via console_list, preventing a new recording from reusing an in-flight recording's split-dispatch scratch buffer.

Previously real::dispatch_chain::list_reset was called only from list_x::reset_copy_scratch, never from list_x::on_create, list_x::on_release, list_x::clear_segment_state, or console_list (create_with_allocator, cl_reset, cl_release, close). When a command list recording split compute dispatches on allocator A was submitted and released while in flight, a newly created command list reusing the same pointer on A (or a recycled Wait64 split segment or reset console list) matched SHARED[list] and reused the active scratch buffer without synchronization.

Part of #2459 (specifically item 1; item 2 is tracked separately by #2333/#2519).

What is in it

  • crates/xcl/src/hle/d3d12x/list_x.rs: call super::real::dispatch_chain::list_reset in on_create, on_release, and clear_segment_state alongside title_textures::list_reset.
  • crates/xcl/src/hle/d3d12x/console_list.rs: call super::real::dispatch_chain::list_reset for the backing PC list in create_with_allocator, cl_reset, cl_release, and close.
  • crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs: add tests::list_lifecycle_transitions_clear_shared_scratch verifying that list_x::on_release, list_x::on_create, list_x::clear_segment_state, and console_list Reset/Release all clear SHARED so subsequent scratch_for calls allocate a fresh scratch buffer.

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 3070 8 GiB (driver 621.24, wave32), AMD Ryzen 7 5700X, 32 GiB RAM, Windows 11 Pro (26300), rustc 1.99.0 (x86_64-pc-windows-msvc), DXC/DXIL 1.8.2502.11 (Windows SDK 10.0.26100.0).
  • Failing-first before fix: cargo test -p xcl --lib list_lifecycle_transitions_clear_shared_scratch -- --nocapture failed (0 passed, 1 failed: on_release must clear shared dispatch scratch).
  • After fix: cargo test -p xcl --lib hle::d3d12x::real::dispatch_chain::tests -- --test-threads=1: 3 passed, 0 failed, 0 ignored.
  • Full workspace suite (.\scripts\test.ps1, debug): 1424 passed, 0 failed, 46 ignored (skipped on this adapter: wave64-only GPU tests, unsupported per-lane semantics variants, no heap windows).
  • Release build (cargo build --release -p xcl) and clean 60 s retail smoke run (.\scripts\smoke.ps1).

Regression run

Baseline (main):

xcl-smoke v1
commit: f087b998d0d51a9f11bbfa0761967a63e778edd9
gpu: NVIDIA GeForce RTX 3070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14467 MB

PR (12141cc):

xcl-smoke v1
commit: 12141ccbfa162b7e169d913a20c1b7e3fd1bf1dd
gpu: NVIDIA GeForce RTX 3070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1628 (PresentX 1628)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14070 MB

Not tested

  • Multi-queue retail stress triggering live command-list address reuse across in-flight split dispatches (covered deterministically by list_lifecycle_transitions_clear_shared_scratch).
  • AMD / Intel GPUs and Wine / macOS hosts.

AI use

  • Antigravity (Gemini 4 Neon): analyzed #2459 item 1, added dispatch_chain::list_reset across the missing command-list and console-list lifecycle hooks with a failing-first test, ran .\scripts\test.ps1, release build, and the 60 s smoke.ps1 run, and drafted this PR description.
**@⁠ramon-victor** on GitHub · 2026-11-25 22:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/2543) `ramon-victor:fix/dispatch-chain-shared-scratch-reset` → `main` · +78 −0 · 3 files · 1 commits · open Clears `dispatch_chain::SHARED` entries when command lists are created, released, recycled as split segments, or reset/closed via `console_list`, preventing a new recording from reusing an in-flight recording's split-dispatch scratch buffer. Previously `real::dispatch_chain::list_reset` was called only from `list_x::reset_copy_scratch`, never from `list_x::on_create`, `list_x::on_release`, `list_x::clear_segment_state`, or `console_list` (`create_with_allocator`, `cl_reset`, `cl_release`, `close`). When a command list recording split compute dispatches on allocator `A` was submitted and released while in flight, a newly created command list reusing the same pointer on `A` (or a recycled `Wait64` split segment or reset console list) matched `SHARED[list]` and reused the active scratch buffer without synchronization. Part of #2459 (specifically item 1; item 2 is tracked separately by #2333/#2519). **What is in it** - `crates/xcl/src/hle/d3d12x/list_x.rs`: call `super::real::dispatch_chain::list_reset` in `on_create`, `on_release`, and `clear_segment_state` alongside `title_textures::list_reset`. - `crates/xcl/src/hle/d3d12x/console_list.rs`: call `super::real::dispatch_chain::list_reset` for the backing PC list in `create_with_allocator`, `cl_reset`, `cl_release`, and `close`. - `crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs`: add `tests::list_lifecycle_transitions_clear_shared_scratch` verifying that `list_x::on_release`, `list_x::on_create`, `list_x::clear_segment_state`, and `console_list` `Reset`/`Release` all clear `SHARED` so subsequent `scratch_for` calls allocate a fresh scratch buffer. **Tested** - Hardware / toolchain: NVIDIA GeForce RTX 3070 8 GiB (driver `621.24`, wave32), AMD Ryzen 7 5700X, 32 GiB RAM, Windows 11 Pro (`26300`), `rustc 1.99.0` (`x86_64-pc-windows-msvc`), DXC/DXIL `1.8.2502.11` (Windows SDK `10.0.26100.0`). - Failing-first before fix: `cargo test -p xcl --lib list_lifecycle_transitions_clear_shared_scratch -- --nocapture` failed (`0 passed, 1 failed`: `on_release must clear shared dispatch scratch`). - After fix: `cargo test -p xcl --lib hle::d3d12x::real::dispatch_chain::tests -- --test-threads=1`: `3 passed, 0 failed, 0 ignored`. - Full workspace suite (`.\scripts\test.ps1`, debug): `1424 passed, 0 failed, 46 ignored` (skipped on this adapter: wave64-only GPU tests, unsupported per-lane semantics variants, `no heap windows`). - Release build (`cargo build --release -p xcl`) and clean 60 s retail smoke run (`.\scripts\smoke.ps1`). **Regression run** Baseline (`main`): ``` xcl-smoke v1 commit: f087b998d0d51a9f11bbfa0761967a63e778edd9 gpu: NVIDIA GeForce RTX 3070 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14467 MB ``` PR (`12141cc`): ``` xcl-smoke v1 commit: 12141ccbfa162b7e169d913a20c1b7e3fd1bf1dd gpu: NVIDIA GeForce RTX 3070 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1628 (PresentX 1628) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14070 MB ``` **Not tested** - Multi-queue retail stress triggering live command-list address reuse across in-flight split dispatches (covered deterministically by `list_lifecycle_transitions_clear_shared_scratch`). - AMD / Intel GPUs and Wine / macOS hosts. **AI use** - Antigravity (Gemini 4 Neon): analyzed #2459 item 1, added `dispatch_chain::list_reset` across the missing command-list and console-list lifecycle hooks with a failing-first test, ran `.\scripts\test.ps1`, release build, and the 60 s `smoke.ps1` run, and drafted this PR description.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:33:22 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 22:32 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 22:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/2543#issuecomment-7176482902) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠xpatfussy69x on GitHub · 2026-11-25 22:40 UTC · original

Test run on exact head 12141cc (12141ccbfa162b7e169d913a20c1b7e3fd1bf1dd, on its base e1d84b7), clean tree.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.2124, 32-lane waves only), AMD Ryzen 5 7500F, Windows 11, Rust 1.100.0; debug build for the tests, release for the smoke runs
  • cargo test --workspace -- --test-threads=4: 1424 passed, 0 failed, 46 ignored
  • SKIPPED (25): 21 × no wave64; 1 × no heap windows; 3 × per-lane form refused V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32 (on main too)
  • cargo test -p xcl --lib list_lifecycle: 1 passed, 0 failed
  • This PR's new tests in the workspace run:
    • list_lifecycle_transitions_clear_shared_scratch: ok
  • Conflicts with #2532 in crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs (git merge-tree of both heads); whichever lands second needs a rebase

Regression run (60 s, default settings, a retail title)

main:

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1091 (PresentX 1091)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14814 MB

this PR:

xcl-smoke v1
commit: 12141ccbfa162b7e169d913a20c1b7e3fd1bf1dd
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1137 (PresentX 1137)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14777 MB

No crash or device removal; frames 104 % of main's, peak commit 100 %.

Not tested

  • Whether the title runs a split compute dispatch on a released and recreated list in this run: a regression check only
  • The PR merged into current main (tested on its own base; it merges into e1d84b7 without conflicts)
  • AMD / native wave64

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and both smoke runs on the machine above and wrote this report.
**@⁠xpatfussy69x** on GitHub · 2026-11-25 22:40 UTC · [original](https://github.com/xcl-dev/xcl/pull/2543#issuecomment-7176659057) Test run on exact head `12141cc` (`12141ccbfa162b7e169d913a20c1b7e3fd1bf1dd`, on its base `e1d84b7`), clean tree. **Tested** - NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.2124, 32-lane waves only), AMD Ryzen 5 7500F, Windows 11, Rust 1.100.0; debug build for the tests, release for the smoke runs - `cargo test --workspace -- --test-threads=4`: 1424 passed, 0 failed, 46 ignored - SKIPPED (25): 21 × no wave64; 1 × no heap windows; 3 × per-lane form refused `V_MUL_F16` / `V_PK_MUL_F16` / `V_CVT_F16_F32` (on `main` too) - `cargo test -p xcl --lib list_lifecycle`: 1 passed, 0 failed - This PR's new tests in the workspace run: - `list_lifecycle_transitions_clear_shared_scratch`: ok - Conflicts with #2532 in `crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs` (`git merge-tree` of both heads); whichever lands second needs a rebase **Regression run** (60 s, default settings, a retail title) main: ``` xcl-smoke v1 commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea gpu: NVIDIA GeForce RTX 3060 title: c3f791f3 seconds: 60 exit: 0x0 frames shown: 1091 (PresentX 1091) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14814 MB ``` this PR: ``` xcl-smoke v1 commit: 12141ccbfa162b7e169d913a20c1b7e3fd1bf1dd gpu: NVIDIA GeForce RTX 3060 title: c3f791f3 seconds: 60 exit: 0x0 frames shown: 1137 (PresentX 1137) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14777 MB ``` No crash or device removal; frames 104 % of `main`'s, peak commit 100 %. **Not tested** - Whether the title runs a split compute dispatch on a released and recreated list in this run: a regression check only - The PR merged into current `main` (tested on its own base; it merges into `e1d84b7` without conflicts) - AMD / native wave64 **AI use** - Claude Code (Claude Opus 5.5) ran the tests and both smoke runs on the machine above and wrote this report.
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-25 22:42 UTC · original

AMD run (listed as untested; the reports above are NVIDIA): the new test passes on an RX 9070 XT.

Head 12141cc applied on main e1d84b7, debug, Windows 11 Pro 26200, RX 9070 XT (RDNA4, driver 32.0.32029.2010):

  • cargo test -p xcl --lib -- list_lifecycle_transitions_clear_shared_scratch --nocapture: 1 passed, 0 failed, no SKIPPED.
  • The test makes its command lists on the default adapter (D3D12CreateDevice(None, ..)), which is the RX 9070 XT here, so they ran on the AMD driver, not WARP.

Not tested: the whole suite with this PR, Intel, a title.
AI use: Claude Code (Claude Opus 5.5) ran the test on this machine and wrote this report.

**@⁠DarkPanda69** on GitHub · 2026-11-25 22:42 UTC · [original](https://github.com/xcl-dev/xcl/pull/2543#issuecomment-7176683441) AMD run (listed as untested; the reports above are NVIDIA): the new test passes on an RX 9070 XT. Head `12141cc` applied on `main` `e1d84b7`, debug, Windows 11 Pro 26200, RX 9070 XT (RDNA4, driver 32.0.32029.2010): - `cargo test -p xcl --lib -- list_lifecycle_transitions_clear_shared_scratch --nocapture`: 1 passed, 0 failed, no SKIPPED. - The test makes its command lists on the default adapter (`D3D12CreateDevice(None, ..)`), which is the RX 9070 XT here, so they ran on the AMD driver, not WARP. Not tested: the whole suite with this PR, Intel, a title. AI use: Claude Code (Claude Opus 5.5) ran the test on this machine and wrote this report.
Author
Owner

@⁠emirduran707 on GitHub · 2026-11-25 22:52 UTC · original

Independent AMD RDNA4 (native wave64) verification of exact PR head 12141ccbfa162b7e169d913a20c1b7e3fd1bf1dd on Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver 32.0.31044.16, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC 1.9.2602.17).

Tested

  • cargo build --workspace (debug): passed (0 errors).
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1422 passed, 2 failed, 46 ignored (8 SKIPPED: 6 per-lane DXIL forms refused by host adapter/driver, 1 heap_window_out_of_memory_falls_back_to_the_switch_form no heap windows, 1 pso_measurement_compiles_an_exact_synthetic_record Windows Developer Mode off).
    • The new test hle::d3d12x::real::dispatch_chain::tests::list_lifecycle_transitions_clear_shared_scratch passed.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 and fuzz_validate_and_gpu_3) are pre-existing on unmodified main on this RX 9060 XT / driver 32.0.31044.16.
  • cargo build --release -p xcl + 60 s retail-title smoke test (scripts/smoke.ps1, offline):
xcl-smoke v1
commit: 12141ccbfa162b7e169d913a20c1b7e3fd1bf1dd
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1582 (PresentX 1582)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13932 MB

(Compare against main 68a284a on this machine: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • NVIDIA / Intel GPUs, Linux / Wine.

AI use

  • Verification run and report prepared with Antigravity (Gemini 4 Neon); all build, test, and smoke results are from live runs on this machine.
**@⁠emirduran707** on GitHub · 2026-11-25 22:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/2543#issuecomment-7176878727) Independent AMD RDNA4 (native wave64) verification of exact PR head `12141ccbfa162b7e169d913a20c1b7e3fd1bf1dd` on Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver `32.0.31044.16`, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC `1.9.2602.17`). **Tested** - `cargo build --workspace` (debug): passed (`0` errors). - `cargo test --workspace --no-fail-fast -- --test-threads=4`: `1422 passed, 2 failed, 46 ignored` (`8 SKIPPED`: 6 per-lane DXIL forms refused by host adapter/driver, 1 `heap_window_out_of_memory_falls_back_to_the_switch_form` no heap windows, 1 `pso_measurement_compiles_an_exact_synthetic_record` Windows Developer Mode off). - The new test `hle::d3d12x::real::dispatch_chain::tests::list_lifecycle_transitions_clear_shared_scratch` passed. - The 2 failures (`gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` and `fuzz_validate_and_gpu_3`) are pre-existing on unmodified `main` on this RX 9060 XT / driver `32.0.31044.16`. - `cargo build --release -p xcl` + 60 s retail-title smoke test (`scripts/smoke.ps1`, offline): ``` xcl-smoke v1 commit: 12141ccbfa162b7e169d913a20c1b7e3fd1bf1dd gpu: AMD Radeon RX 9060 XT title: 21222967 seconds: 60 exit: 0x0 frames shown: 1582 (PresentX 1582) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 13932 MB ``` (Compare against `main` `68a284a` on this machine: `1573 frames, 14420 MB peak, 0 device removals, 0 crashes`.) **Not tested** - NVIDIA / Intel GPUs, Linux / Wine. **AI use** - Verification run and report prepared with Antigravity (Gemini 4 Neon); all build, test, and smoke results are from live runs on this machine.
Author
Owner

@⁠SlopTart on GitHub · 2026-11-25 23:24 UTC · original

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

gpu_ suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
Targeted run of list_lifecycle_transitions_clear_shared_scratch: passed.

Not tested: retail titles (no title data on this lane, counts only).

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

**@⁠SlopTart** on GitHub · 2026-11-25 23:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/2543#issuecomment-7177528463) **Tested**: current PR head merged onto current `origin/main` (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target `x86_64-pc-windows-gnu` run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29). `gpu_` suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR. Targeted run of `list_lifecycle_transitions_clear_shared_scratch`: passed. **Not tested**: retail titles (no title data on this lane, counts only). **AI use**: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/2543/head:github-bot/gh-2543'
git switch 'github-bot/gh-2543'

Merge

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