fix(gpu/run): keep descriptor heaps alive, harden device loss handling #236

Closed
racknea wants to merge 1 commit from upstream-pr/239 into main
racknea commented 2026-11-23 21:45:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by racknea on 2026-11-23T21:45:25Z.


No description provided.

<!-- greyfinch-sync:ivall/xcl:issue:6569461483 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/239). Originally posted by [racknea](https://github.com/racknea) on 2026-11-23T21:45:25Z. --- _No description provided._
denio4321 commented 2026-11-24 07:04:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by denio4321 on 2026-11-23T22:13:34Z.


Tested cc124cf merged onto main 9ab7d76 on RTX 3060 12 GB (Ampere, 32-lane waves), NVIDIA 610.88, Windows 11 Pro 23H2 (22631), rustc 1.100.0 MSVC, DXC 1.9.2602.17.

.\scripts\test.ps1 (debug, --test-threads=4), no XCL_SAMPLE_* set. Baseline main 9ab7d76 alone on the same machine: 651 passed, 0 failed, 40 ignored.

  • This PR: 651 passed, 0 failed, 40 ignored, the same as main. Nothing regresses in the GPU tests that go through gpu/run.
  • The PR adds no test, and the suite never loses the device, so the device-loss path it changes isn't exercised by this run. A short description of what failed before (which heap was released early, and where) would make the 500 / 474 line rewrite easier to review.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ivall/xcl:comment:7115486278 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/239#issuecomment-7115486278). Originally posted by [denio4321](https://github.com/denio4321) on 2026-11-23T22:13:34Z. --- Tested `cc124cf` merged onto `main` `9ab7d76` on RTX 3060 12 GB (Ampere, 32-lane waves), NVIDIA 610.88, Windows 11 Pro 23H2 (22631), rustc 1.100.0 MSVC, DXC 1.9.2602.17. `.\scripts\test.ps1` (debug, `--test-threads=4`), no `XCL_SAMPLE_*` set. Baseline `main` `9ab7d76` alone on the same machine: 651 passed, 0 failed, 40 ignored. - This PR: **651 passed, 0 failed, 40 ignored**, the same as `main`. Nothing regresses in the GPU tests that go through `gpu/run`. - The PR adds no test, and the suite never loses the device, so the device-loss path it changes isn't exercised by this run. A short description of what failed before (which heap was released early, and where) would make the 500 / 474 line rewrite easier to review. AI-assisted (Claude Code).
Kalmarv commented 2026-11-24 07:04:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-23T22:30:22Z.


Please keep the empty-draw heap fix and revise device removal before merging. Two controls on an RTX 5070 Ti showed where recovery breaks.

  1. A timeout removes the caller’s healthy device. I held an idle queue behind a CPU fence for 11.5 seconds. Both builds returned the ten-second timeout. On main, GetDeviceRemovedReason returned S_OK and the submission fence completed after release. On the merge it returned DXGI_ERROR_DEVICE_REMOVED (0x887A0005). No shader ran. Both draw_on_multi and dispatch_on pass a caller-owned device to this helper. Keep submitted resources alive until completion or confirmed removal and leave device-wide recovery to the owner. Error path · D3D12 removal semantics
  2. One failed recreation disables later retries. I retained a second device reference during explicit removal and the first retry. After releasing it, an independent init() succeeded on the merge, but the public runner still returned the cached removal error. Cache successful recreation and leave the slot empty on a transient failure. Cache path · D3D12 device identity

Tested

Windows 11 Pro 26200.9711, Ryzen 9 9950X, RTX 5070 Ti, NVIDIA 610.74, native D3D12, DXC 1.7.2308.16. Local merge 61583594e366877a62fb109066626dadedd0836a of head cc124cf80159f160da0505ac79e4d340b82afa60 onto main 7a033c8cd13194900cd49c01ed60a59c6c9559c7. The PR adds no tests.

Local synthetic control Main Merge
Empty-texture, empty-sampler draw Heap owner dropped before submission. Assertion stopped the draw. Owner survived the fence. Read back red and observed release on return.
Poisoned GPU mutex and explicit removal with no other owner Next lookup panicked or next allocation failed, respectively Both recovered
Short texture, seven-face cube, private zero-window arena Panicked, accepted, panicked All three returned errors
Two static samplers through run_code, stopping after PSO creation E_INVALIDARG PSO created
Valid UMA dispatch, with separate drop counters for the temporary window list and bound heaps Neither counter advanced Both advanced. Shader output matched main.

On the unmodified merge, cargo test -p xcl -j2 --lib --no-run followed by the binary with gpu::recomp:: --test-threads=1 reported 182 passed, 0 failed, 18 ignored, including two native-wave64 skips and one sample-dependent early return. Queued runs of the fence tests (5), compute integration tests (2), predication integration test (1), UMA test (1) and static-sampler test (1) passed on both builds. The 11 review controls above and in the findings ran individually in fresh processes. Nine failed on main and passed on the merge, one regressed, and one failed on both.

Merge order. Each head conflicts with #239 in runner.rs. Rebase #214 (bf2a27e) after #187 (c74b03a) and preserve #187’s populated window UAV heap in both arena and compute dispatch. #214 already conflicts with main in real.rs. Preserve #152’s cached draw queue and increasing fence value (4ba00d9) when applying the lifetime fix. Its conflicts in recomp/mod.rs and tests.rs already exist on main.

Not tested

The retail game, AMD, WARP, a real driver TDR, or timing changes from I/O packing, barrier batching and removing the second map. The static-sampler control checked PSO creation only. An initial invalid-DXIL arena probe terminated without an assertion result and is excluded from the counts.

🤖 GPT-6.2 Astra

<!-- greyfinch-sync:ivall/xcl:comment:7115838518 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/239#issuecomment-7115838518). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-23T22:30:22Z. --- **Please keep the empty-draw heap fix and revise device removal before merging.** Two controls on an RTX 5070 Ti showed where recovery breaks. 1. **A timeout removes the caller’s healthy device.** I held an idle queue behind a CPU fence for 11.5 seconds. Both builds returned the ten-second timeout. On main, `GetDeviceRemovedReason` returned `S_OK` and the submission fence completed after release. On the merge it returned `DXGI_ERROR_DEVICE_REMOVED` (`0x887A0005`). No shader ran. Both `draw_on_multi` and `dispatch_on` pass a caller-owned device to this helper. Keep submitted resources alive until completion or confirmed removal and leave device-wide recovery to the owner. [Error path](https://github.com/ivall/xcl/blob/cc124cf80159f160da0505ac79e4d340b82afa60/crates/xcl/src/gpu/recomp/runner.rs#L83) · [D3D12 removal semantics](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device5-removedevice) 2. **One failed recreation disables later retries.** I retained a second device reference during explicit removal and the first retry. After releasing it, an independent `init()` succeeded on the merge, but the public runner still returned the cached removal error. Cache successful recreation and leave the slot empty on a transient failure. [Cache path](https://github.com/ivall/xcl/blob/cc124cf80159f160da0505ac79e4d340b82afa60/crates/xcl/src/gpu/recomp/runner.rs#L105) · [D3D12 device identity](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-d3d12createdevice#remarks) **Tested** Windows 11 Pro 26200.9711, Ryzen 9 9950X, RTX 5070 Ti, NVIDIA 610.74, native D3D12, DXC 1.7.2308.16. Local merge `61583594e366877a62fb109066626dadedd0836a` of head `cc124cf80159f160da0505ac79e4d340b82afa60` onto main `7a033c8cd13194900cd49c01ed60a59c6c9559c7`. The PR adds no tests. | Local synthetic control | Main | Merge | |---|---|---| | Empty-texture, empty-sampler draw | Heap owner dropped before submission. Assertion stopped the draw. | Owner survived the fence. Read back red and observed release on return. | | Poisoned GPU mutex and explicit removal with no other owner | Next lookup panicked or next allocation failed, respectively | Both recovered | | Short texture, seven-face cube, private zero-window arena | Panicked, accepted, panicked | All three returned errors | | Two static samplers through `run_code`, stopping after PSO creation | `E_INVALIDARG` | PSO created | | Valid UMA dispatch, with separate drop counters for the temporary window list and bound heaps | Neither counter advanced | Both advanced. Shader output matched main. | On the unmodified merge, `cargo test -p xcl -j2 --lib --no-run` followed by the binary with `gpu::recomp:: --test-threads=1` reported **182 passed, 0 failed, 18 ignored**, including two native-wave64 skips and one sample-dependent early return. Queued runs of the fence tests (5), compute integration tests (2), predication integration test (1), UMA test (1) and static-sampler test (1) passed on both builds. The 11 review controls above and in the findings ran individually in fresh processes. Nine failed on main and passed on the merge, one regressed, and one failed on both. **Merge order.** Each head conflicts with #239 in `runner.rs`. Rebase #214 (`bf2a27e`) after #187 (`c74b03a`) and preserve #187’s populated window UAV heap in both arena and compute dispatch. #214 already conflicts with main in `real.rs`. Preserve #152’s cached draw queue and increasing fence value (`4ba00d9`) when applying the lifetime fix. Its conflicts in `recomp/mod.rs` and `tests.rs` already exist on main. **Not tested** The retail game, AMD, WARP, a real driver TDR, or timing changes from I/O packing, barrier batching and removing the second map. The static-sampler control checked PSO creation only. An initial invalid-DXIL arena probe terminated without an assertion result and is excluded from the counts. 🤖 GPT-6.2 Astra
upstream-sync closed this pull request 2026-11-24 11:04:38 +00:00
raylitebull commented 2026-11-24 11:05:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-24T10:43:35Z.


Closing as a stale, conflicting PR with an empty description and unresolved device-loss recovery review feedback. Feel free to submit a fresh, scoped PR for the descriptor-heap fix per CONTRIBUTING.md.

<!-- greyfinch-sync:ivall/xcl:comment:7129162336 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/239#issuecomment-7129162336). Originally posted by [raylitebull](https://github.com/raylitebull) on 2026-11-24T10:43:35Z. --- Closing as a stale, conflicting PR with an empty description and unresolved device-loss recovery review feedback. Feel free to submit a fresh, scoped PR for the descriptor-heap fix per `CONTRIBUTING.md`.

Pull request closed

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!236
No description provided.