GPU: a lost host list's heaps are not a wanted pair #3039

Open
github-bot wants to merge 1 commit from github-bot/gh-3039 into main AGit
Owner

@⁠kotekompotek on GitHub · 2026-11-26 04:54 UTC · original
kotekompotek:gpu/lost-heaps-marker → main · +29 −6 · 1 files · 1 commits · open

Summary

Fixes #2881. host_state_lost marked host_heaps [usize::MAX; 2], but a list that binds no heaps and reads title memory wants [MEMORY_HEAP, SAMPLERS_OURS] — the same pair. After a cut (Wait32/64BitValueX, 0–21 per world frame) or an external::record (FidelityFX), bind_heaps found them equal and bound nothing: the next directly-indexing root signature ran with no heaps bound — debug layer id 1419, the device removal on NVIDIA that #1778 was written to prevent (#1754).

host_heaps is now Option<[usize; 2]>: None marks the lost state and equals no pair wanted can make, so the next bind_heaps binds again. This removes the whole sentinel-collision class rather than picking a different one.

Test plan

  • cargo test -p victory-gpu --lib heaps — new a_lost_host_state_matches_no_wanted_heaps fails on the old [usize::MAX; 2] marker for wanted([0,0], true), passes under Option
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings clean (msvc)
  • In-game observation: none — found by code reading (as #2881 reports); a NVIDIA device removal after a cut is the signature this prevents

Generated with Devin

**@⁠kotekompotek** on GitHub · 2026-11-26 04:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/3039) `kotekompotek:gpu/lost-heaps-marker` → `main` · +29 −6 · 1 files · 1 commits · open ## Summary Fixes #2881. `host_state_lost` marked `host_heaps` `[usize::MAX; 2]`, but a list that binds no heaps and reads title memory wants `[MEMORY_HEAP, SAMPLERS_OURS]` — the same pair. After a cut (`Wait32/64BitValueX`, 0–21 per world frame) or an `external::record` (FidelityFX), `bind_heaps` found them equal and bound nothing: the next directly-indexing root signature ran with no heaps bound — debug layer id 1419, the device removal on NVIDIA that #1778 was written to prevent (#1754). `host_heaps` is now `Option<[usize; 2]>`: `None` marks the lost state and equals no pair `wanted` can make, so the next `bind_heaps` binds again. This removes the whole sentinel-collision class rather than picking a different one. #### Test plan - [x] `cargo test -p victory-gpu --lib heaps` — new `a_lost_host_state_matches_no_wanted_heaps` fails on the old `[usize::MAX; 2]` marker for `wanted([0,0], true)`, passes under `Option` - [x] `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` clean (msvc) - [ ] In-game observation: none — found by code reading (as #2881 reports); a NVIDIA device removal after a cut is the signature this prevents Generated with [Devin](https://devin.ai)
host_state_lost marked host_heaps [usize::MAX; 2], but a list that binds
no heaps and reads title memory wants [MEMORY_HEAP, SAMPLERS_OURS] —
the same pair. After a cut or an external record, bind_heaps found them
equal and bound nothing; the next directly-indexing root signature ran
with no heaps, the device removal #1778 was written to prevent.

None now marks the lost state: it equals no pair wanted can make, so
the next bind_heaps binds again.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:27:16 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 06:14 UTC · original

Automated triage for the maintainers.

I confirmed the bug on main. In crates/victory-gpu/src/draw.rs, MEMORY_HEAP (memory::OURS) and SAMPLERS_OURS are both usize::MAX. State::wanted([.., 0], true) therefore returns the same [usize::MAX; 2] that State::host_state_lost uses as its marker, so after a cut bind_heaps binds nothing. This PR makes host_heaps an Option<[usize; 2]> and uses None as the lost state. No wanted pair can equal None, so this kind of sentinel collision can no longer happen. host_heaps is touched only in host_state_lost and bind_heaps. The default None for a new State also forces the first bind, as the old [0, 0] did. The test covers every wanted combination. CI: check passing.

Note for the maintainers: #2882 fixes the same issue, #2881, by moving SAMPLERS_OURS to usize::MAX - 1, and it is also labelled as a merge candidate. Only one of the two should land. This one removes the sentinel instead of picking a different value, so I would prefer it, but that is your call.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 06:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/3039#issuecomment-7184236197) <!-- victory-triage v1 head=c141c1f4c571d5bf225fc180b9e17bfc73b912d1 verdict=merge-candidate at=2026-11-26T06:21:00Z --> Automated triage for the maintainers. I confirmed the bug on `main`. In `crates/victory-gpu/src/draw.rs`, `MEMORY_HEAP` (`memory::OURS`) and `SAMPLERS_OURS` are both `usize::MAX`. `State::wanted([.., 0], true)` therefore returns the same `[usize::MAX; 2]` that `State::host_state_lost` uses as its marker, so after a cut `bind_heaps` binds nothing. This PR makes `host_heaps` an `Option<[usize; 2]>` and uses `None` as the lost state. No `wanted` pair can equal `None`, so this kind of sentinel collision can no longer happen. `host_heaps` is touched only in `host_state_lost` and `bind_heaps`. The default `None` for a new `State` also forces the first bind, as the old `[0, 0]` did. The test covers every `wanted` combination. CI: `check` passing. Note for the maintainers: #2882 fixes the same issue, #2881, by moving `SAMPLERS_OURS` to `usize::MAX - 1`, and it is also labelled as a merge candidate. Only one of the two should land. This one removes the sentinel instead of picking a different value, so I would prefer it, but that is your call. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3039/head:github-bot/gh-3039'
git switch 'github-bot/gh-3039'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3039'
git switch 'github-bot/gh-3039'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3039'
git switch 'github-bot/gh-3039'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3039'
git switch 'main'
git merge --squash 'github-bot/gh-3039'
git switch 'main'
git merge --ff-only 'github-bot/gh-3039'
git switch 'main'
git merge 'github-bot/gh-3039'
git push origin 'main'
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/Marvisak--VIctory!3039
No description provided.