GPU: use non-zero NumElements for null raw pairs in HostHeap::raw_pair_at #2540
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-25T15:33:45Z.
Problem
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.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T18:34:27Z.
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
Imported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-25T20:05:26Z.
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.[PR #2542] GPU: use non-zero NumElements for null raw pairs and track pair-slot resources in HostHeapto [PR #2542] GPU: use non-zero NumElements for null raw pairs in HostHeap::raw_pair_atImported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-26T05:56:02Z.
Rebased cleanly onto current
main(63bcca4, resolving the test-append conflict indescriptor/host.rs).Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T12:21:23Z.
Review: APPROVED
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.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T18:49:35Z.
Review: APPROVED
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.