D3D12.X: decommit released sparse blocks outside the driver callback #783

Open
badoomtch wants to merge 1 commit from upstream-pr/789 into main
badoomtch commented 2026-11-24 05:26:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by badoomtch on 2026-11-24T05:26:18Z.


This is what is left of #789 after #1981.

#789 had two halves. #1981 fixed the first one: a placed buffer's last Release (forget_buffer)
no longer waits for the sparse state's lock (STATE). This PR is the second half.

res_release and mem_heap_release give back a block that XCL took with sparse::alloc. On main
(8b957be) they still call sparse::free, which takes STATE through decommitted. D3D12 can
make a resource's or a heap's last Release inside one of its own calls on another thread (a list's
Reset in D3D12Core, in the thread dumps below). before_execute calls D3D12 with STATE held
(begin_slot → ID3D12CommandAllocator::Reset). So the two threads can wait for each other, the
same deadlock as in #789.

Now the release only queues the block (release_owned_block). The block stays reserved and
committed, so its address cannot be handed out again yet. The next alloc, alloc_in or
before_execute decommits it and gives it back (reclaim_released_blocks, through free). That
runs without STATE held and outside any D3D12 callback. One thread reclaims at a time
(RECLAIMING): a caller that finds the queue empty while another thread is giving blocks back
waits until they are back. RECLAIMING is only taken before STATE, never with it held, and
alloc / alloc_in already take STATE (through committed), so the reclaim adds no new lock to
those paths. A reclaimed block goes through free → decommitted as before: its tiles are parked,
and main's flush_parked and quarantine unmap and free them. #1981's FORGOTTEN path is
unchanged.

What is in it

  • crates/xcl/src/hle/d3d12x/sparse.rs: release_owned_block, reclaim_released_blocks,
    RELEASED_BLOCKS, RECLAIMING. alloc, alloc_in and before_execute reclaim first. Two tests.
  • crates/xcl/src/hle/d3d12x/real.rs: res_release and mem_heap_release call
    release_owned_block in place of free. Two #[cfg(test)] helpers that give a test buffer or
    heap a block.
  • 111 lines added, 2 removed.

Tested

  • NVIDIA GeForce RTX 5080 16 GB (driver 610.88), Intel Core Ultra 7 265, 32 GB RAM, Windows 11
    build 26300, Rust 1.96.0 MSVC, release build (the suite in its default debug test profile).

  • This head (b4f9aaf, rebased on main 8b957be): cargo build --locked --release -p xcl --bin xcl
    succeeds. Its one warning (vram.rs:1110, RetiringBatch::heaps is never read) is main's.

  • cargo test --workspace -- --test-threads=4 on this head (after cargo build --workspace):
    1448 passed, 0 failed, 47 ignored (SKIPPED GPU tests: 25 forms of 15 tests, none of them a
    sparse test. 21 are "no wave64": this card has none. 3 are f16 forms the lowering refuses
    (V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32, #1426). 1 is "no heap windows":
    gpu_compute_e2e::heap_window_out_of_memory_falls_back_to_the_switch_form.) Both new tests
    passed. Of the sparse tests only early_commit_timing is ignored, as on main.

    The 25 SKIPPED lines
    gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole: no wave64
    gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu: no wave64
    gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu: no wave64
    gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu: no wave64
    gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu: no wave64
    gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu: no wave64
    gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu: const_mask, wave64: no wave64
    gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16)
    gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64: no wave64
    gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers)
    gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64: no wave64
    gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 arithmetic, wave64: no wave64
    gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 compares, wave64: no wave64
    gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32)
    gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64: no wave64
    gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 rounding, wave64: no wave64
    gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 three-source, wave64: no wave64
    gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 transcendentals, wave64: no wave64
    gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu: f64, wave64: no wave64
    gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer arithmetic, wave64: no wave64
    gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer carries, wave64: no wave64
    gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu: mask_ff0_flbit, wave64: no wave64
    gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64
    gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64
    heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
    
  • New tests:

    • a_buffer_or_heap_released_while_the_state_is_held_does_not_wait_to_free_its_block (GPU,
      ran on the RTX 5080): a real buffer and a real heap get their last Release while another
      thread holds STATE. With the two hooks calling free again, it fails after its 5 s timeout:
      "a last Release waited for the sparse state's lock to free its block".
    • an_owned_block_released_while_the_state_is_held_does_not_wait_for_it: the release does not
      wait for STATE, and the queued block keeps its reservation, its pages and its contents until
      it is reclaimed. After the reclaim it is given back.
  • Earlier runs of the same change, on older bases:

    • d5723ae on main 9633138: cargo check --release --tests clean, and
      cargo test -p xcl --lib -- sparse --test-threads=4: 26 passed, 0 failed, 1 ignored
      (early_commit_timing, ignored on main too).
    • On main 7b9eabb: cargo build --workspace --frozen without warnings; the sparse tests
      22 passed / 1 ignored in 8 runs; cargo test --workspace -- --test-threads=4: 1093 passed,
      0 failed, 46 ignored (SKIPPED: 13 tests, all "no wave64", "no heap windows" or refused f16
      forms; none of them a sparse test).
  • Reports in this thread, all on the earlier head bc82410 (the first half, now on main as
    #1981, with #968 for queue()). They show the deadlock pattern this PR closes the rest of:
    STATE held across a D3D12 call while a release hook inside D3D12Core waits for it. None of them
    ran this head.

    • imnicho, RTX 5080: thread
      dump of the cycle; with bc82410 + #968 a retail title runs with XCL_DRED=1 (918 / 910 / 920
      frames against 1 frame on main).
    • Arvi23, RX 9070 XT (RDNA4):
      the same cycle from a retail run frozen for 20 minutes; then
      bc82410 + #968 on main 930e8b4: 1104 / 1179 frames against 1 frame, and the suite
      754 passed, 0 failed, 41 ignored, no SKIPPED tests.
    • deepdev237, RX 9060 XT
      (RDNA4): the same cycle from a release PDB; bc82410 + #968 cleared the startup stall.
    • MesshM, RX 9060 XT (RDNA4):
      the suite on bc82410 merged onto main e50836b, 706 passed, 0 failed, 41 ignored, and a review.

Regression run
scripts/smoke.ps1 -Game <the retail title of #505> -Seconds 120 -Title 'retail title of 505', release builds, RTX 5080, both with the same environment: XCL_DIRECT_DXIL=1 XCL_PIPELINE_THREADS=8 XCL_PIPELINE_MAX_KB=0 (XCL_DIRECT_DXIL=1 sends compute through the direct translator, in the launch preparation and in game; the other two only affect the preparation: 8 driver compiles at once, and no size cap, which otherwise stops the launch). Same shader cache for both; no input.

main:

xcl-smoke v1
commit: 8b957bec6f82495aec940944c6bf47faa02db590
gpu: NVIDIA GeForce RTX 5080
title: retail title of 505
seconds: 120
exit: 0x0
frames shown: 791 (PresentX 791)
presents per 2 s (last 3): 15 15 14
device removals: 0
crashes: 0
peak commit: 15646 MB

PR:

xcl-smoke v1
commit: b4f9aaf213f9d606332edec01f3e14a9358b6b88
gpu: NVIDIA GeForce RTX 5080
title: retail title of 505
seconds: 120
exit: 0x0
frames shown: 3307 (PresentX 3307)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14744 MB

main's run started right after its launch preparation had built the cache's last 98 large pipelines, which likely explains its lower frame count (791 against 3,307); the PR's run started on the warm cache. Both stayed on the title's first screens (no input) and neither removed the device or crashed.

Not tested

  • The regression runs stay on the title's first screens (no input), so they do not reach heavy streaming, where the decommit path runs most.
  • AMD and Intel GPUs on this head (the reports above are of the earlier head).
  • Descriptor heaps: heap_release → console_heap::unregister still calls sparse::free from a
    final Release. #789 did not change it, and neither does this PR.

AI use

  • Claude Code (Claude Opus 5.5): prepared the change, its tests and the rebases onto main, ran
    the build and the suite on the machine named, and wrote this description.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5466651701 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/789). Originally posted by [badoomtch](https://github.com/badoomtch) on 2026-11-24T05:26:18Z. --- This is what is left of #789 after #1981. #789 had two halves. #1981 fixed the first one: a placed buffer's last Release (`forget_buffer`) no longer waits for the sparse state's lock (`STATE`). This PR is the second half. `res_release` and `mem_heap_release` give back a block that XCL took with `sparse::alloc`. On `main` (`8b957be`) they still call `sparse::free`, which takes `STATE` through `decommitted`. D3D12 can make a resource's or a heap's last Release inside one of its own calls on another thread (a list's `Reset` in D3D12Core, in the thread dumps below). `before_execute` calls D3D12 with `STATE` held (`begin_slot` → `ID3D12CommandAllocator::Reset`). So the two threads can wait for each other, the same deadlock as in #789. Now the release only queues the block (`release_owned_block`). The block stays reserved and committed, so its address cannot be handed out again yet. The next `alloc`, `alloc_in` or `before_execute` decommits it and gives it back (`reclaim_released_blocks`, through `free`). That runs without `STATE` held and outside any D3D12 callback. One thread reclaims at a time (`RECLAIMING`): a caller that finds the queue empty while another thread is giving blocks back waits until they are back. `RECLAIMING` is only taken before `STATE`, never with it held, and `alloc` / `alloc_in` already take `STATE` (through `committed`), so the reclaim adds no new lock to those paths. A reclaimed block goes through `free` → `decommitted` as before: its tiles are parked, and `main`'s `flush_parked` and quarantine unmap and free them. #1981's `FORGOTTEN` path is unchanged. **What is in it** - `crates/xcl/src/hle/d3d12x/sparse.rs`: `release_owned_block`, `reclaim_released_blocks`, `RELEASED_BLOCKS`, `RECLAIMING`. `alloc`, `alloc_in` and `before_execute` reclaim first. Two tests. - `crates/xcl/src/hle/d3d12x/real.rs`: `res_release` and `mem_heap_release` call `release_owned_block` in place of `free`. Two `#[cfg(test)]` helpers that give a test buffer or heap a block. - 111 lines added, 2 removed. **Tested** - NVIDIA GeForce RTX 5080 16 GB (driver 610.88), Intel Core Ultra 7 265, 32 GB RAM, Windows 11 build 26300, Rust 1.96.0 MSVC, release build (the suite in its default debug test profile). - This head (`b4f9aaf`, rebased on `main` `8b957be`): `cargo build --locked --release -p xcl --bin xcl` succeeds. Its one warning (`vram.rs:1110`, `RetiringBatch::heaps` is never read) is `main`'s. - `cargo test --workspace -- --test-threads=4` on this head (after `cargo build --workspace`): **1448 passed, 0 failed, 47 ignored** (SKIPPED GPU tests: 25 forms of 15 tests, none of them a sparse test. 21 are "no wave64": this card has none. 3 are f16 forms the lowering refuses (`V_MUL_F16`, `V_PK_MUL_F16`, `V_CVT_F16_F32`, #1426). 1 is "no heap windows": `gpu_compute_e2e::heap_window_out_of_memory_falls_back_to_the_switch_form`.) Both new tests passed. Of the sparse tests only `early_commit_timing` is ignored, as on `main`. <details><summary>The 25 SKIPPED lines</summary> ``` gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole: no wave64 gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu: no wave64 gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu: no wave64 gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu: no wave64 gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu: no wave64 gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu: no wave64 gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu: const_mask, wave64: no wave64 gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16) gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64: no wave64 gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers) gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64: no wave64 gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 arithmetic, wave64: no wave64 gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 compares, wave64: no wave64 gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32) gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64: no wave64 gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 rounding, wave64: no wave64 gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 three-source, wave64: no wave64 gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 transcendentals, wave64: no wave64 gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu: f64, wave64: no wave64 gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer arithmetic, wave64: no wave64 gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer carries, wave64: no wave64 gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu: mask_ff0_flbit, wave64: no wave64 gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64 gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64 heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows ``` </details> - New tests: - `a_buffer_or_heap_released_while_the_state_is_held_does_not_wait_to_free_its_block` (GPU, ran on the RTX 5080): a real buffer and a real heap get their last Release while another thread holds `STATE`. With the two hooks calling `free` again, it fails after its 5 s timeout: "a last Release waited for the sparse state's lock to free its block". - `an_owned_block_released_while_the_state_is_held_does_not_wait_for_it`: the release does not wait for `STATE`, and the queued block keeps its reservation, its pages and its contents until it is reclaimed. After the reclaim it is given back. - Earlier runs of the same change, on older bases: - `d5723ae` on `main` `9633138`: `cargo check --release --tests` clean, and `cargo test -p xcl --lib -- sparse --test-threads=4`: 26 passed, 0 failed, 1 ignored (`early_commit_timing`, ignored on `main` too). - On `main` `7b9eabb`: `cargo build --workspace --frozen` without warnings; the sparse tests 22 passed / 1 ignored in 8 runs; `cargo test --workspace -- --test-threads=4`: 1093 passed, 0 failed, 46 ignored (`SKIPPED`: 13 tests, all "no wave64", "no heap windows" or refused f16 forms; none of them a sparse test). - Reports in this thread, all on the earlier head `bc82410` (the first half, now on `main` as #1981, with #968 for `queue()`). They show the deadlock pattern this PR closes the rest of: `STATE` held across a D3D12 call while a release hook inside D3D12Core waits for it. None of them ran this head. - [imnicho](https://github.com/xcl-dev/xcl/pull/789#issuecomment-7127746948), RTX 5080: thread dump of the cycle; with `bc82410` + #968 a retail title runs with `XCL_DRED=1` (918 / 910 / 920 frames against 1 frame on `main`). - [Arvi23](https://github.com/xcl-dev/xcl/pull/789#issuecomment-7133368191), RX 9070 XT (RDNA4): the same cycle from a retail run frozen for 20 minutes; [then](https://github.com/xcl-dev/xcl/pull/789#issuecomment-7135138546) `bc82410` + #968 on `main` `930e8b4`: 1104 / 1179 frames against 1 frame, and the suite 754 passed, 0 failed, 41 ignored, no SKIPPED tests. - [deepdev237](https://github.com/xcl-dev/xcl/pull/789#issuecomment-7134910500), RX 9060 XT (RDNA4): the same cycle from a release PDB; `bc82410` + #968 cleared the startup stall. - [MesshM](https://github.com/xcl-dev/xcl/pull/789#issuecomment-7123257465), RX 9060 XT (RDNA4): the suite on `bc82410` merged onto `main` `e50836b`, 706 passed, 0 failed, 41 ignored, and a review. **Regression run** `scripts/smoke.ps1 -Game <the retail title of #505> -Seconds 120 -Title 'retail title of 505'`, release builds, RTX 5080, both with the same environment: `XCL_DIRECT_DXIL=1 XCL_PIPELINE_THREADS=8 XCL_PIPELINE_MAX_KB=0` (`XCL_DIRECT_DXIL=1` sends compute through the direct translator, in the launch preparation and in game; the other two only affect the preparation: 8 driver compiles at once, and no size cap, which otherwise stops the launch). Same shader cache for both; no input. main: ``` xcl-smoke v1 commit: 8b957bec6f82495aec940944c6bf47faa02db590 gpu: NVIDIA GeForce RTX 5080 title: retail title of 505 seconds: 120 exit: 0x0 frames shown: 791 (PresentX 791) presents per 2 s (last 3): 15 15 14 device removals: 0 crashes: 0 peak commit: 15646 MB ``` PR: ``` xcl-smoke v1 commit: b4f9aaf213f9d606332edec01f3e14a9358b6b88 gpu: NVIDIA GeForce RTX 5080 title: retail title of 505 seconds: 120 exit: 0x0 frames shown: 3307 (PresentX 3307) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14744 MB ``` main's run started right after its launch preparation had built the cache's last 98 large pipelines, which likely explains its lower frame count (791 against 3,307); the PR's run started on the warm cache. Both stayed on the title's first screens (no input) and neither removed the device or crashed. **Not tested** - The regression runs stay on the title's first screens (no input), so they do not reach heavy streaming, where the decommit path runs most. - AMD and Intel GPUs on this head (the reports above are of the earlier head). - Descriptor heaps: `heap_release` → `console_heap::unregister` still calls `sparse::free` from a final Release. #789 did not change it, and neither does this PR. **AI use** - Claude Code (Claude Opus 5.5): prepared the change, its tests and the rebases onto `main`, ran the build and the suite on the machine named, and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MesshM commented 2026-11-24 07:06:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by MesshM on 2026-11-24T05:46:15Z.


Test run of bc82410abd9ccad26987ed86ec82f4194e06a888 on AMD RDNA4. I merged it onto current main e50836b locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 706 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 665 passed, 0 failed, 21 ignored
  • 0 SKIPPED; the sparse tests pass.

Review: Taking the buffer's pins out before the release and dropping them outside the sparse-state lock removes the second wait-for-each-other path (allocator reset holding the lock vs. the release callback taking it), the same pattern #443 used for the device replacement. I found nothing to change.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

<!-- greyfinch-sync:ivall/xcl:comment:7123257465 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/789#issuecomment-7123257465). Originally posted by [MesshM](https://github.com/MesshM) on 2026-11-24T05:46:15Z. --- Test run of `bc82410abd9ccad26987ed86ec82f4194e06a888` on AMD RDNA4. I merged it onto current `main` `e50836b` locally (clean merge) and tested that tree. **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 `stable-x86_64-pc-windows-msvc`, debug - `cargo build --workspace` + `cargo test --workspace -- --test-threads=4` on the merge: **706 passed, 0 failed, 41 ignored**, exit code 0; `xcl` lib tests 665 passed, 0 failed, 21 ignored - **0 `SKIPPED`**; the `sparse` tests pass. **Review:** Taking the buffer's pins out before the release and dropping them outside the sparse-state lock removes the second wait-for-each-other path (allocator reset holding the lock vs. the release callback taking it), the same pattern #443 used for the device replacement. I found nothing to change. **Not tested:** no retail title or regression run (I have no unpacked game), no `XCL_SAMPLE_*` tests, release build; the PR's head on its old base was not run, only its merge onto `main`. Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
imnicho commented 2026-11-24 10:04:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by imnicho on 2026-11-24T09:41:07Z.


Test report: with XCL_DRED=1 this PR's path is the first of two (RTX 5080, a retail title)

bc82410 merged onto main 077ce40 (clean), release. The newer retail title of the README, XCL_NETWORK=0, XCL_DRED=1, no input (its first screens), 45 s runs, four builds in turn, 3 rounds. Frames shown, and when the 2 s activity log stops (it stands still with the title):

build round 1 round 2 round 3
main (077ce40) 1 frame, still from 10.8 s 1 frame, still from 8.1 s 1 frame, still from 8.3 s
main + this PR 1 frame, still from 10.9 s 1 frame, still from 8.7 s 1 frame, still from 10.5 s
main + #968 1 frame, still from 10.5 s 1 frame, still from 8.0 s 1 frame, still from 10.5 s
main + this PR + #968 918 frames 910 frames 920 frames
  • Without this PR (thread dump of a local stack on main 09940bb) the two threads are the ones this PR describes: one in State::begin_slot → ID3D12CommandAllocator::Reset with the sparse-state mutex held, the other in a list's Reset → D3D12Core → the release hook → sparse::forget_buffer.
  • With this PR that wait is gone: the release hook gets past forget_buffer. The same two threads then meet one step later, in late_release::hold → drain_known → sparse::queue(), which takes the same mutex to clone the queue. That is #968 (queue() only; merging the two gives textual conflicts in sparse.rs where both add lines at the same three places – both sides are kept).
  • With both, the title runs with XCL_DRED=1; a longer run reached the device removal of #675 and logged its breadcrumbs (on #675).
  • This PR's own tests in the merged tree were not run again by me; the suite on #968 alone is in its description.

Hardware: Intel Core i7-7700K, 16 GB RAM, NVIDIA GeForce RTX 5080 16 GB (driver 610.47), Windows 10 22H2 (19045), Agility SDK 620, rustc 1.100.0.

AI use: Claude Code with Claude Fable 5.2 read the thread dumps (XCL frames symbolised from the build's PDB) and wrote this; the runs are from the machine named.

<!-- greyfinch-sync:ivall/xcl:comment:7127746948 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/789#issuecomment-7127746948). Originally posted by [imnicho](https://github.com/imnicho) on 2026-11-24T09:41:07Z. --- **Test report: with `XCL_DRED=1` this PR's path is the first of two (RTX 5080, a retail title)** `bc82410` merged onto `main` `077ce40` (clean), release. The newer retail title of the README, `XCL_NETWORK=0`, `XCL_DRED=1`, no input (its first screens), 45 s runs, four builds in turn, 3 rounds. Frames shown, and when the 2 s activity log stops (it stands still with the title): | build | round 1 | round 2 | round 3 | |---|---|---|---| | `main` (`077ce40`) | 1 frame, still from 10.8 s | 1 frame, still from 8.1 s | 1 frame, still from 8.3 s | | `main` + this PR | 1 frame, still from 10.9 s | 1 frame, still from 8.7 s | 1 frame, still from 10.5 s | | `main` + #968 | 1 frame, still from 10.5 s | 1 frame, still from 8.0 s | 1 frame, still from 10.5 s | | `main` + this PR + #968 | **918 frames** | **910 frames** | **920 frames** | - Without this PR (thread dump of a local stack on `main` `09940bb`) the two threads are the ones this PR describes: one in `State::begin_slot` → `ID3D12CommandAllocator::Reset` with the sparse-state mutex held, the other in a list's `Reset` → D3D12Core → the release hook → `sparse::forget_buffer`. - With this PR that wait is gone: the release hook gets past `forget_buffer`. The same two threads then meet one step later, in `late_release::hold` → `drain_known` → `sparse::queue()`, which takes the same mutex to clone the queue. That is #968 (`queue()` only; merging the two gives textual conflicts in `sparse.rs` where both add lines at the same three places – both sides are kept). - With both, the title runs with `XCL_DRED=1`; a longer run reached the device removal of #675 and logged its breadcrumbs (on #675). - This PR's own tests in the merged tree were not run again by me; the suite on #968 alone is in its description. Hardware: Intel Core i7-7700K, 16 GB RAM, NVIDIA GeForce RTX 5080 16 GB (driver 610.47), Windows 10 22H2 (19045), Agility SDK 620, rustc 1.100.0. AI use: Claude Code with Claude Fable 5.2 read the thread dumps (XCL frames symbolised from the build's PDB) and wrote this; the runs are from the machine named.
Arvi23 commented 2026-11-24 14:06:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Arvi23 on 2026-11-24T13:48:33Z.


The same cycle on AMD (RDNA4), from a retail run that froze at 5 s and stayed frozen for 20 minutes until it was stopped. Two title threads in the thread dump, symbolised with the PDB of a rebuild of the run's tree (e50836b + #708 + #684's CopyFromSubresource fix, none of which touches sparse.rs or res_release):

  • q_execute_command_lists → title_textures::refresh → sparse::before_execute → State::upload_dirty → State::begin_slot (holding STATE) → ID3D12CommandAllocator::Reset → D3D12Core, waiting on a critical section;
  • list_x::reset_x → the native list Reset in D3D12Core → real::res_release → sparse::forget_buffer, waiting for STATE.

The run had XCL_DRED=1, as in the #675 / #968 reports. The pipeline preload was compiling a big compute program in amdxc64 at the same time, which made it look like #1035, but no preload thread is in the cycle.

Setup: AMD Radeon RX 9070 XT 16 GB (driver 26.11.2), Ryzen 7 5800X3D, 32 GB, Windows 10 IoT Enterprise LTSC 21H2 (19044), release build.

I haven't run #789 itself here.

Written with Claude Code (Claude Opus 5.5) from the run's log and thread dump.

<!-- greyfinch-sync:ivall/xcl:comment:7133368191 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/789#issuecomment-7133368191). Originally posted by [Arvi23](https://github.com/Arvi23) on 2026-11-24T13:48:33Z. --- The same cycle on AMD (RDNA4), from a retail run that froze at 5 s and stayed frozen for 20 minutes until it was stopped. Two title threads in the thread dump, symbolised with the PDB of a rebuild of the run's tree (`e50836b` + #708 + #684's CopyFromSubresource fix, none of which touches `sparse.rs` or `res_release`): - `q_execute_command_lists` → `title_textures::refresh` → `sparse::before_execute` → `State::upload_dirty` → `State::begin_slot` (holding `STATE`) → `ID3D12CommandAllocator::Reset` → D3D12Core, waiting on a critical section; - `list_x::reset_x` → the native list `Reset` in D3D12Core → `real::res_release` → `sparse::forget_buffer`, waiting for `STATE`. The run had `XCL_DRED=1`, as in the #675 / #968 reports. The pipeline preload was compiling a big compute program in amdxc64 at the same time, which made it look like #1035, but no preload thread is in the cycle. Setup: AMD Radeon RX 9070 XT 16 GB (driver 26.11.2), Ryzen 7 5800X3D, 32 GB, Windows 10 IoT Enterprise LTSC 21H2 (19044), release build. I haven't run #789 itself here. Written with Claude Code (Claude Opus 5.5) from the run's log and thread dump.
deepdev237 commented 2026-11-24 15:06:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by deepdev237 on 2026-11-24T14:45:57Z.


Retail DRED startup lock on AMD RDNA4

Tested

  • AMD Radeon RX 9060 XT (RDNA4, driver 32.0.32015.7029), Ryzen 9 5950X, Windows 11 build 26300, Rust 1.100.0 MSVC, release.
  • xcl.exe run "<retail-title>" with XCL_DRED=1, XCL_NETWORK=0 and matching seeded DXIL caches. The control was a local diagnostic stack based on 47efa2ecea0a12934719ae69b81930cf02a4b1c3 (Git tree 33f77129622ede6608187d6a1d68e48bcd8c84f1). Its last output was at 7.436 s. Two thread samples symbolized with the release PDB showed:
    • q_execute_command_lists → sparse::before_execute → State::upload_dirty → State::begin_slot → ID3D12CommandAllocator::Reset, holding the sparse-state mutex inside D3D12Core.
    • list_x::reset_x → D3D12Core → res_release → sparse::forget_buffer, waiting for that mutex.
  • Applying #789 bc82410abd9ccad26987ed86ec82f4194e06a888 together with #968 9beaa733fbead2d7909d22d36d59f6dc9e16dc64 (tree f4890332e2b99b49ef23de068079e86e2b4cfbef) cleared the startup stall in the paired run. DRED then produced breadcrumbs on DXGI_ERROR_DEVICE_HUNG at 204.029 s.
  • Combined tree, cargo test --offline --locked --release -p xcl --lib hle::d3d12x::sparse::tests -- --nocapture --test-threads=1: 14 passed, 0 failed, 1 ignored, zero GPU skips.

Not tested — #789 alone, clean upstream main, or rendered gameplay.

AI use — OpenAI Codex (gpt-6.2-sol) ran the tests, checked the local receipts and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7134910500 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/789#issuecomment-7134910500). Originally posted by [deepdev237](https://github.com/deepdev237) on 2026-11-24T14:45:57Z. --- **Retail DRED startup lock on AMD RDNA4** **Tested** - AMD Radeon RX 9060 XT (RDNA4, driver `32.0.32015.7029`), Ryzen 9 5950X, Windows 11 build 26300, Rust 1.100.0 MSVC, release. - `xcl.exe run "<retail-title>"` with `XCL_DRED=1`, `XCL_NETWORK=0` and matching seeded DXIL caches. The control was a local diagnostic stack based on `47efa2ecea0a12934719ae69b81930cf02a4b1c3` (Git tree `33f77129622ede6608187d6a1d68e48bcd8c84f1`). Its last output was at 7.436 s. Two thread samples symbolized with the release PDB showed: - `q_execute_command_lists → sparse::before_execute → State::upload_dirty → State::begin_slot → ID3D12CommandAllocator::Reset`, holding the sparse-state mutex inside D3D12Core. - `list_x::reset_x → D3D12Core → res_release → sparse::forget_buffer`, waiting for that mutex. - Applying #789 `bc82410abd9ccad26987ed86ec82f4194e06a888` **together with** #968 `9beaa733fbead2d7909d22d36d59f6dc9e16dc64` (tree `f4890332e2b99b49ef23de068079e86e2b4cfbef`) cleared the startup stall in the paired run. DRED then produced breadcrumbs on `DXGI_ERROR_DEVICE_HUNG` at 204.029 s. - Combined tree, `cargo test --offline --locked --release -p xcl --lib hle::d3d12x::sparse::tests -- --nocapture --test-threads=1`: **14 passed, 0 failed, 1 ignored**, zero GPU skips. **Not tested** — #789 alone, clean upstream main, or rendered gameplay. **AI use** — OpenAI Codex (`gpt-6.2-sol`) ran the tests, checked the local receipts and wrote this report.
Arvi23 commented 2026-11-24 15:06:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Arvi23 on 2026-11-24T14:54:17Z.


Test report: the same result on AMD RDNA4 (RX 9070 XT), with XCL_DRED=1, on current main

bc82410 merged onto main 930e8b4, and #968 (pr-968 head) merged on top of that. Both merges have conflicts only in sparse.rs. I kept both sides:

  • main's new parked field and flush_parked step next to this PR's released_pins. before_execute runs reclaim_released_pins first, then flush_parked.
  • main's two newer test constructors take released_pins in place of buffers.
  • #968's QUEUE next to this PR's statics, and both PRs' tests.

The merged trees differ from main only in real.rs and sparse.rs.

The retail title of #505, release builds, XCL_NETWORK=0, XCL_DRED=1, XCL_ACTIVITY=1, no input, 45 s runs (XCL_RUN_SECONDS), the three builds in turn, 2 rounds:

build round 1 round 2
main (930e8b4) 1 frame, still from 6.0 s 1 frame, still from 6.0 s
main + this PR 1 frame, still from 6.0 s 1 frame, still from 6.0 s
main + this PR + #968 1104 frames 1179 frames

This covers the two cases @deepdev237's RDNA4 report leaves out: this PR on its own, and clean main. On its own it does not get past the start-up here either.

"Still from" is the last 2 s activity line. No crash or device removal in any run. #789's "could not retire owned block" warning appears in none of the six logs. These runs have no thread dumps, so I can't say where main + this PR stops. The pattern is the one @imnicho reported on the RTX 5080 (#968's queue()). Separately, an earlier run here (RX 9070 XT, e50836b + local changes, XCL_DRED=1) froze in this PR's path: begin_slot → ID3D12CommandAllocator::Reset against reset_x → D3D12Core → res_release → forget_buffer, symbolised from the build's PDB.

cargo test --workspace -- --test-threads=4 (debug) on the merged tree (main + this PR + #968): 754 passed, 0 failed, 41 ignored, no SKIPPED tests. Both of this PR's tests and #968's pass. final_buffer_release_completes_with_sparse_state_locked ran on the GPU and was not skipped.

Hardware: AMD Radeon RX 9070 XT 16 GB (RDNA4, driver 26.11.2), Ryzen 7 5800X3D, 32 GB RAM, Windows 10 IoT Enterprise LTSC 21H2 (19044), rustc 1.100.0 MSVC, DXC 1.9.2609.5.

Not tested: this PR's head on its own base (6025201), runs without XCL_DRED=1, runs longer than 45 s.

Written with Claude Code (Claude Opus 5.5): it made the merges and the run script, ran the test suite and wrote this report. The title runs are mine, on the machine named.

<!-- greyfinch-sync:ivall/xcl:comment:7135138546 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/789#issuecomment-7135138546). Originally posted by [Arvi23](https://github.com/Arvi23) on 2026-11-24T14:54:17Z. --- **Test report: the same result on AMD RDNA4 (RX 9070 XT), with `XCL_DRED=1`, on current `main`** `bc82410` merged onto `main` `930e8b4`, and #968 (`pr-968` head) merged on top of that. Both merges have conflicts only in `sparse.rs`. I kept both sides: - `main`'s new `parked` field and `flush_parked` step next to this PR's `released_pins`. `before_execute` runs `reclaim_released_pins` first, then `flush_parked`. - `main`'s two newer test constructors take `released_pins` in place of `buffers`. - #968's `QUEUE` next to this PR's statics, and both PRs' tests. The merged trees differ from `main` only in `real.rs` and `sparse.rs`. The retail title of #505, release builds, `XCL_NETWORK=0`, `XCL_DRED=1`, `XCL_ACTIVITY=1`, no input, 45 s runs (`XCL_RUN_SECONDS`), the three builds in turn, 2 rounds: | build | round 1 | round 2 | |---|---|---| | `main` (`930e8b4`) | 1 frame, still from 6.0 s | 1 frame, still from 6.0 s | | `main` + this PR | 1 frame, still from 6.0 s | 1 frame, still from 6.0 s | | `main` + this PR + #968 | **1104 frames** | **1179 frames** | This covers the two cases @deepdev237's RDNA4 report leaves out: this PR on its own, and clean `main`. On its own it does not get past the start-up here either. "Still from" is the last 2 s activity line. No crash or device removal in any run. #789's "could not retire owned block" warning appears in none of the six logs. These runs have no thread dumps, so I can't say where `main` + this PR stops. The pattern is the one @imnicho reported on the RTX 5080 (#968's `queue()`). Separately, an earlier run here (RX 9070 XT, `e50836b` + local changes, `XCL_DRED=1`) froze in this PR's path: `begin_slot` → `ID3D12CommandAllocator::Reset` against `reset_x` → D3D12Core → `res_release` → `forget_buffer`, symbolised from the build's PDB. `cargo test --workspace -- --test-threads=4` (debug) on the merged tree (`main` + this PR + #968): 754 passed, 0 failed, 41 ignored, no SKIPPED tests. Both of this PR's tests and #968's pass. `final_buffer_release_completes_with_sparse_state_locked` ran on the GPU and was not skipped. Hardware: AMD Radeon RX 9070 XT 16 GB (RDNA4, driver 26.11.2), Ryzen 7 5800X3D, 32 GB RAM, Windows 10 IoT Enterprise LTSC 21H2 (19044), rustc 1.100.0 MSVC, DXC 1.9.2609.5. Not tested: this PR's head on its own base (`6025201`), runs without `XCL_DRED=1`, runs longer than 45 s. Written with Claude Code (Claude Opus 5.5): it made the merges and the run script, ran the test suite and wrote this report. The title runs are mine, on the machine named.
DavidM1911 commented 2026-11-25 11:09:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T11:08:55Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7160657104 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/789#issuecomment-7160657104). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T11:08:55Z. --- Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
badoomtch commented 2026-11-26 21:42:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by badoomtch on 2026-11-26T21:42:12Z.


@DavidM1911 thanks, rebased onto main 8b957be: the head is now b4f9aaf, and GitHub shows it mergeable.

  • Conflicts: all in crates/xcl/src/hle/d3d12x/sparse.rs. main's code is kept as it is (parked, flush_parked, and the quarantine from 10e9fb76), and this PR's release_owned_block / reclaim_released_blocks sit next to it. res_release and mem_heap_release queue the block in place of calling sparse::free, so no lock is taken inside D3D12's callback. The next alloc, alloc_in or before_execute frees a queued block through free → decommitted as before, without STATE held.
  • Build: cargo build --locked --release -p xcl --bin xcl succeeds (one warning, main's vram.rs:1110).
  • Tests on the RTX 5080 (driver 610.88): cargo test --workspace -- --test-threads=4: 1448 passed, 0 failed, 47 ignored. The 25 SKIPPED forms are "no wave64", refused f16 forms and "no heap windows", none of them a sparse test. Both new tests pass.
  • Not yet run: scripts/smoke.ps1 on main and on this head. The description now follows the template.

Written with Claude Code (Claude Opus 5.5) from the runs on the machine named.

<!-- greyfinch-sync:ivall/xcl:comment:7203979437 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/789#issuecomment-7203979437). Originally posted by [badoomtch](https://github.com/badoomtch) on 2026-11-26T21:42:12Z. --- @DavidM1911 thanks, rebased onto `main` `8b957be`: the head is now `b4f9aaf`, and GitHub shows it mergeable. - Conflicts: all in `crates/xcl/src/hle/d3d12x/sparse.rs`. `main`'s code is kept as it is (`parked`, `flush_parked`, and the quarantine from `10e9fb76`), and this PR's `release_owned_block` / `reclaim_released_blocks` sit next to it. `res_release` and `mem_heap_release` queue the block in place of calling `sparse::free`, so no lock is taken inside D3D12's callback. The next `alloc`, `alloc_in` or `before_execute` frees a queued block through `free` → `decommitted` as before, without `STATE` held. - Build: `cargo build --locked --release -p xcl --bin xcl` succeeds (one warning, `main`'s `vram.rs:1110`). - Tests on the RTX 5080 (driver 610.88): `cargo test --workspace -- --test-threads=4`: 1448 passed, 0 failed, 47 ignored. The 25 SKIPPED forms are "no wave64", refused f16 forms and "no heap windows", none of them a sparse test. Both new tests pass. - Not yet run: `scripts/smoke.ps1` on `main` and on this head. The description now follows the template. Written with Claude Code (Claude Opus 5.5) from the runs on the machine named.
Foniass commented 2026-12-01 04:08:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:08:11Z.


Triage (#1607) – head b4f9aaf

No open or merged PR defers the sparse block free of res_release / mem_heap_release. Main still calls sparse::free there (now inside release_taking_first for heaps), and free still takes the sparse state through decommitted, so the problem is still there.
The PR conflicts with main: res_release and mem_heap_release were restructured since its base, so the two call sites need to be redone on a rebase.
Minor: reclaim_released_blocks holds RECLAIMING while free waits for STATE. Please confirm no sparse::alloc / alloc_in caller holds STATE, otherwise that is a new lock-order cycle.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7300415418 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/789#issuecomment-7300415418). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T04:08:11Z. --- **Triage (#1607)** – head b4f9aaf No open or merged PR defers the sparse block free of `res_release` / `mem_heap_release`. Main still calls `sparse::free` there (now inside `release_taking_first` for heaps), and `free` still takes the sparse state through `decommitted`, so the problem is still there. The PR conflicts with main: `res_release` and `mem_heap_release` were restructured since its base, so the two call sites need to be redone on a rebase. Minor: `reclaim_released_blocks` holds `RECLAIMING` while `free` waits for `STATE`. Please confirm no `sparse::alloc` / `alloc_in` caller holds `STATE`, otherwise that is a new lock-order cycle. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/789:upstream-pr/789'
git switch 'upstream-pr/789'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/789'
git switch 'upstream-pr/789'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/789'
git switch 'upstream-pr/789'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/789'
git switch 'main'
git merge --squash 'upstream-pr/789'
git switch 'main'
git merge --ff-only 'upstream-pr/789'
git switch 'main'
git merge 'upstream-pr/789'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!783
No description provided.