D3D12.X: a put-off call's segment that does not close is not submitted #2622

Open
github-bot wants to merge 2 commits from github-bot/gh-2622 into main AGit
Owner

@⁠KDenKC on GitHub · 2026-11-26 02:50 UTC · original
KDenKC:closefix → main · +199 −2 · 2 files · 2 commits · open

Related: #2118 (the put-off-to-the-submit path), #2088. Found by @⁠KOLESNiii in a static review (#2088).

The path that puts a call off to a segment of its own, recorded at ExecuteCommandLists (#2118), ignored the native Close result twice:

  • deferred_segment closed the new empty segment and added it to the recording whatever Close returned;
  • record_deferred closed the segment after recording the call, ignored the result, and made it the next segment's predecessor.

A segment whose recording the runtime refused was then submitted with the rest. In a test, submitting one removed the device (0x887A0001, an invalid call).

What is in it

  • Review fix f0f9daee (thehollowedone's finding, #2622): a put-off segment whose native Close fails is released instead of being kept as a spare (a spare that cannot be reset lost its owning reference), in both deferred_segment and drop_segment, and its dispatch-chain predecessor entry is cleared. This is their patch and test, with one change: the first-refusal release goes through the adopted vtable like drop_segment, so cl_release cleans the list's address-keyed state.

  • crates/xcl/src/hle/d3d12x/list_x.rs:

    • segment_close: the native Close of a put-off segment, with its HRESULT (and a test-only hook).
    • deferred_segment: if the empty segment doesn't close, it isn't used; the list goes back to the spares and the call waits in its list, as it did before #2118.
    • record_deferred: if the segment doesn't close after the call is recorded, it leaves the recording (title_list::drop_segment; it stays with the spares and is released with them). A list whose Close failed is still open and can't be Reset (E_FAIL, measured), so it can't be emptied. The call is dropped and counted (as a failed Reset there already is), the next segment doesn't follow it, and a warning is logged.
  • crates/xcl/src/hle/d3d12x/title_list.rs: drop_segment.

  • Tests:

    • a_put_off_call_whose_close_fails_is_not_submitted: the replay's recording is made to fail in the runtime (a query begun and never ended); the submission still runs and its fence is signalled, and the device stays.
    • a_put_off_segment_that_does_not_close_is_not_used: nothing is put off when the empty segment doesn't close.

Tested

  • Review fix f0f9daee, RTX 5090, XCL_NETWORK=0: thehollowedone's reference-count test on the previous head: 0 passed, 1 failed (final Release returned 1); with the fix: a_put_off_ 2 passed, 0 failed (final Release 0). list_x 42 passed, 0 failed, no SKIPPED. cargo build --workspace passed. The smoke pair below is main against this head (200 s, same recipe).

  • Whole suite at f0f9daee (RTX 5090, --no-fail-fast --test-threads=4, XCL_NETWORK=0): 1,433 passed, 4 failed (the known fuzz_validate_and_gpu_0..3), 47 ignored, 26 SKIPPED. On the Ryzen's AMD iGPU (RDNA2), with local test-only overlays so the fixtures honour XCL_ADAPTER (this PR's put_off_rig uses the default adapter, as noted in the review thread): a_put_off_ 2 passed and list_x 42 passed, with the fixture printing the AMD adapter.

  • RTX 5090 32 GB (driver 621.24), Ryzen 7 9800X3D, Windows 11 Pro 26200, Rust 1.99.1, debug tests. Base main b49be18; head 008201c.

  • Both tests fail with main's behaviour at the two sites (the segment code otherwise the same): "the refused segment is not submitted" (left: 3, right: 2) and "nothing was put off" (left: 3, right: 1). Both pass with the change: 20 of 20 runs with --test-threads=4.

  • In the first test the runtime refuses the recording itself (a query begun and never ended, then the native Close: the test asserts it fails). The test hook is #[cfg(test)] and keyed by the wrapper, so tests running in parallel don't take each other's hook.

  • cargo test -p xcl --lib hle::d3d12x -- --test-threads=4: 256 passed, 0 failed, 2 ignored.

  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4 on 008201c
    (XCL_NETWORK=0): 1433 passed, 4 failed, 47 ignored over 37 test binaries. The 4 failures are
    gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (CreateComputePipelineState 0x8007000E, seeds
    70 / 545 / 1019 / 1507). They fail the same way on main b49be18 (pre-existing, #1905).
    --no-fail-fast because otherwise those 4 stop cargo before the integration tests.

  • SKIPPED (26 lines): GPU tests or forms that need wave64 (no wave64 on this card); 3 f16/f32 forms the
    per-lane lowering refuses (#1426); heap_window_out_of_memory_falls_back_to_the_switch_form (no heap
    windows); pso_measurement_compiles_an_exact_synthetic_record (needs Developer Mode).

Regression run
main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 5090
title: 9cc6a39e
seconds: 200
exit: 0x0
frames shown: 1542 (PresentX 1542)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 31097 MB

This PR (008201c):

xcl-smoke v1
commit: f0f9daee2d7e7cf5b46aa0d9b6a1beb46b94b5dc
gpu: NVIDIA GeForce RTX 5090
title: 9cc6a39e
seconds: 200
exit: 0x0
frames shown: 2065 (PresentX 2065)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 31080 MB

Both: the retail title, -Seconds 200, XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1, the same scripted input to the world load, each on a copy of the same cache (compute precompiled, graphics driver blobs removed) under a never-used exe name. Both stop presenting at the world load (#2088).

Tested by others (thank you):

  • RTX 5070 Ti (Blackwell), futurepro62, exact head 008201c4: whole suite 1425 passed, 0 failed (main's known failures skipped); both new tests pass. On the Ryzen iGPU (RDNA2, XCL_ADAPTER=radeon): 1436 passed, 0 failed. Note: the new tests' fixture uses the default adapter (see the review thread), so XCL_ADAPTER did not select it on every machine. #2622
  • AMD RX 7800 XT (RDNA3), oni-swr, exact head against its parent: 1436 vs 1434 passed, the same one fuzz failure on both. A LUID probe confirmed the fixtures ran on the RX 7800 XT, and a causal control (the Close failure masked) made both new tests fail, as expected. #2622
  • RTX 3060 Ti, DavidM1911, head merged with current main: cargo test -p xcl --lib all passed, 0 failed. #2622

Not tested

  • A Close failing on its own in a title run: not seen in ours (no Close failed line in either smoke run); the failure is injected in the tests.
  • The smoke runs don't reach the changed code: with compute precompiled, neither run put a call off to the submit (0 such lines in both logs). They are a regression check only.
  • AMD and Intel GPUs.

Edge cases we would like tested

Results on other hardware are very welcome here. Please give the commit, GPU, driver and the output.

  1. AMD (RDNA2 / 3 / 4) and Intel, the two new tests. Whether a recording is refused at Close, and what a refused list does when submitted, is up to the driver.
    cargo test -p xcl --lib a_put_off_ -- --test-threads=4
    Look for: both pass. In the first, the assertion that the runtime refused the recording (a query begun and never ended) passes, the submission runs, and the device stays. If Close isn't refused on your driver, that assertion fails and names the HRESULT: please post it.
  2. Wine / vkd3d-proton. The same two tests. Look for: whether vkd3d-proton reports the unended query at Close at all. If it doesn't, the first test fails at "the runtime refused the recording", which says how a refused recording surfaces there.
  3. Several put-off calls in one submit, the refused one in the middle. Not covered by the tests, which put off one call. Look for: the segments after the refused one run in order; split dispatch chains don't link across it (it isn't used as the predecessor); a fence signalled after the ExecuteCommandLists completes.
  4. The KickoffX path. KickoffX checks its own list's Close, then calls the same record_deferred. A put-off call refused there should be dropped the same way. Look for: the deferred call: Close failed warning and no device removal.
  5. Compute lists. The tests use a direct list; put-off dispatches are mostly on compute lists. Look for: the same behaviour on a compute queue. (Copy lists can't put a call off, so they don't apply.)
  6. A title run with the D3D12 debug layer (XCL_D3D12_DEBUG=1). Look for: whether any put-off segment is ever refused in practice, i.e. the log lines D3D12.X: deferred call: Close failed (…) or D3D12.X: put-off segment: Close failed (…), and the debug layer's message for that list. We saw none in our runs without the debug layer.

Related but not changed here: @⁠KOLESNiii's second case. A put-off call is taken out of its segment before a bounded resolve (XCL_PSO_WAIT_MS) can skip it, so after a timed-out dispatch, a reusable list submitted again may still be missing that dispatch. This is a separate question from the Close results, and this PR doesn't touch it.

AI use

  • Review fix: thehollowedone wrote the patch and test; Codex (GPT-6.1-Sol) applied them with the release-path change and ran them; Claude Code (Claude Opus 5.5) ran the smoke and updated this description.
  • Claude Code (Claude Opus 5.5) wrote the change, the tests and this description, and ran the tests and runs listed.

🤖 Generated with Claude Code

**@⁠KDenKC** on GitHub · 2026-11-26 02:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/2622) `KDenKC:closefix` → `main` · +199 −2 · 2 files · 2 commits · open Related: #2118 (the put-off-to-the-submit path), #2088. Found by @⁠KOLESNiii in a static review (https://git.gtahub.st/github/xcl-dev--xcl/issues/2088). The path that puts a call off to a segment of its own, recorded at `ExecuteCommandLists` (#2118), ignored the native `Close` result twice: - `deferred_segment` closed the new empty segment and added it to the recording whatever `Close` returned; - `record_deferred` closed the segment after recording the call, ignored the result, and made it the next segment's predecessor. A segment whose recording the runtime refused was then submitted with the rest. In a test, submitting one **removed the device** (`0x887A0001`, an invalid call). **What is in it** - **Review fix `f0f9daee`** (thehollowedone's finding, https://git.gtahub.st/github/xcl-dev--xcl/pulls/2622): a put-off segment whose native `Close` fails is released instead of being kept as a spare (a spare that cannot be reset lost its owning reference), in both `deferred_segment` and `drop_segment`, and its dispatch-chain predecessor entry is cleared. This is their patch and test, with one change: the first-refusal release goes through the adopted vtable like `drop_segment`, so `cl_release` cleans the list's address-keyed state. - `crates/xcl/src/hle/d3d12x/list_x.rs`: - `segment_close`: the native Close of a put-off segment, with its HRESULT (and a test-only hook). - `deferred_segment`: if the empty segment doesn't close, it isn't used; the list goes back to the spares and the call waits in its list, as it did before #2118. - `record_deferred`: if the segment doesn't close after the call is recorded, it leaves the recording (`title_list::drop_segment`; it stays with the spares and is released with them). A list whose Close failed is still open and can't be Reset (`E_FAIL`, measured), so it can't be emptied. The call is dropped and counted (as a failed Reset there already is), the next segment doesn't follow it, and a warning is logged. - `crates/xcl/src/hle/d3d12x/title_list.rs`: `drop_segment`. - Tests: - `a_put_off_call_whose_close_fails_is_not_submitted`: the replay's recording is made to fail in the runtime (a query begun and never ended); the submission still runs and its fence is signalled, and the device stays. - `a_put_off_segment_that_does_not_close_is_not_used`: nothing is put off when the empty segment doesn't close. **Tested** - **Review fix `f0f9daee`**, RTX 5090, `XCL_NETWORK=0`: thehollowedone's reference-count test on the previous head: 0 passed, 1 failed (final `Release` returned 1); with the fix: `a_put_off_` 2 passed, 0 failed (final `Release` 0). `list_x` 42 passed, 0 failed, no SKIPPED. `cargo build --workspace` passed. The smoke pair below is `main` against this head (200 s, same recipe). - Whole suite at `f0f9daee` (RTX 5090, `--no-fail-fast --test-threads=4`, `XCL_NETWORK=0`): 1,433 passed, 4 failed (the known `fuzz_validate_and_gpu_0..3`), 47 ignored, 26 SKIPPED. On the Ryzen's AMD iGPU (RDNA2), with local test-only overlays so the fixtures honour `XCL_ADAPTER` (this PR's `put_off_rig` uses the default adapter, as noted in the review thread): `a_put_off_` 2 passed and `list_x` 42 passed, with the fixture printing the AMD adapter. - RTX 5090 32 GB (driver 621.24), Ryzen 7 9800X3D, Windows 11 Pro 26200, Rust 1.99.1, debug tests. Base `main` `b49be18`; head `008201c`. - Both tests fail with `main`'s behaviour at the two sites (the segment code otherwise the same): "the refused segment is not submitted" (`left: 3`, `right: 2`) and "nothing was put off" (`left: 3`, `right: 1`). Both pass with the change: 20 of 20 runs with `--test-threads=4`. - In the first test the runtime refuses the recording itself (a query begun and never ended, then the native `Close`: the test asserts it fails). The test hook is `#[cfg(test)]` and keyed by the wrapper, so tests running in parallel don't take each other's hook. - `cargo test -p xcl --lib hle::d3d12x -- --test-threads=4`: 256 passed, 0 failed, 2 ignored. - `cargo build --workspace`, then `cargo test --workspace --no-fail-fast -- --test-threads=4` on `008201c` (`XCL_NETWORK=0`): **1433 passed, 4 failed, 47 ignored** over 37 test binaries. The 4 failures are `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3` (`CreateComputePipelineState` `0x8007000E`, seeds 70 / 545 / 1019 / 1507). They fail the same way on `main` `b49be18` (pre-existing, #1905). `--no-fail-fast` because otherwise those 4 stop cargo before the integration tests. - SKIPPED (26 lines): GPU tests or forms that need wave64 (no wave64 on this card); 3 f16/f32 forms the per-lane lowering refuses (#1426); `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows); `pso_measurement_compiles_an_exact_synthetic_record` (needs Developer Mode). **Regression run** `main`: ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 5090 title: 9cc6a39e seconds: 200 exit: 0x0 frames shown: 1542 (PresentX 1542) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 31097 MB ``` This PR (`008201c`): ``` xcl-smoke v1 commit: f0f9daee2d7e7cf5b46aa0d9b6a1beb46b94b5dc gpu: NVIDIA GeForce RTX 5090 title: 9cc6a39e seconds: 200 exit: 0x0 frames shown: 2065 (PresentX 2065) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 31080 MB ``` Both: the retail title, `-Seconds 200`, `XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1`, the same scripted input to the world load, each on a copy of the same cache (compute precompiled, graphics driver blobs removed) under a never-used exe name. Both stop presenting at the world load (#2088). **Tested by others** (thank you): - RTX 5070 Ti (Blackwell), futurepro62, exact head `008201c4`: whole suite 1425 passed, 0 failed (main's known failures skipped); both new tests pass. On the Ryzen iGPU (RDNA2, `XCL_ADAPTER=radeon`): 1436 passed, 0 failed. Note: the new tests' fixture uses the default adapter (see the review thread), so `XCL_ADAPTER` did not select it on every machine. https://git.gtahub.st/github/xcl-dev--xcl/pulls/2622 - AMD RX 7800 XT (RDNA3), oni-swr, exact head against its parent: 1436 vs 1434 passed, the same one fuzz failure on both. A LUID probe confirmed the fixtures ran on the RX 7800 XT, and a causal control (the Close failure masked) made both new tests fail, as expected. https://git.gtahub.st/github/xcl-dev--xcl/pulls/2622 - RTX 3060 Ti, DavidM1911, head merged with current `main`: `cargo test -p xcl --lib` all passed, 0 failed. https://git.gtahub.st/github/xcl-dev--xcl/pulls/2622 **Not tested** - A `Close` failing on its own in a title run: not seen in ours (no `Close failed` line in either smoke run); the failure is injected in the tests. - The smoke runs don't reach the changed code: with compute precompiled, neither run put a call off to the submit (0 such lines in both logs). They are a regression check only. - AMD and Intel GPUs. **Edge cases we would like tested** Results on other hardware are very welcome here. Please give the commit, GPU, driver and the output. 1. **AMD (RDNA2 / 3 / 4) and Intel, the two new tests.** Whether a recording is refused at `Close`, and what a refused list does when submitted, is up to the driver. `cargo test -p xcl --lib a_put_off_ -- --test-threads=4` Look for: both pass. In the first, the assertion that the runtime refused the recording (a query begun and never ended) passes, the submission runs, and the device stays. If `Close` isn't refused on your driver, that assertion fails and names the HRESULT: please post it. 2. **Wine / vkd3d-proton.** The same two tests. Look for: whether vkd3d-proton reports the unended query at `Close` at all. If it doesn't, the first test fails at "the runtime refused the recording", which says how a refused recording surfaces there. 3. **Several put-off calls in one submit, the refused one in the middle.** Not covered by the tests, which put off one call. Look for: the segments after the refused one run in order; split dispatch chains don't link across it (it isn't used as the predecessor); a fence signalled after the `ExecuteCommandLists` completes. 4. **The `KickoffX` path.** `KickoffX` checks its own list's `Close`, then calls the same `record_deferred`. A put-off call refused there should be dropped the same way. Look for: the `deferred call: Close failed` warning and no device removal. 5. **Compute lists.** The tests use a direct list; put-off dispatches are mostly on compute lists. Look for: the same behaviour on a compute queue. (Copy lists can't put a call off, so they don't apply.) 6. **A title run with the D3D12 debug layer** (`XCL_D3D12_DEBUG=1`). Look for: whether any put-off segment is ever refused in practice, i.e. the log lines `D3D12.X: deferred call: Close failed (…)` or `D3D12.X: put-off segment: Close failed (…)`, and the debug layer's message for that list. We saw none in our runs without the debug layer. Related but not changed here: @⁠KOLESNiii's second case. A put-off call is taken out of its segment before a bounded resolve (`XCL_PSO_WAIT_MS`) can skip it, so after a timed-out dispatch, a reusable list submitted again may still be missing that dispatch. This is a separate question from the `Close` results, and this PR doesn't touch it. **AI use** - Review fix: thehollowedone wrote the patch and test; Codex (GPT-6.1-Sol) applied them with the release-path change and ran them; Claude Code (Claude Opus 5.5) ran the smoke and updated this description. - Claude Code (Claude Opus 5.5) wrote the change, the tests and this description, and ran the tests and runs listed. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The path that puts a call off to a segment of its own, recorded at the
submit (#2118), ignored the native Close result twice: deferred_segment
added the new empty segment to the recording whatever its Close returned,
and record_deferred closed the segment after recording the call, ignored
the result and chained the next segment to it. A segment whose recording
the runtime refused was submitted with the rest: in a test, submitting one
removed the device (0x887A0001, an invalid call). Found by KOLESNiii in a
static review on #2088.

A put-off segment that does not close when it is made is not used: it goes
back to the spares and the call waits in its list, as before #2118. One
that does not close after its call is recorded leaves the recording (a list
whose Close failed is still open and cannot be reset), its call is dropped
and counted, and the next one does not follow it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:35:04 +00:00
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-26 03:35 UTC · original · edited 2026-11-26 03:38 UTC

Full-suite run, since this PR has no test report yet. Tested exact head 008201c4 (on its base b49be18).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1425 passed, 0 failed, 45 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, dispatch_chain_native_wave64_builds_whole, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: a_put_off_call_whose_close_fails_is_not_submitted, a_put_off_segment_that_does_not_close_is_not_used.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1436 passed, 0 failed, 47 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main b49be183 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (#1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-26 03:35 UTC · [original](https://github.com/xcl-dev/xcl/pull/2622#issuecomment-7181852742) · edited 2026-11-26 03:38 UTC Full-suite run, since this PR has no test report yet. Tested exact head `008201c4` (on its base `b49be18`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests`: **1425 passed, 0 failed, 45 ignored**. SKIPPED (no wave64): `a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu`, `a_per_lane_2d_or_3d_group_runs_on_the_gpu`, `coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu`, `cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu`, `dispatch_chain_native_wave64_builds_whole`, `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`, `the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu`. - The new tests ran and passed: `a_put_off_call_whose_close_fails_is_not_submitted`, `a_put_off_segment_that_does_not_close_is_not_used`. - Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1`: **1436 passed, 0 failed, 47 ignored**. SKIPPED: `f16_programs_on_the_gpu` (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), `f16_programs_on_the_gpu` (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), `f16_programs_on_the_gpu` (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), `f16_programs_on_the_gpu` (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), `f32_programs_on_the_gpu` (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), `f32_programs_on_the_gpu` (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - `--skip` leaves out tests that fail on main `b49be183` too, not because of this PR. On NVIDIA: `heap_window_out_of_memory_falls_back_to_the_switch_form` (#1651), the four `gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu` tests, `const_and_null_mask_operands_agree_with_hlsl_on_the_gpu` and `mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu` ([follow-up on #1651](https://git.gtahub.st/github/xcl-dev--xcl/issues/1651)) fail because `runner::skip_test` turns their skips into failures under `XCL_REQUIRE_GPU=mesh`, and `gpu::dxil::fuzz_tests` seeds 70, 545, 1019 and 1507 fail `CreateComputePipelineState` with `E_OUTOFMEMORY` on this card (drivers 616.64 and 621.40). On AMD: `fuzz_validate_and_gpu_1` fails on seed 540 (`res[833]` 0x7 vs CPU 0x6). The AMD run does not set `XCL_REQUIRE_GPU`. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠KDenKC on GitHub · 2026-11-26 04:02 UTC · original

AMD run of the two new tests, with the adapter shown. Head 008201c4, debug, Windows 11 Pro 26200, on the integrated AMD Radeon(TM) Graphics of a Ryzen 7 9800X3D (RDNA2; driver version not recorded). To select that adapter, the list_x fixture was temporarily changed (local, test-only, not part of this PR) to use the crate's adapter selection with XCL_ADAPTER, and to print what it got:

  • list_x fixture adapter: AMD Radeon(TM) Graphics; WARP=false
  • cargo test -p xcl --lib a_put_off_ -- --test-threads=4: 2 passed, 0 failed, 0 ignored, no SKIPPED. Both refused recordings show up at Close on this driver too (0x80004005), and both log lines fire: deferred call: Close failed (0x80004005), the call is dropped and put-off segment: Close failed (0x80004005).

So this is AMD coverage of the two tests, unlike the default-adapter runs discussed above. The fixture change will be its own test-only PR (the follow-up offered to @⁠luckyteagirl).

Not tested: RDNA3/4, Intel, a title run on AMD.

AI use: Codex (GPT-6.1-Sol) wrote the temporary fixture change and ran the tests; Claude Code (Claude Opus 5.5) checked the log and wrote this comment.

**@⁠KDenKC** on GitHub · 2026-11-26 04:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/2622#issuecomment-7182247678) **AMD run of the two new tests, with the adapter shown.** Head `008201c4`, debug, Windows 11 Pro 26200, on the integrated AMD Radeon(TM) Graphics of a Ryzen 7 9800X3D (RDNA2; driver version not recorded). To select that adapter, the `list_x` fixture was temporarily changed (local, test-only, not part of this PR) to use the crate's adapter selection with `XCL_ADAPTER`, and to print what it got: - `list_x fixture adapter: AMD Radeon(TM) Graphics; WARP=false` - `cargo test -p xcl --lib a_put_off_ -- --test-threads=4`: **2 passed, 0 failed, 0 ignored**, no SKIPPED. Both refused recordings show up at `Close` on this driver too (`0x80004005`), and both log lines fire: `deferred call: Close failed (0x80004005), the call is dropped` and `put-off segment: Close failed (0x80004005)`. So this is AMD coverage of the two tests, unlike the default-adapter runs discussed above. The fixture change will be its own test-only PR (the follow-up offered to @⁠luckyteagirl). **Not tested:** RDNA3/4, Intel, a title run on AMD. **AI use:** Codex (GPT-6.1-Sol) wrote the temporary fixture change and ran the tests; Claude Code (Claude Opus 5.5) checked the log and wrote this comment.
@ -7082,0 +7126,4 @@
use windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_11_0;
use windows::Win32::Graphics::Dxgi::*;
let mut dev: Option<ID3D12Device> = None;
if D3D12CreateDevice(None, D3D_FEATURE_LEVEL_11_0, &mut dev).is_err() {
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 03:20 UTC · original

The two requested AMD RDNA2 tests call D3D12CreateDevice(None, ...), so XCL_ADAPTER=6800M does not select their device. On this hybrid AMD laptop, a standalone call with the same arguments succeeded and its device LUID matched the integrated AMD Radeon(TM) Graphics (DEV_1638), not the RX 6800M (DEV_73DF); the fixture therefore would not enter its WARP fallback but would test the iGPU. Could the rig honor XCL_ADAPTER, or at least print the actual device adapter and WARP fallback status, before these results are counted as RX 6800M coverage? This is source review plus an external default-device probe; I did not run the PR tests.

AI-assisted review: OpenAI Codex (GPT-6; exact serving variant unavailable) and a Luna subagent.

**@⁠luckyteagirl** on GitHub · 2026-11-26 03:20 UTC · [original](https://github.com/xcl-dev/xcl/pull/2622#discussion_r4703523280) The two requested AMD RDNA2 tests call `D3D12CreateDevice(None, ...)`, so `XCL_ADAPTER=6800M` does not select their device. On this hybrid AMD laptop, a standalone call with the same arguments succeeded and its device LUID matched the integrated AMD Radeon(TM) Graphics (`DEV_1638`), not the RX 6800M (`DEV_73DF`); the fixture therefore would not enter its WARP fallback but would test the iGPU. Could the rig honor `XCL_ADAPTER`, or at least print the actual device adapter and WARP fallback status, before these results are counted as RX 6800M coverage? This is source review plus an external default-device probe; I did not run the PR tests. AI-assisted review: OpenAI Codex (GPT-6; exact serving variant unavailable) and a Luna subagent.
@ -7082,0 +7126,4 @@
use windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_11_0;
use windows::Win32::Graphics::Dxgi::*;
let mut dev: Option<ID3D12Device> = None;
if D3D12CreateDevice(None, D3D_FEATURE_LEVEL_11_0, &mut dev).is_err() {
Author
Owner

@⁠KDenKC on GitHub · 2026-11-26 03:50 UTC · original

Thanks @⁠luckyteagirl for catching this, and @⁠futurepro62 for the full-suite report. You are right: our two new tests share put_off_rig at list_x.rs:7124, whose D3D12CreateDevice(None, ...) call at 7129 ignores XCL_ADAPTER. Their helper calls are at 7166 and 7228. On a hybrid machine they use the default adapter, or WARP if default-device creation fails.

Checked: at 008201c4, list_x.rs has 15 direct D3D12CreateDevice(None, ...) call sites: this shared helper plus 14 other fixture calls at lines 4645, 4667, 4715, 5111, 5935, 6013, 6199, 6278, 6451, 6627, 6794, 6916, 7052 and 7267. Our tests followed that existing pattern, so their adapter attribution needs correcting.

@⁠futurepro62, the two new tests in your “AMD iGPU (XCL_ADAPTER=radeon)” run therefore most likely ran on your default adapter. Could you confirm which adapter that is? We should hold their AMD-specific coverage attribution until the actual device is identified.

I can add the actual adapter name/LUID and WARP status to these two tests now. Making the broader list_x fixtures honor XCL_ADAPTER through gpu::adapter / the runner's selection pattern can be a separate test-only PR.

Not tested: no new device probe or GPU run for this reply; source inspection and the linked reports only.

AI use: Codex (GPT-6.1-Sol) checked the fixture call sites and drafted this reply. Claude Code (Claude Opus 5.5) checked the count and posted it.

**@⁠KDenKC** on GitHub · 2026-11-26 03:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/2622#discussion_r4703680871) Thanks @⁠luckyteagirl for catching this, and @⁠futurepro62 for the full-suite report. You are right: our two new tests share [`put_off_rig` at `list_x.rs:7124`](https://github.com/xcl-dev/xcl/blob/008201c4ee8204d1e4c28fc6eee0409b6b26314b/crates/xcl/src/hle/d3d12x/list_x.rs#L7124), whose `D3D12CreateDevice(None, ...)` call at **7129** ignores `XCL_ADAPTER`. Their helper calls are at 7166 and 7228. On a hybrid machine they use the default adapter, or WARP if default-device creation fails. **Checked:** at `008201c4`, `list_x.rs` has **15 direct `D3D12CreateDevice(None, ...)` call sites**: this shared helper plus 14 other fixture calls at lines **4645, 4667, 4715, 5111, 5935, 6013, 6199, 6278, 6451, 6627, 6794, 6916, 7052 and 7267**. Our tests followed that existing pattern, so their adapter attribution needs correcting. @⁠futurepro62, the two new tests in your “AMD iGPU (`XCL_ADAPTER=radeon`)” run therefore most likely ran on your default adapter. Could you confirm which adapter that is? We should hold their AMD-specific coverage attribution until the actual device is identified. I can add the actual adapter name/LUID and WARP status to these two tests now. Making the broader `list_x` fixtures honor `XCL_ADAPTER` through `gpu::adapter` / the runner's selection pattern can be a separate test-only PR. **Not tested:** no new device probe or GPU run for this reply; source inspection and the linked reports only. **AI use:** Codex (GPT-6.1-Sol) checked the fixture call sites and drafted this reply. Claude Code (Claude Opus 5.5) checked the count and posted it.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-26 05:41 UTC · original

Independent synthetic Windows GPU verification on an AMD Radeon RX 7800 XT (RDNA3), driver 32.0.31035.1003, Ryzen 7 5700X3D, Windows 11 Pro build 26200, Rust 1.100.0 x86_64-pc-windows-msvc, DXC/DXIL 1.8.2502.11 (Windows SDK 10.0.26100), debug.

Tested

With CARGO_TARGET_DIR=D:\xcl-2622-amd-target and XCL_NETWORK=0, cargo build --workspace -j 4 succeeded at both clean commits. cargo test --workspace --no-fail-fast -j 4 -- --test-threads=4 ran all workspace targets at each commit.

Revision Passed (harness) Failed Ignored SKIPPED cases
Head 008201c4ee8204d1e4c28fc6eee0409b6b26314b 1436 1 47 7
Parent b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 1434 1 47 7

Both suites exited 101 on gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 with the same mismatch at seed 722, res[30] GPU 0x1 versus CPU 0x7fffffff. The existing deferred-submit test a_dispatch_with_a_pipeline_still_building_waits_at_the_submit passed at both revisions. The two new Close regressions passed at the head and are absent from the parent.

The same seven SKIPPED cases were logged on both runs and are excluded from coverage.

  • f16_programs_on_the_gpu, per-lane arithmetic on wave32 and wave64 (V_MUL_F16) and per-lane packed arithmetic on wave32 and wave64 (V_PK_MUL_F16).
  • f32_programs_on_the_gpu, per-lane conversions on wave32 and wave64 (V_CVT_F16_F32). These six cases were refused due to the semantic differences tracked in #1426.
  • heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).

Both full-suite logs identify the RX 7800 XT in the D3D12.X runtime. At the head, a temporary test-only probe matched each Close fixture device's LUID to the RX 7800 XT (software=false) and reported the same adapter name from the GPU test runner. With that probe, cargo test -p xcl --lib -j 4 a_put_off_ -- --test-threads=4 --nocapture gave 2 passed, 0 failed, 0 ignored, and 0 skipped. The replay hook recorded native Close returning 0x80004005. The segment-creation hook injected 0x80004005 after the native call.

Repeating the same targeted command with the temporary XCL_2622_CONTROL_SUPPRESS_CLOSE_FAILURE=1 masked the hook HRESULT at the caller. The control gave 0 passed, 2 failed, 0 ignored, and 0 skipped. The refusal-at-replay test collected three segments with two expected, and the refusal-at-creation test collected three with one expected. The temporary test changes were removed.

Not tested

Retail title smoke runs, release builds, and other adapters.

AI use

Claude Code (Claude Opus 5.5) ran the exact-head build and suite. Codex (gpt-6.2-sol) ran the exact-parent build and suite, ran the temporary adapter and causal checks, compared the saved logs, and wrote this test report.

**@⁠oni-swr** on GitHub · 2026-11-26 05:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/2622#issuecomment-7183721030) Independent synthetic Windows GPU verification on an AMD Radeon RX 7800 XT (RDNA3), driver `32.0.31035.1003`, Ryzen 7 5700X3D, Windows 11 Pro build 26200, Rust 1.100.0 `x86_64-pc-windows-msvc`, DXC/DXIL 1.8.2502.11 (Windows SDK 10.0.26100), debug. **Tested** With `CARGO_TARGET_DIR=D:\xcl-2622-amd-target` and `XCL_NETWORK=0`, `cargo build --workspace -j 4` succeeded at both clean commits. `cargo test --workspace --no-fail-fast -j 4 -- --test-threads=4` ran all workspace targets at each commit. | Revision | Passed (harness) | Failed | Ignored | SKIPPED cases | |---|---:|---:|---:|---:| | Head `008201c4ee8204d1e4c28fc6eee0409b6b26314b` | 1436 | 1 | 47 | 7 | | Parent `b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7` | 1434 | 1 | 47 | 7 | Both suites exited 101 on `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` with the same mismatch at seed 722, `res[30]` GPU `0x1` versus CPU `0x7fffffff`. The existing deferred-submit test `a_dispatch_with_a_pipeline_still_building_waits_at_the_submit` passed at both revisions. The two new Close regressions passed at the head and are absent from the parent. The same seven `SKIPPED` cases were logged on both runs and are excluded from coverage. - `f16_programs_on_the_gpu`, per-lane arithmetic on wave32 and wave64 (`V_MUL_F16`) and per-lane packed arithmetic on wave32 and wave64 (`V_PK_MUL_F16`). - `f32_programs_on_the_gpu`, per-lane conversions on wave32 and wave64 (`V_CVT_F16_F32`). These six cases were refused due to the semantic differences tracked in #1426. - `heap_window_out_of_memory_falls_back_to_the_switch_form` (`no heap windows`). Both full-suite logs identify the RX 7800 XT in the D3D12.X runtime. At the head, a temporary test-only probe matched each Close fixture device's LUID to the RX 7800 XT (`software=false`) and reported the same adapter name from the GPU test runner. With that probe, `cargo test -p xcl --lib -j 4 a_put_off_ -- --test-threads=4 --nocapture` gave 2 passed, 0 failed, 0 ignored, and 0 skipped. The replay hook recorded native `Close` returning `0x80004005`. The segment-creation hook injected `0x80004005` after the native call. Repeating the same targeted command with the temporary `XCL_2622_CONTROL_SUPPRESS_CLOSE_FAILURE=1` masked the hook HRESULT at the caller. The control gave 0 passed, 2 failed, 0 ignored, and 0 skipped. The refusal-at-replay test collected three segments with two expected, and the refusal-at-creation test collected three with one expected. The temporary test changes were removed. **Not tested** Retail title smoke runs, release builds, and other adapters. **AI use** Claude Code (Claude Opus 5.5) ran the exact-head build and suite. Codex (gpt-6.2-sol) ran the exact-parent build and suite, ran the temporary adapter and causal checks, compared the saved logs, and wrote this test report.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 03:20 UTC · original · reviewed

Source-derived adapter selection finding, supported by a local D3D12 null-device LUID probe. No PR test run.

**@⁠luckyteagirl** on GitHub · 2026-11-26 03:20 UTC · [original](https://github.com/xcl-dev/xcl/pull/2622#pullrequestreview-6068117336) · **reviewed** Source-derived adapter selection finding, supported by a local D3D12 null-device LUID probe. No PR test run.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 08:29 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 08:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/2622#issuecomment-7186656353) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
Apply thehollowedone's patch and reference-count regression from #2622 comment 7187891221. A list whose Close failed cannot be reset, so release it rather than losing its owner on later spare reuse, and clear its dispatch-chain predecessor.

Adjust the suggested initial-refusal Release call to use the adopted vtable too: cl_release must clean address-keyed state instead of bypassing it through orig_fn. This is the same lifecycle class discussed in #1453 and #2691.

Assisted-by: Codex (GPT-6.1-Sol)
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-26 09:23 UTC · original

Finding on #2622 head 008201c: a replay segment whose native Close fails is moved to title_list's spare pool. On its next use, deferred_segment removes it with pop_spare; native Reset fails, and .filter(emptied) discards the raw pointer. Wrapper teardown can then no longer release that owning COM reference. The same failed-reset spare fallback exists in the ordinary split path, though I exercised the deferred path here.

I extended the existing refused-Close GPU test locally to hold one extra reference, attempt the next deferred allocation, release the wrapper, then release the test reference. On the untouched runtime with only that test addition, the last Release returned 1 instead of the expected 0 (0 passed, 1 failed, 0 ignored). That identifies an owner lost from the wrapper's tracking; repeated refusals could retain lists and their resources. With the local patch below, it returned 0, and the two focused a_put_off_ tests passed (2 passed, 0 failed, 0 ignored, no skips). The patch releases a refused list rather than placing it among resettable spares, after removing it from the active recording, and clears its split-dispatch predecessor entry before release.

Tested: RTX 3080 Ti (NVIDIA 621.35), Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC, DXC/DXIL 1.8.2502.11. cargo build --offline --locked --workspace on the clean PR head passed. On the final local, uncommitted patch, cargo test --offline --locked -p xcl --lib a_put_off_ -- --nocapture --test-threads=1 had 2 passed, 0 failed, 0 ignored; cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --quiet had 1,437 passed, 0 failed, 47 ignored across 37 targets, with 25 explicit GPU skip notices. Skips are not GPU coverage.

Not tested: a retail title, paired clean-tree smoke, repeated failure under a live workload, or a refused middle call with later deferred calls. This is an author-ready local suggestion, not a merge-readiness claim.

Local test and fix diff (not committed)
diff --git a/crates/xcl/src/hle/d3d12x/list_x.rs b/crates/xcl/src/hle/d3d12x/list_x.rs
index dddb6c4..c8fe256 100644
--- a/crates/xcl/src/hle/d3d12x/list_x.rs
+++ b/crates/xcl/src/hle/d3d12x/list_x.rs
@@ -3008,7 +3008,9 @@ unsafe fn deferred_segment(wrapper: *mut c_void, list: *mut c_void, ty: D3D12_CO
         // a list that did not close is no segment: the call waits in its list instead
         static CLOSE_ERR: AtomicU64 = AtomicU64::new(0);
         warn(&CLOSE_ERR, "put-off segment", format_args!("Close failed ({hr:#x})"));
-        super::title_list::put_spare(wrapper, p);
+        real::dispatch_chain::list_reset(p as usize);
+        let release = pc::<unsafe extern "system" fn(*mut c_void) -> u32>(p, 2);
+        release(p);
         return None;
     }
     super::title_list::push_segment(wrapper, p);
@@ -7171,6 +7173,10 @@ mod tests {
             let mut segs = Vec::new();
             assert!(title_list::push_segments(wrap, &mut segs));
             assert_eq!(segs.len(), 3, "the dispatch was put off");
+            let refused = segs[1];
+            let add_ref: unsafe extern "system" fn(*mut c_void) -> u32 =
+                std::mem::transmute(*(*(refused as *const *const usize)).add(1));
+            add_ref(refused); // Keep a test reference so final Release can reveal a lost owner.
 
             // the replay's recording fails in the runtime: a query begun and never ended
             let mut heap: Option<ID3D12QueryHeap> = None;
@@ -7203,8 +7209,14 @@ mod tests {
             crate::gpu::fence::wait(&done, 1, &dev, None, 2000).expect("the submission runs");
             assert!(dev.GetDeviceRemovedReason().is_ok(), "the device stays");
 
+            // The failed-Close list cannot Reset. Its next spare reuse must not lose the
+            // wrapper's owning reference when a new segment is made instead.
+            assert!(deferred_segment(wrap, pc0, D3D12_COMMAND_LIST_TYPE_DIRECT).is_some());
             let rel_fn: unsafe extern "system" fn(*mut c_void) -> u32 = std::mem::transmute(*(*(wrap as *const *const usize)).add(2));
             rel_fn(wrap);
+            let release_ref: unsafe extern "system" fn(*mut c_void) -> u32 =
+                std::mem::transmute(*(*(refused as *const *const usize)).add(2));
+            assert_eq!(release_ref(refused), 0, "the refused segment retained an untracked owner");
             let _ = pso_async::released(standin);
         }
     }
diff --git a/crates/xcl/src/hle/d3d12x/title_list.rs b/crates/xcl/src/hle/d3d12x/title_list.rs
index 2aa8a6c..882139e 100644
--- a/crates/xcl/src/hle/d3d12x/title_list.rs
+++ b/crates/xcl/src/hle/d3d12x/title_list.rs
@@ -292,14 +292,17 @@ pub(super) fn put_spare(wrapper: *mut c_void, pc: *mut c_void) {
     sg.get_or_insert_with(HashMap::new).entry(wrapper as usize).or_default().spares.push(pc as usize);
 }
 
-/// Take segment `pc` out of `wrapper`'s recording, so it is not submitted (its recording failed);
-/// it stays with the spares, released with them.
-pub(super) fn drop_segment(wrapper: *mut c_void, pc: *mut c_void) {
+/// Take a refused segment out of `wrapper`'s recording and release it. A list whose Close failed
+/// cannot be reset, so it cannot be kept as a reusable spare.
+pub(super) unsafe fn drop_segment(wrapper: *mut c_void, pc: *mut c_void) {
     let mut sg = SEGMENTS.lock().unwrap();
     if let Some(b) = sg.as_mut().and_then(|m| m.get_mut(&(wrapper as usize))) {
         b.extra_active.retain(|&p| p != pc as usize);
-        b.spares.push(pc as usize);
     }
+    drop(sg);
+    super::real::dispatch_chain::list_reset(pc as usize);
+    let release: unsafe extern "system" fn(*mut c_void) -> u32 = std::mem::transmute(pc_slot(pc, 2));
+    release(pc);
 }
 
 /// Add the closed segment `pc` to `wrapper`'s recording, after the ones it has.

AI-assisted: Codex (GPT-6.2 Sol) traced the ownership path, wrote and ran the regression and local patch, and drafted this report. GPT-6.2 Astra reviewed the deferred segment and scratch lifetimes.

**@⁠thehollowedone** on GitHub · 2026-11-26 09:23 UTC · [original](https://github.com/xcl-dev/xcl/pull/2622#issuecomment-7187891221) **Finding on [#2622 head `008201c`](https://github.com/xcl-dev/xcl/commit/008201c4ee8204d1e4c28fc6eee0409b6b26314b):** a replay segment whose native `Close` fails is moved to `title_list`'s spare pool. On its next use, `deferred_segment` removes it with `pop_spare`; native `Reset` fails, and `.filter(emptied)` discards the raw pointer. Wrapper teardown can then no longer release that owning COM reference. The same failed-reset spare fallback exists in the ordinary split path, though I exercised the deferred path here. I extended the existing refused-`Close` GPU test locally to hold one extra reference, attempt the next deferred allocation, release the wrapper, then release the test reference. On the untouched runtime with only that test addition, the last `Release` returned **1** instead of the expected **0** (`0 passed, 1 failed, 0 ignored`). That identifies an owner lost from the wrapper's tracking; repeated refusals could retain lists and their resources. With the local patch below, it returned **0**, and the two focused `a_put_off_` tests passed (`2 passed, 0 failed, 0 ignored`, no skips). The patch releases a refused list rather than placing it among resettable spares, after removing it from the active recording, and clears its split-dispatch predecessor entry before release. **Tested:** RTX 3080 Ti (NVIDIA 621.35), Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC, DXC/DXIL 1.8.2502.11. `cargo build --offline --locked --workspace` on the clean PR head passed. On the final local, uncommitted patch, `cargo test --offline --locked -p xcl --lib a_put_off_ -- --nocapture --test-threads=1` had 2 passed, 0 failed, 0 ignored; `cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --quiet` had **1,437 passed, 0 failed, 47 ignored** across 37 targets, with **25 explicit GPU skip notices**. Skips are not GPU coverage. **Not tested:** a retail title, paired clean-tree smoke, repeated failure under a live workload, or a refused middle call with later deferred calls. This is an author-ready local suggestion, not a merge-readiness claim. <details><summary>Local test and fix diff (not committed)</summary> ```diff diff --git a/crates/xcl/src/hle/d3d12x/list_x.rs b/crates/xcl/src/hle/d3d12x/list_x.rs index dddb6c4..c8fe256 100644 --- a/crates/xcl/src/hle/d3d12x/list_x.rs +++ b/crates/xcl/src/hle/d3d12x/list_x.rs @@ -3008,7 +3008,9 @@ unsafe fn deferred_segment(wrapper: *mut c_void, list: *mut c_void, ty: D3D12_CO // a list that did not close is no segment: the call waits in its list instead static CLOSE_ERR: AtomicU64 = AtomicU64::new(0); warn(&CLOSE_ERR, "put-off segment", format_args!("Close failed ({hr:#x})")); - super::title_list::put_spare(wrapper, p); + real::dispatch_chain::list_reset(p as usize); + let release = pc::<unsafe extern "system" fn(*mut c_void) -> u32>(p, 2); + release(p); return None; } super::title_list::push_segment(wrapper, p); @@ -7171,6 +7173,10 @@ mod tests { let mut segs = Vec::new(); assert!(title_list::push_segments(wrap, &mut segs)); assert_eq!(segs.len(), 3, "the dispatch was put off"); + let refused = segs[1]; + let add_ref: unsafe extern "system" fn(*mut c_void) -> u32 = + std::mem::transmute(*(*(refused as *const *const usize)).add(1)); + add_ref(refused); // Keep a test reference so final Release can reveal a lost owner. // the replay's recording fails in the runtime: a query begun and never ended let mut heap: Option<ID3D12QueryHeap> = None; @@ -7203,8 +7209,14 @@ mod tests { crate::gpu::fence::wait(&done, 1, &dev, None, 2000).expect("the submission runs"); assert!(dev.GetDeviceRemovedReason().is_ok(), "the device stays"); + // The failed-Close list cannot Reset. Its next spare reuse must not lose the + // wrapper's owning reference when a new segment is made instead. + assert!(deferred_segment(wrap, pc0, D3D12_COMMAND_LIST_TYPE_DIRECT).is_some()); let rel_fn: unsafe extern "system" fn(*mut c_void) -> u32 = std::mem::transmute(*(*(wrap as *const *const usize)).add(2)); rel_fn(wrap); + let release_ref: unsafe extern "system" fn(*mut c_void) -> u32 = + std::mem::transmute(*(*(refused as *const *const usize)).add(2)); + assert_eq!(release_ref(refused), 0, "the refused segment retained an untracked owner"); let _ = pso_async::released(standin); } } diff --git a/crates/xcl/src/hle/d3d12x/title_list.rs b/crates/xcl/src/hle/d3d12x/title_list.rs index 2aa8a6c..882139e 100644 --- a/crates/xcl/src/hle/d3d12x/title_list.rs +++ b/crates/xcl/src/hle/d3d12x/title_list.rs @@ -292,14 +292,17 @@ pub(super) fn put_spare(wrapper: *mut c_void, pc: *mut c_void) { sg.get_or_insert_with(HashMap::new).entry(wrapper as usize).or_default().spares.push(pc as usize); } -/// Take segment `pc` out of `wrapper`'s recording, so it is not submitted (its recording failed); -/// it stays with the spares, released with them. -pub(super) fn drop_segment(wrapper: *mut c_void, pc: *mut c_void) { +/// Take a refused segment out of `wrapper`'s recording and release it. A list whose Close failed +/// cannot be reset, so it cannot be kept as a reusable spare. +pub(super) unsafe fn drop_segment(wrapper: *mut c_void, pc: *mut c_void) { let mut sg = SEGMENTS.lock().unwrap(); if let Some(b) = sg.as_mut().and_then(|m| m.get_mut(&(wrapper as usize))) { b.extra_active.retain(|&p| p != pc as usize); - b.spares.push(pc as usize); } + drop(sg); + super::real::dispatch_chain::list_reset(pc as usize); + let release: unsafe extern "system" fn(*mut c_void) -> u32 = std::mem::transmute(pc_slot(pc, 2)); + release(pc); } /// Add the closed segment `pc` to `wrapper`'s recording, after the ones it has. ``` </details> AI-assisted: Codex (GPT-6.2 Sol) traced the ownership path, wrote and ran the regression and local patch, and drafted this report. GPT-6.2 Astra reviewed the deferred segment and scratch lifetimes.
Author
Owner

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

Thanks @⁠thehollowedone, that is a real leak, and thank you for the test that proves it and the patch. We will take your change: a refused segment is released instead of going to the spares, in both deferred_segment and drop_segment. Your extended test goes in with it, credited to you, and we will rerun it and the suite on our side before pushing. I will post here when it is pushed.

AI use: Claude Code (Claude Opus 5.5) wrote this.

**@⁠KDenKC** on GitHub · 2026-11-26 09:43 UTC · [original](https://github.com/xcl-dev/xcl/pull/2622#issuecomment-7188387647) Thanks @⁠thehollowedone, that is a real leak, and thank you for the test that proves it and the patch. We will take your change: a refused segment is released instead of going to the spares, in both `deferred_segment` and `drop_segment`. Your extended test goes in with it, credited to you, and we will rerun it and the suite on our side before pushing. I will post here when it is pushed. AI use: Claude Code (Claude Opus 5.5) wrote this.
Author
Owner

@⁠KDenKC on GitHub · 2026-11-26 10:33 UTC · original

@⁠thehollowedone your fix is in f0f9daee: your patch and your reference-count test, credited in the commit. On our side the test failed on the previous head (final Release 1) and passes with the fix (0). a_put_off_ and list_x pass, and a new smoke pair is in the description.

One change from your diff: in deferred_segment's first-refusal branch, the release goes through the list's adopted vtable (as your drop_segment does) instead of pc(p, 2), the original Release. A refused list there can be a reused spare that XCL adopted. Releasing it past the hook would skip cl_release's cleanup of the list's address-keyed state (the class of #1453 / #2691). Your test still returns 0 with that.

AI use: Codex (GPT-6.1-Sol) applied the patch and ran the tests. Claude Code (Claude Opus 5.5) checked the diff and wrote this reply.

**@⁠KDenKC** on GitHub · 2026-11-26 10:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/2622#issuecomment-7189517013) @⁠thehollowedone your fix is in `f0f9daee`: your patch and your reference-count test, credited in the commit. On our side the test failed on the previous head (final `Release` 1) and passes with the fix (0). `a_put_off_` and `list_x` pass, and a new smoke pair is in the description. One change from your diff: in `deferred_segment`'s first-refusal branch, the release goes through the list's adopted vtable (as your `drop_segment` does) instead of `pc(p, 2)`, the original `Release`. A refused list there can be a reused spare that XCL adopted. Releasing it past the hook would skip `cl_release`'s cleanup of the list's address-keyed state (the class of #1453 / #2691). Your test still returns 0 with that. AI use: Codex (GPT-6.1-Sol) applied the patch and ran the tests. Claude Code (Claude Opus 5.5) checked the diff and wrote this reply.
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/2622/head:github-bot/gh-2622'
git switch 'github-bot/gh-2622'

Merge

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