Repository navigation
GPU: heaps are bound again after a cut when ours stand in for both kinds (#2881) - #2882
BastienRodz wants to merge 1 commit into
Conversation
Marvisak#1778 made the sampler heap we bind when the title binds none SAMPLERS_OURS = usize::MAX. Our view heap for title memory, MEMORY_HEAP (memory::OURS), is usize::MAX too, and host_state_lost marks the host list's heaps unknown with [usize::MAX; 2]. A draw or dispatch that wants both of ours (the title binds no heap, its shaders use title memory or root views) then wants exactly that marker, so bind_heaps found nothing to change: after a cut at a Wait32/64BitValueX the new host list starts with no heaps and none were set before the root signature, which indexes both directly (SetDescriptorHeaps must come first: the debug layer's 1419, INVALID_CALL on NVIDIA); after external::record the heaps of the other recorder stayed bound. Before Marvisak#1778 such a list wanted [usize::MAX, 0]. SAMPLERS_OURS is now usize::MAX - 1, which neither a title heap nor the marker takes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Windows run of this head (
|
|
Reviewed and verified
Looks clean and ready to merge. |
kotekompotek
left a comment
There was a problem hiding this comment.
Nice catch — SAMPLERS_OURS == usize::MAX collided with the lost-state sentinel [MAX, MAX], so a no-heap list after a cut compared wanted==host_heaps and never re-bound. MAX-1 keeps the stand-in address distinct. The test asserts the invariant across all heap combos. LGTM.
|
In-game evidence from @wilu222 on #2896, which stacks this PR's commit (RTX 5070, Windows 10,
The message names the sampler heap. That is the half this PR fixes: after a cut, a list with our view heap and our sampler heap wanted the lost-state marker and was never bound again. #2896 adds the view-heap half. |
|
Automated triage for the maintainers. Merge candidate. This fixes a real collision in CI: passing. Generated by Claude Code |
… stand in for both kinds (Marvisak#2881)
Dukestar69
left a comment
There was a problem hiding this comment.
Verified on RTX 5090 & WARP against origin/main (63bcca4):
cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 21/21 passed on RTX 5090 and WARP (includingheaps_are_bound_again_after_the_host_state_is_lost).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Clean fix ensuring stand-in heaps are rebound after a cut when ours stand in for both kinds (#2881).
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal
left a comment
There was a problem hiding this comment.
Looks good — minimal, exact fix for the sentinel collision between [MEMORY_HEAP, SAMPLERS_OURS] and State::host_state_lost()'s [usize::MAX; 2] in crates/victory-gpu/src/draw.rs.
Verified all references to SAMPLERS_OURS, MEMORY_HEAP, and host_heaps in draw.rs (no other code relies on SAMPLERS_OURS == usize::MAX), and checked git merge-tree against origin/main (63bcca43): clean.
Native Windows 11 hardware & WARP verification
cargo clippy --workspace --all-targets --locked -- -D warnings(default &--all-features): clean;cargo xtask policy: 191 files ok.- RTX 5090
cargo test -p victory-gpu --lib -- draw::tests:: --test-threads=1: 21/21 passed (heaps_are_bound_again_after_the_host_state_is_lost+a_list_without_a_sampler_heap_gets_oursincluded). - RTX 5090 +
VICTORY_D3D12_DEBUG=1(--features diagnostics): 21/21 passed. - WARP +
VICTORY_D3D12_DEBUG=1(--features diagnostics): 21/21 passed.
What's wrong
#1778 gave our fallback sampler heap the marker value
usize::MAX.MEMORY_HEAP(our view heap for title memory) already had that value, and so did the[usize::MAX; 2]thatState::host_state_lostleaves inhost_heapsso the next draw or dispatch binds its heaps again.The collision hits a list that binds no sampler heap and reads title memory or root views. It wants
[MEMORY_HEAP, SAMPLERS_OURS], which equals the lost-state marker, sobind_heapsbinds nothing after:Wait32BitValueX/Wait64BitValueX. The new host list starts with no heaps, and its next root signature indexes both heaps directly with none bound: the debug layer's 1419, a device removal on NVIDIA (NVIDIA RTX 4070 SUPER on 70564ae: device removed (INVALID_CALL, 0x887A0001) at frame 128, before the menus #1754).external::record. The other recorder's heaps stay bound.Before #1778 that list wanted
[usize::MAX, 0]and always bound its heaps again.DirectX-Specs, SM 6.6 Dynamic Resources: "SetDescriptorHeaps must be called, passing the corresponding heaps, before a call to SetGraphicsRootSignature or SetComputeRootSignature that uses either CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED or SAMPLER_HEAP_DIRECTLY_INDEXED flags."
What the fix does
SAMPLERS_OURSbecomesusize::MAX - 1, a value neither a title heap address nor the lost-state marker takes. A comment says why it can't beusize::MAX. Nothing else compares against it by value.Tests
New
draw::tests::heaps_are_bound_again_after_the_host_state_is_lost: afterhost_state_lost,wanted(..)differs fromhost_heapsfor every combination of title heaps and memory heap. It needs no device.[0, 0], memory heap true, left and right both[18446744073709551615, 18446744073709551615].a_list_without_a_sampler_heap_gets_ours.Run under Wine and vkd3d-proton. The
draw::,descriptor::andtwin::tests, one per process, give the same results with and without the fix except for the new test.cargo clippy --workspace --all-targets --locked -- -D warningsis clean.Not tested
On Windows hardware or in game. How often a world frame binds no sampler heap while reading title memory, right after a cut, is not measured.
Fixes #2881
No game data. Found and written with AI assistance (Claude Code), reviewed and run locally.
🤖 Generated with Claude Code