GPU: heaps are bound again after a cut when ours stand in for both kinds (#2881) #2882
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2882
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2882"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@BastienRodz on GitHub · 2026-11-25 23:01 UTC · original
BastienRodz:gpu/samplers-ours-not-lost-marker→main· +18 −2 · 1 files · 1 commits · openWhat'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 (#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
@BastienRodz on GitHub · 2026-11-25 23:04 UTC · original
Windows run of this head (
00d163a, onmain842b0cb) onwindows-latest, WARP,cargo test --workspace --locked --no-fail-fast -- --test-threads=1: https://github.com/BastienRodz/VIctory/actions/runs/45718036015victory-gpulib: 232 passed, 0 failed, 1 ignored, includingdraw::tests::heaps_are_bound_again_after_the_host_state_is_lostanddraw::tests::a_list_without_a_sampler_heap_gets_ours.@fuzeofficlal on GitHub · 2026-11-25 23:10 UTC · original
Reviewed and verified
00d163a9on Windows 11 (RTX 5090 + WARP) againstmain(842b0cb):SAMPLERS_OURSfromusize::MAXtousize::MAX - 1cleanly removes the sentinel collision withState::host_state_lost()'s[usize::MAX; 2]when both heaps stand in as[MEMORY_HEAP, SAMPLERS_OURS], and no other code indraw.rsconflicts withusize::MAX - 1.draw::tests21/21 (includingheaps_are_bound_again_after_the_host_state_is_lost) andlist::tests4/4 passed,cargo clippy --locked -p victory-gpu --all-targets(default &--features diagnostics) 0 warnings,cargo xtask policy(191 files ok).Looks clean and ready to merge.
@BastienRodz on GitHub · 2026-11-26 00:18 UTC · original
In-game evidence from @wilu222 on #2896, which stacks this PR's commit (RTX 5070, Windows 10,
VICTORY_D3D12_DEBUG=1): #2896main842b0cb: the debug layer logsSetComputeRootSignature: SetDescriptorHeaps must be called to bind a sampler descriptor before setting a root signature with D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED flag. id=1419about 4 s after start, in a menu run and in a world run.main+ #2882 + #2896: no 1419 in a 60 s menu run.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.
@Marvisak on GitHub · 2026-11-26 04:27 UTC · original
Automated triage for the maintainers.
Merge candidate. This fixes a real collision in
draw.rs:SAMPLERS_OURSandMEMORY_HEAPwere bothusize::MAX, soState::wantedcould return[usize::MAX; 2], the valuehost_state_lostuses for "unknown", andbind_heapsthen skippedSetDescriptorHeapsafter a cut.usize::MAX - 1cannot be a title heap address, and the test checks every combination of title and memory heaps against the lost state.CI: passing.
Generated by Claude Code
@kotekompotek on GitHub · 2026-11-25 23:34 UTC · original · reviewed
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.
@Dukestar69 on GitHub · 2026-11-26 09:49 UTC · original · approved these changes
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 on GitHub · 2026-11-26 10:22 UTC · original · approved these changes
Looks good — minimal, exact fix for the sentinel collision between
[MEMORY_HEAP, SAMPLERS_OURS]andState::host_state_lost()'s[usize::MAX; 2]incrates/victory-gpu/src/draw.rs.Verified all references to
SAMPLERS_OURS,MEMORY_HEAP, andhost_heapsindraw.rs(no other code relies onSAMPLERS_OURS == usize::MAX), and checkedgit merge-treeagainstorigin/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.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).VICTORY_D3D12_DEBUG=1(--features diagnostics): 21/21 passed.VICTORY_D3D12_DEBUG=1(--features diagnostics): 21/21 passed.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.