Skip to content

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

Open
kotekompotek wants to merge 1 commit into
Marvisak:mainfrom
kotekompotek:gpu/lost-heaps-marker
Open

kotekompotek wants to merge 1 commit into
Marvisak:mainfrom
kotekompotek:gpu/lost-heaps-marker

Conversation

@kotekompotek

Copy link
Copy Markdown

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

Generated with Devin

@fuzeofficlal fuzeofficlal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review of 851b5290 against crates/victory-gpu/src/draw.rs and crates/victory-gpu/src/memory.rs.

Confirmed the root cause on main: crate::memory::OURS is usize::MAX, SAMPLERS_OURS is usize::MAX, so State::wanted([0, 0], true) returns [usize::MAX, usize::MAX], which collided with the [usize::MAX; 2] sentinel written by State::host_state_lost(). After cut() or external::record, bind_heaps treated the lost state as already matching want and skipped SetDescriptorHeaps.

Switching host_heaps to Option<[usize; 2]> is cleaner than introducing another magic sentinel:

  • State::default() initializes host_heaps to None, matching the prior behavior ([0, 0] never matched wanted's non-zero sampler slot either).
  • All four host_heaps sites in draw.rs are updated consistently, host_roots is still cleared whenever SetDescriptorHeaps runs, and the unit test covers all combinations of (views, samplers, memory_heap) after host_state_lost().

Note for maintainers: this addresses the same issue (#2881) as #2882; the Option<[usize; 2]> approach here eliminates sentinel collisions by type.

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 Marvisak#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>

Copy link
Copy Markdown
Owner

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

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):

  • Diff review: Changing State::host_heaps to Option<[usize; 2]> with None in host_state_lost() cleanly eliminates the sentinel collision with [MEMORY_HEAP, SAMPLERS_OURS] ([usize::MAX; 2], #2881) so heaps are always rebound after a lost host state.
  • cargo test -p victory-gpu draw::tests -- --test-threads=1 (RTX 5090 & WARP): 21 passed, 0 failed on both (including a_lost_host_state_matches_no_wanted_heaps).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GPU: after a cut, a list using our view heap and our sampler heap never binds them again (SAMPLERS_OURS equals the lost-state marker)

4 participants