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

Closed
github-bot wants to merge 41 commits from github-bot/gh-3740 into main AGit
Owner

@⁠eleboucher on GitHub · 2026-11-30 05:47 UTC · original
eleboucher:dred-first → main · +38 −9 · 2 files · 41 commits · closed without merging

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.

**@⁠eleboucher** on GitHub · 2026-11-30 05:47 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3740) `eleboucher:dred-first` → `main` · +38 −9 · 2 files · 41 commits · closed without merging 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 05:51:37 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-30 06:13 UTC · original · approved these changes

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).

**@⁠Dukestar69** on GitHub · 2026-11-30 06:13 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3740#pullrequestreview-6107634490) · **approved these changes** 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).
Author
Owner

@⁠eleboucher on GitHub · 2026-11-30 06:22 UTC · original

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** on GitHub · 2026-11-30 06:22 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3740#issuecomment-7270589865) 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.
Author
Owner

@⁠eleboucher on GitHub · 2026-11-30 14:58 UTC · original

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.

**@⁠eleboucher** on GitHub · 2026-11-30 14:58 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3740#issuecomment-7282222816) 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.
Search for existing work first, make one change per branch from the latest main, keep the template, never make up results, and get approval before posting.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Covers reporting problems and sending pull requests: check for overlap first, test existing pull requests, and don't rely on the label bot's green tick.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`loose_metadata_reads_version_0x403` held 0x118 bytes the title handed
over, as a hex string. The asset policy refuses it
(`crates/victory-shader/src/native.rs: 560-character hex/base64 run`),
so `cargo xtask policy` and xtask's `repository_passes_policy` failed on
main since 698ab79e. The test now builds the same shape with `record()`:
the 0x18-byte header, a sampler, SRV and UAV table, a CBV, a skipped
declaration and the end record. It checks what the old one did, plus the
lower bounds, the root parameters, a container from loose_compute, and a
size that disagrees.

It still catches the 0x403 cases it is for: with the 0x403 arm removed,
or 0x403 read with v3's record offset (0x38), v2's header (0xc) or v2's
record offset (0x10), it fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
split_lds_wave32_read_after_read_barrier_coalescing_and_parity failed on
main at neg_uav_load_between_reads, mask=ALL: BWBRRBWBR where the test
expects BWBRBRBWBR.

The case puts buffer_load_dword v8 between the two LDS reads as a call
that must keep the barrier between them, but nothing reads v8. Since
dbdd6ada, optimise drops dead instructions inside its rounds: round one
keeps the barrier (the load resets the barrier state), DEAD then drops
the unread load, and round two finds the two reads with only the barrier
between them and drops it. That is correct: without the load the case is
adjacent_rar, which the test expects to become BWBRRBWBR. BARRIERS alone
runs no DEAD, which is why only the ALL assertion failed.

The negative now adds the loaded value into v6 before out[128 + t] is
stored. Thread t loads out[t], which starts at 0 and which only thread t
writes, after the load, so the expected outputs stay the same, and the
load stays live under every mask.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The `check` job has stopped at its first step on every pull request: with
`-D warnings` Clippy finds, on `main` (84bd61e2):

- `victory-shader`: `Lowered::loop_caps`, kept for tests, is read by none
  now (allowed, with a note).
- `victory-gpu`: `Shadow::ranged` has no caller left; its two parts are
  asked for by `ranged_parts` (removed, its sentence moved there). A test's
  `seed % 3 == 0` is `is_multiple_of`. With all features, the free
  function `mb` of `copystat.rs` is shadowed by a closure of the same name
  wherever it was called (removed).
- `victory-hle`: a `match` that is `unwrap_or_default` (the same value;
  its comment kept).

Nothing of this changes what runs. With it both Clippy steps pass, and
the job reaches its tests, of which two in `victory-gpu` were stale:

- `shader_cache`'s key test still named the four switches of the
  differential fuzzer, which a1fe8350 reverted out of the translator.
- `list::thin`'s `bindings_record_no_work` wants every call named as
  binding, waiting or work; `BEGIN_QUERY` and `END_QUERY` (471d05c4) were
  in none. They are work, as the waits take them today.

`cargo test -p victory-gpu`: 1,133 pass, none fail.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The title's metadata this test replaced had a sampler of root type 4,
and no other test in the crate reaches `RootType::ImmediateSampler` in
`records()`. The made-up 0x403 block now ends with one (slot 9, no user
data); the test checks that it is read (`used`, root type, slot) and adds
no root parameter (`layout` is unchanged).

With that arm removed, or given an SGPR, the test fails, as it does for
the four 0x403 header and offset mistakes it already caught.

Suggested by Lyrnc in the review of #4223.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The label was never removed, so it stayed on issues that now have logs.
Edits and comments by the issue's author are now checked with the same log
test. A manual run checks every open issue that has the label.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
needs-logs: take the label off when the author adds the logs
Add a short CONTRIBUTING.md
Clippy passes on main again, and two tests of victory-gpu the merges left behind (the check job)
Shader tests: the split-LDS read-after-read test's UAV-load negative reads its load (fails on main since #2623)
Shader tests: the 0x403 loose metadata is built in the test, not the title's bytes
Loader: resume late faults through recorded console instruction replacements (#2393)
A second thread reaching an insertq/extrq while the first replaces it can still end the run with 0xc000001d on Intel (#2393, #3775). #2585 makes that much rarer, not impossible; emulating each time never crashes this way.
AGENTS.md: rules for agents opening issues and pull requests
Claude Code reads CLAUDE.md, not AGENTS.md, so agents using it never saw the rules against duplicate issues and pull requests.
An exact duplicate goes on the existing issue or pull request as a comment, not a new one. Every issue and pull request needs its type and area labels, as title tags the bot turns into labels.
github-bot closed this pull request 2026-12-01 18:51:24 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:49 UTC · original

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.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:49 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3740#issuecomment-7321607767) 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!3740
No description provided.