Diagnostics: the device-removed report reaches the log when the removal is first seen outside fail(), or by two threads at once #3740

Closed
eleboucher wants to merge 41 commits from upstream-pr/3740 into main
eleboucher commented 2026-11-30 05:47:32 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by eleboucher on 2026-11-30T05:47:32Z.


With VICTORY_D3D12_DRED on, the device-removed report (log_removal_context: reason, breadcrumbs, page fault, the trail) often never reached the log.

  • Removals seen only by a warn! path printed nothing. The first call to see a removal is often a resource creation (no upload buffer … 0x887A0005), a map failure or a wait that only warns, and only fail() asked for the report. Now removed_seen(&Error) asks for it from residency::allocation_error (upload, pool blocks, alias heap chunks, host textures), the read-back/shared/mapped/UAV buffer sites, the two submission-wait error arms and the two timestamp read-back maps.
  • A second thread could end the run before the report was out. The once-flag was an AtomicBool: when two threads saw the loss together, the second skipped the report and went on to fail()/exit while the first was still writing it. It is now a std::sync::Once, so the second caller waits. The device's own data (removed reason, DRED) is written before the context, which takes locks.

Tested on an RTX 4070 Ti SUPER with a build that reproduces a removal (#3706's hardware path, ~2 min in). Before: three runs, no report at all. After: the report is in the log (device removed: …, device-removed data; …, when the host device went: …). Diagnostics builds only; nothing changes without VICTORY_D3D12_DRED. cargo xwin check/clippy with and without victory-gpu/diagnostics: no new warnings.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5559785245 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3740). Originally posted by [eleboucher](https://github.com/eleboucher) on 2026-11-30T05:47:32Z. --- With `VICTORY_D3D12_DRED` on, the device-removed report (`log_removal_context`: reason, breadcrumbs, page fault, the trail) often never reached the log. - **Removals seen only by a `warn!` path printed nothing.** The first call to see a removal is often a resource creation (`no upload buffer … 0x887A0005`), a map failure or a wait that only warns, and only `fail()` asked for the report. Now `removed_seen(&Error)` asks for it from `residency::allocation_error` (upload, pool blocks, alias heap chunks, host textures), the read-back/shared/mapped/UAV buffer sites, the two submission-wait error arms and the two timestamp read-back maps. - **A second thread could end the run before the report was out.** The once-flag was an `AtomicBool`: when two threads saw the loss together, the second skipped the report and went on to `fail()`/exit while the first was still writing it. It is now a `std::sync::Once`, so the second caller waits. The device's own data (removed reason, DRED) is written before the context, which takes locks. Tested on an RTX 4070 Ti SUPER with a build that reproduces a removal (#3706's hardware path, ~2 min in). Before: three runs, no report at all. After: the report is in the log (`device removed: …`, `device-removed data; …`, `when the host device went: …`). Diagnostics builds only; nothing changes without `VICTORY_D3D12_DRED`. `cargo xwin check`/`clippy` with and without `victory-gpu/diagnostics`: no new warnings.
Dukestar69 commented 2026-11-30 06:13:21 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-30T06:13:21Z.

Review: APPROVED


Tested locally merged onto main (41adb551).

  • Merge: Clean merge across crates/victory-gpu/src/host.rs and residency.rs.
  • Tests: cargo test -p victory-gpu --lib host::host_fence_completion_rejects_removed_device passed in both default and --features diagnostics builds with 0 new warnings.

Clean concurrency-safe device-removed diagnostic reporting outside fail(). LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6107634490 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3740#pullrequestreview-6107634490). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-30T06:13:21Z. **Review:** APPROVED --- Tested locally merged onto `main` (`41adb551`). - **Merge**: Clean merge across `crates/victory-gpu/src/host.rs` and `residency.rs`. - **Tests**: `cargo test -p victory-gpu --lib host::host_fence_completion_rejects_removed_device` passed in both default and `--features diagnostics` builds with 0 new warnings. Clean concurrency-safe device-removed diagnostic reporting outside `fail()`. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
eleboucher commented 2026-11-30 06:22:56 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by eleboucher on 2026-11-30T06:22:56Z.


The red check is function unwind_copy is never used in victory-loader, which is on main already (this diff touches only victory-gpu's host.rs and residency.rs); #2048 clears it.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7270589865 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3740#issuecomment-7270589865). Originally posted by [eleboucher](https://github.com/eleboucher) on 2026-11-30T06:22:56Z. --- The red `check` is `function unwind_copy is never used` in `victory-loader`, which is on main already (this diff touches only `victory-gpu`'s host.rs and residency.rs); #2048 clears it.
eleboucher commented 2026-11-30 14:58:21 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by eleboucher on 2026-11-30T14:58:21Z.


Merged main (c71899d9). One conflict in host.rs: main replaced the host-submission wait with wait_host_fence, whose error paths go through fail(), which already calls log_removal_context(), so main's code is kept there and the report still reaches the log on that path. The rest of the PR (Once in log_removal_context, removed_seen() at the allocation/map/wait errors) applies unchanged on main's code. cargo xwin check -p victory-gpu passes with and without diagnostics; clippy shows only two dead-code warnings that plain main has too (fixed in #2048). Note: main's victory-gpu tests do not compile at the moment (card_pass called with 5 arguments in the card-compare test); #2048 fixes that too.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7282222816 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3740#issuecomment-7282222816). Originally posted by [eleboucher](https://github.com/eleboucher) on 2026-11-30T14:58:21Z. --- Merged main (c71899d9). One conflict in host.rs: main replaced the host-submission wait with `wait_host_fence`, whose error paths go through `fail()`, which already calls `log_removal_context()`, so main's code is kept there and the report still reaches the log on that path. The rest of the PR (`Once` in `log_removal_context`, `removed_seen()` at the allocation/map/wait errors) applies unchanged on main's code. `cargo xwin check -p victory-gpu` passes with and without diagnostics; clippy shows only two dead-code warnings that plain main has too (fixed in #2048). Note: main's victory-gpu tests do not compile at the moment (`card_pass` called with 5 arguments in the card-compare test); #2048 fixes that too.
trustno1-coder commented 2026-12-01 18:49:11 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:49:11Z.


Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7321607767 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3740#issuecomment-7321607767). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:49:11Z. --- Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

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
trustno1-coder/VIctory-NVIDIA!3740
No description provided.