gpu/draw: batch ListViews descriptor copies and remove per-draw allocations #272
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/TaynanGT--Vice-Tay!272
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-272"
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?
@mint17 on GitHub · 2026-11-27 13:16 UTC · original
mint17:perf/draw-zero-alloc-batched-listviews→main· +1310 −187 · 2 files · 2 commits · openEliminates per-draw heap allocations, SipHash overhead, COM refcount churn, and per-descriptor
CopyDescriptorsSimplecalls on the hot submission path incrates/victory-gpu/src/draw.rsandcrates/victory-gpu/src/descriptor/host.rs(zero merge conflict with #234, #245, or #257).Changes
ListViewsCopyDescriptors(ListCopyBatch+HostHeap::make_listed_into): Collapses up to 64 primary + twin descriptor copies inState::tablesinto a singleCopyDescriptorscall (keepingCopyDescriptorsSimple(1, ...)for single copies), uses a singleviews.made.get(&words)lookup on hit, flushes onDropand before recording resets, and buffers displaced COM resources inline ([Option; 64]) soretire_resourcestrictly runs afterCopyDescriptorsoverwrites the shader-visible descriptor slots.HostHeap::keep_ref: Compares raw COM pointers underself.kept[index]before cloning/retiring onmake_listed_into,raw_at,raw_uav_at,constant_at, andconstant_raw_at.host_signatureTLS cache: Stores leaked&'static ID3D12CommandSignaturereferences instatic MADEand caches plain 'static references inthread_local!viatry_with()— eliminating COMAddRef/ReleaseperExecuteIndirectwhile running zero COM calls in TLS destructors at teardown.Few<T, N>& 24-byteReadyReader): ExtendsFewwithclear(), inline/spill-preservingdedup(), andPartialEq/Eq/Debug; replaces heapVecs inState::host_targets,set_targetsscratch buffers,State::tablesselectedindices, andFreshTable::ready(packed into a 24-byteCopyReadyReader).AddressHash& zero-atomic root-slot hits: Switchesroot_srv_slots/root_uav_slotstoAddressHashand borrowsOption<&Arc<Shadow>>on hits inroot_uavandroot_srv_table.Release Microbenchmark (
cargo test --release --locked -p victory-gpu --lib draw_batch_and_alloc_bench -- --ignored --nocapture)ListCopyBatch/ Zero-Alloc)ListViewscopy (20,000 tables)Vec+ SipHash +Arc::clonevsFew+ReadyReader+AddressHash)Verification
cargo test --locked -p victory-gpu --lib -- zero_alloc_tests descriptor::host::tests draw::record_hash_tests -- --test-threads=1(56 passed, 0 failed — includes 70-slotListCopyBatchboundary +len == 63pair-flush + deferred-retirement tests,keep_refidentity/retirement test, 4-threadhost_signaturetest, andFew/ReadyReadertests).cargo test --locked -p victory-gpu --lib --features diagnostics -- zero_alloc_tests -- --test-threads=1(6 passed, 0 failed).cargo clippy -p victory-gpu --all-targets --locked -- -D warnings(default +--all-features) andcargo test --locked -p xtask(11 passed, 0 failed).@TaynanGT on GitHub · 2026-11-27 13:23 UTC · original
@mint17 The 48-descriptor comparison isolates the batching gain. The boundary I’ll check is that displaced COM resources stay alive until the destination slots are overwritten and any in-flight use completes. Keep the per-draw allocation result scoped to the microbenchmark.
@Garu667 on GitHub · 2026-11-27 14:47 UTC · original
Tested on an RTX 3080 10 GB (Series S,
-Machine auto, boat mission autosave, warm shader cache). Same executable source except for this PR:maine45051amain+ #272With this PR the game stalls for seconds at a time: frames of up to 36 s (
0.0 fps, 35992.8 ms/frame (22054.4 preparing: copies 7537.6 ms ...)). There's no crash and no card loss, and no pipelines are being made (warm cache). A combined build with #284 and #294 (run 160) stalled the same way. #272 alone reproduces it, so it looks like this one. Happy to rerun with a switch if there is one to turn the batching off.@TaynanGT on GitHub · 2026-11-27 15:01 UTC · original
@Garu667 The switch is in
d3ff310.-More @{VICTORY_BATCH_LIST_VIEWS='0'}flushes each view with individual descriptor copies. Compare it with1on the same executable, boat save and warm shader cache. Median frame time, the longest stall and the preparing/copies breakdown are enough to tell whether the batching is responsible.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.