GPU: use non-zero NumElements for null raw pairs in HostHeap::raw_pair_at #2542
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!2542
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2542"
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?
@reeledMarek on GitHub · 2026-11-25 15:33 UTC · original
reeledMarek:fix/gpu-raw-pair-null-and-kept→main· +38 −2 · 1 files · 1 commits · openProblem
HostHeap::raw_pair_atcomputedelements = (bytes / 4).min(1 << 27), which producesNumElements = 0for null raw pairs (raw_pair_at(slot, None, 0), called bymemory::Shared::newandShared::rewrite) and sub-4-byte copies. D3D12 rejectsNumElements = 0on raw SRV/UAV descriptors.HostHeap::keptwas sized to(count + extra)slots, whilepair()allocates slots atcount + extra..pairs_end. Calls toself.keep(index, ...)inraw_pair_atalways missedkept.get_mut(index)and silently dropped the resource instead of retaining and retiring it across in-flight GPU work.Fix
HostHeap::kepttototal as usizeso pair slots retain and retire resources like regular and dynamic slots.raw_view_atinraw_pair_at: use(bytes / 4).clamp(1, 1 << 27)whenbuffer.is_some(), and1for null descriptors.Testing
raw_pair_null_is_valid_and_pair_slots_retire_resourcesincrates/victory-gpu/src/descriptor/host.rs.cargo test -p xtask --lockedpasses asset policy.fc1274156dto9a4721ab31@Marvisak on GitHub · 2026-11-25 18:34 UTC · original · edited 2026-11-26 07:22 UTC
Automated triage for the maintainers.
Merge candidate. Thanks for the rebase.
HostHeap::raw_pair_atincrates/victory-gpu/src/descriptor/host.rsnow takesNumElementsfromraw_pair_elements. That gives 1 for a null pair and clamps a real buffer to1..=2^27. It is the same ruleraw_view_atalready uses inmain, so the null pairs thatmemory.rswrites no longer carryNumElements = 0. TheHostHeap::keptsizing change is dropped, as asked. The device test is weak, because removal on an invalid descriptor shows up only with the debug layer, but it is harmless.CI:
checkpassing; merges cleanly.Generated by Claude Code
@reeledMarek on GitHub · 2026-11-25 20:05 UTC · original
Updated to address the triage feedback:
raw_pair_atnon-zeroNumElementsfix (raw_pair_elements, matchingraw_view_atso D3D12 does not rejectNumElements = 0on null raw SRV/UAV descriptors).HostHeap::keptsizing change to avoid the 32 MiB allocation andHostHeap::evictwalk overhead.raw_pair_elements_never_returns_zerothat runs unconditionally, alongside the device-backedraw_pair_null_descriptor_is_accepted_by_devicetest.@reeledMarek on GitHub · 2026-11-26 05:56 UTC · original
Rebased cleanly onto current
main(63bcca4, resolving the test-append conflict indescriptor/host.rs).@fuzeofficlal on GitHub · 2026-11-26 12:21 UTC · original · approved these changes
Reviewed and verified at head
9a4721abagainstorigin/main(63bcca43) on Windows 11 (RTX 5090 + WARP,VICTORY_D3D12_DEBUG=1):raw_pair_elements(crates/victory-gpu/src/descriptor/host.rs:627-633, 1827-1833) bringsHostHeap::raw_pair_atinto exact parity withHostHeap::raw_view_at(descriptor/host.rs:483-487), yieldingNumElements = 1for null raw SRV/UAV pairs and(bytes / 4).clamp(1, 1 << 27)for live buffers.pResource == NULL), reads return zero and writes are discarded regardless ofNumElements, while non-zeroNumElementssatisfies strict descriptor validation. Both the pure unit test (descriptor/host.rs:2478-2486) and device test (:2488-2501) are clean.#2542and#2543have no production-code overlap (only a trivial test-append conflict at the bottom ofcrates/victory-gpu/src/descriptor/host.rs).git merge-treeagainstorigin/main(63bcca43);cargo xtask policy(191 files ok);cargo clippy -p victory-gpu --all-targets -- -D warningsclean with default features and--all-features.raw_pair_elements_never_returns_zeroandraw_pair_null_descriptor_is_accepted_by_device2/2 passed.VICTORY_D3D12_DEBUG=1(--features diagnostics):descriptor::host::tests+memory::tests23/23 passed (skipping the two pre-existing NVIDIA 1M view-heap cap tests); WARP (VICTORY_D3D12_WARP=1) +VICTORY_D3D12_DEBUG=1: 25/25 passed.host.log_messages()after draining startup messages):raw_pair_at(slot, None, 0)produces zero debug-layer warnings or errors on both RTX 5090 and WARP.LGTM.
@Dukestar69 on GitHub · 2026-11-26 18:49 UTC · original · approved these changes
LGTM — verified on RTX 5090 (Windows / D3D12) against
origin/main(63bcca4).NumElementsto1..=2^27(and1for null descriptors) inraw_pair_atavoids D3D12 rejectingNumElements = 0on null raw SRV/UAV pairs, matchingraw_view_at.cargo test -p victory-gpu --lib descriptor::host::tests::raw_pair_ -- --test-threads=1: 2 passed, 0 failed (raw_pair_elements_never_returns_zeroandraw_pair_null_descriptor_is_accepted_by_device).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).
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.