GPU: display mode changes and devices added or removed go to the log and to the removal report's trail #1002

Open
PiloteCode wants to merge 2 commits from upstream-pr/1004 into main
PiloteCode commented 2026-11-25 15:40:13 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by PiloteCode on 2026-11-25T15:40:13Z.


Based on 4c604661 (main). Two commits, two small changes to the window procedure in host.rs: about 20 lines.

Rebuilt on today's main: the two clippy fixes it started with are gone (main is clippy-clean now), and the two commits are re-applied unchanged.

Why

On our test machine, Windows reset the card several times in one day ("Resetting TDR" from the display driver), and each reset ended the run under way with its host device lost. The system's own logs showed what came before: each time, 2.5 to 4.6 s earlier, a remote-desktop host had ended its session and removed its virtual input device. Nothing in our log showed it, so the losses first looked like ours.

What changes

Our window now notes two messages the system sends every top-level window:

  • WM_DISPLAYCHANGE, with the new size and bits per pixel ("the display's mode changed");
  • WM_DEVICECHANGE with DBT_DEVNODES_CHANGED ("a device was added to or removed from the system").

Each goes to the log and to the trail (host::trail). The report of a lost device prints the trail with how long before the loss each entry came, so the report says whether a display or device change preceded the loss.

In every build, with no switch: two log lines per change, which is rare. The window procedure otherwise does as before (DefWindowProcW).

Tested

The branch was checked as it is, on 4c604661, on the software adapter:

  • cargo test -p victory-gpu --features diagnostics -- --test-threads=1 --skip stacks_that_mean_nothing_are_walked_without_a_fault with VICTORY_D3D12_WARP=1: 247 passed, 7 ignored, none failed, as on main. The skipped test ends the test process with an access violation on this machine, on main too.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with --all-features: clean.
  • cargo build --release -p victory and cargo build --profile diag -p victory --features diagnostics pass.
  • cargo xtask policy fails on main itself: host.rs (534,239 bytes) and emit/lower.rs (546,915) are over the 524,288-byte limit. This branch adds 991 bytes to host.rs and names no other file.

In our tree, these lines have been in every run since they went in. No unit test: the messages come from the system.

Not tested

  • A device loss with this branch (the losses it was written for came from the remote-desktop host).
  • Linux/Proton, where the window messages may differ.

Where this also lives

These changes are also in PiloteBox (https://github.com/PiloteCode/PiloteBox), a tree kept up to date for NVIDIA cards. Its 0.13.1 runs the Series X profile at about 21 frames a second on an RTX 5090 (46.6 and 48.8 ms a frame in one scene; its changelog says how that was measured).

<!-- greyfinch-sync:fxceless/victory-fork:issue:5494483670 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1004). Originally posted by [PiloteCode](https://github.com/PiloteCode) on 2026-11-25T15:40:13Z. --- Based on `4c604661` (main). Two commits, two small changes to the window procedure in `host.rs`: about 20 lines. Rebuilt on today's `main`: the two clippy fixes it started with are gone (`main` is clippy-clean now), and the two commits are re-applied unchanged. ## Why On our test machine, Windows reset the card several times in one day ("Resetting TDR" from the display driver), and each reset ended the run under way with its host device lost. The system's own logs showed what came before: each time, 2.5 to 4.6 s earlier, a remote-desktop host had ended its session and removed its virtual input device. Nothing in our log showed it, so the losses first looked like ours. ## What changes Our window now notes two messages the system sends every top-level window: - `WM_DISPLAYCHANGE`, with the new size and bits per pixel ("the display's mode changed"); - `WM_DEVICECHANGE` with `DBT_DEVNODES_CHANGED` ("a device was added to or removed from the system"). Each goes to the log and to the trail (`host::trail`). The report of a lost device prints the trail with how long before the loss each entry came, so the report says whether a display or device change preceded the loss. In every build, with no switch: two log lines per change, which is rare. The window procedure otherwise does as before (`DefWindowProcW`). ## Tested The branch was checked as it is, on `4c604661`, on the software adapter: - `cargo test -p victory-gpu --features diagnostics -- --test-threads=1 --skip stacks_that_mean_nothing_are_walked_without_a_fault` with `VICTORY_D3D12_WARP=1`: 247 passed, 7 ignored, none failed, as on `main`. The skipped test ends the test process with an access violation on this machine, on `main` too. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and the same with `--all-features`: clean. - `cargo build --release -p victory` and `cargo build --profile diag -p victory --features diagnostics` pass. - `cargo xtask policy` fails on `main` itself: `host.rs` (534,239 bytes) and `emit/lower.rs` (546,915) are over the 524,288-byte limit. This branch adds 991 bytes to `host.rs` and names no other file. In our tree, these lines have been in every run since they went in. No unit test: the messages come from the system. ## Not tested - A device loss with this branch (the losses it was written for came from the remote-desktop host). - Linux/Proton, where the window messages may differ. ## Where this also lives These changes are also in PiloteBox (https://github.com/PiloteCode/PiloteBox), a tree kept up to date for NVIDIA cards. Its 0.13.1 runs the Series X profile at about 21 frames a second on an RTX 5090 (46.6 and 48.8 ms a frame in one scene; its changelog says how that was measured).
PiloteCode commented 2026-11-25 23:09:54 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by PiloteCode on 2026-11-25T22:11:42Z.


Merged main (c36971b) into the branch: a merge commit on top of the commits already here (d1d247d), then one lint commit. No conflict: this branch's change is in window_proc, which main's commits since 0b0074e do not touch.

Added after the merge: one lint commit for main's newer code, the same as on our other open branches: map_entry in fpsbox.rs, collapsible_if in pipeline/library.rs, manual_is_multiple_of in queue.rs, shadow.rs, draw.rs and watch.rs. Without it cargo clippy --workspace --all-targets --locked -- -D warnings fails on c36971b, with or without --all-features.

Checked, the branch as it is (66fa13b), every test on the software adapter:

  • cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with --all-features: clean.
  • cargo xtask policy, cargo build --release -p victory and cargo build --profile diag -p victory --features diagnostics: pass.
  • cargo test -p victory-gpu --features diagnostics -- --test-threads=1 with VICTORY_D3D12_WARP=1: 200 passed, 1 failed, 6 ignored, as on main. The failure is depth_bounds_pipeline_loads_and_filters_draws: WARP does not reject the pixels outside the depth bounds.
  • cargo test -p victory-shader -- --test-threads=1 with VICTORY_WARP=1: 212 passed, 4 failed, 3 ignored, the same four as on main on the software adapter.
  • cargo test -p victory-hle -- --test-threads=1: 100 + 1 passed, as on main.
  • cargo test -p victory -p victory-loader: passed.
<!-- greyfinch-sync:fxceless/victory-fork:comment:7176056144 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1004#issuecomment-7176056144). Originally posted by [PiloteCode](https://github.com/PiloteCode) on 2026-11-25T22:11:42Z. --- Merged `main` (`c36971b`) into the branch: a merge commit on top of the commits already here (`d1d247d`), then one lint commit. No conflict: this branch's change is in `window_proc`, which `main`'s commits since `0b0074e` do not touch. **Added after the merge:** one lint commit for `main`'s newer code, the same as on our other open branches: `map_entry` in `fpsbox.rs`, `collapsible_if` in `pipeline/library.rs`, `manual_is_multiple_of` in `queue.rs`, `shadow.rs`, `draw.rs` and `watch.rs`. Without it `cargo clippy --workspace --all-targets --locked -- -D warnings` fails on `c36971b`, with or without `--all-features`. **Checked**, the branch as it is (`66fa13b`), every test on the software adapter: - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and the same with `--all-features`: clean. - `cargo xtask policy`, `cargo build --release -p victory` and `cargo build --profile diag -p victory --features diagnostics`: pass. - `cargo test -p victory-gpu --features diagnostics -- --test-threads=1` with `VICTORY_D3D12_WARP=1`: 200 passed, 1 failed, 6 ignored, as on `main`. The failure is `depth_bounds_pipeline_loads_and_filters_draws`: WARP does not reject the pixels outside the depth bounds. - `cargo test -p victory-shader -- --test-threads=1` with `VICTORY_WARP=1`: 212 passed, 4 failed, 3 ignored, the same four as on `main` on the software adapter. - `cargo test -p victory-hle -- --test-threads=1`: 100 + 1 passed, as on `main`. - `cargo test -p victory -p victory-loader`: passed.
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/1004:upstream-pr/1004'
git switch 'upstream-pr/1004'

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/1004'
git switch 'upstream-pr/1004'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1004'
git switch 'upstream-pr/1004'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1004'
git switch 'main'
git merge --squash 'upstream-pr/1004'
git switch 'main'
git merge --ff-only 'upstream-pr/1004'
git switch 'main'
git merge 'upstream-pr/1004'
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
fxceless/victory-fork!1002
No description provided.