D3D12: check device removal before using GPU readbacks #108

Merged
certified-retart merged 1 commit from upstream-pr/109 into main 2026-11-23 11:32:41 +00:00
certified-retart commented 2026-11-23 11:23:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by certified-retart on 2026-11-23T11:23:27Z.


When D3D12 removes the device, GetCompletedValue returns UINT64_MAX and an event registered on the fence can wake. The old comparisons accepted that value as a completed copy and proceeded to map the readback buffer.

Check the completion value before registering the event and again after waiting. Return the device's removal reason when available. The compute, draw and texture helpers now stop before mapping an unconfirmed readback, including timestamp results. The presenter retains its copy resources until completion and skips an unconfirmed frame dump. The shutdown queue drain also distinguishes removal from a pending fence.

Five deterministic tests cover completion, removal before registration or after wake, a stale event, timeout resampling and registration failure. They use synthetic fence values without resetting either GPU.

On Windows with Agility SDK 620, the RTX 5070 and Ryzen 9800X3D Radeon iGPU each passed the library suite (434 passed, 16 ignored), both launcher tests and the synthetic compute dispatch/readback test. Each configuration also passed with XCL_SPLIT_WAVE64=1. Builds used two jobs and tests ran on a single thread.

The RTX compute integration test with the inbox D3D12 runtime fails during root-signature creation (0x80070057) on both upstream 60599a9 and the patched code; Agility passes. Sparse-memory staging and one-shot resource lifetime after an ordinary timeout are separate from this readback fix.

<!-- greyfinch-sync:ivall/xcl:issue:6558169439 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/109). Originally posted by [certified-retart](https://github.com/certified-retart) on 2026-11-23T11:23:27Z. --- When D3D12 removes the device, GetCompletedValue returns UINT64_MAX and an event registered on the fence can wake. The old comparisons accepted that value as a completed copy and proceeded to map the readback buffer. Check the completion value before registering the event and again after waiting. Return the device's removal reason when available. The compute, draw and texture helpers now stop before mapping an unconfirmed readback, including timestamp results. The presenter retains its copy resources until completion and skips an unconfirmed frame dump. The shutdown queue drain also distinguishes removal from a pending fence. Five deterministic tests cover completion, removal before registration or after wake, a stale event, timeout resampling and registration failure. They use synthetic fence values without resetting either GPU. On Windows with Agility SDK 620, the RTX 5070 and Ryzen 9800X3D Radeon iGPU each passed the library suite (434 passed, 16 ignored), both launcher tests and the synthetic compute dispatch/readback test. Each configuration also passed with XCL_SPLIT_WAVE64=1. Builds used two jobs and tests ran on a single thread. The RTX compute integration test with the inbox D3D12 runtime fails during root-signature creation (0x80070057) on both upstream 60599a9 and the patched code; Agility passes. Sparse-memory staging and one-shot resource lifetime after an ordinary timeout are separate from this readback fix.
upstream-sync closed this pull request 2026-11-24 06:57:11 +00:00
ivall commented 2026-11-24 07:00:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T11:32:53Z.


Merged. Checked on Windows 11 with an RX 9070: cargo test --workspace green with the retail samples (shader pack, console DLLs, texture archive), lib tests also with XCL_SPLIT_WAVE64=1; Unicorn Overlord runs with #107–#109 merged. Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7099784000 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/109#issuecomment-7099784000). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T11:32:53Z. --- Merged. Checked on Windows 11 with an RX 9070: `cargo test --workspace` green with the retail samples (shader pack, console DLLs, texture archive), lib tests also with `XCL_SPLIT_WAVE64=1`; Unicorn Overlord runs with #107–#109 merged. Thanks!
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!108
No description provided.