GPU: serve unaligned root-CBV fill_scratch fills on the card in card_steps #875
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/875"
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 trustno1-coder/VIctory-NVIDIA. Originally posted by Starchaser1024 on 2026-11-28T08:24:16Z.
Summary
Resolves the unaligned root-CBV
fill_scratchrefusal incard_stepsthat forces full in-flight GPU + copy-back settles duringpreparing(docs/findings.md:125-135, where a0x20-byte upload fill inside the 174 MB world heap stalls behind in-flight UAV dispatches).Cause
gpu % 256 == 0). Roughly 15 of 16 16-byte-aligned root CBVs in the 174 MB heap take the fallback indraw::root_view(list.fill_scratch(address, len)).HostList::fill_scratchsub-allocated fromD3D12_HEAP_TYPE_UPLOAD(GENERIC_READ, which D3D12 forbids as aCopyBufferRegiondestination) and recordedStep::Fill(to, src, len, None)(Does::Fill { to: false }).FillTo::Slot) and texture upload buffers (FillTo::Buffer) already run on the card behind in-flight shader writes, any singlefill_scratchroot CBV overlapping an in-flight UAV range (or reading a takenStep::Copyin the same submission) hitErr("a fill of memory the card cannot be given the bytes of")(card_steps.rs:367), refusingcard_stepsfor the entire submission and blocking inrelay_wait(WHY_READ)/settle.Changes
card_steps::FillTo::Buffer&To::Buffer(crates/victory-gpu/src/host/card_steps.rs): add au64byte offset socard_steps::recordcopies unaligned root CBVs into 256-byte-aligned slices inside a shared chunk (deduplicatingCOPY_DEST -> COMMONbarriers per chunk across single- and multi-level plans).HostList::shared_scratch&SPARE_SHARED(crates/victory-gpu/src/host.rs): parameterizeScratchwithshared: bool(256 KiBfirst chunk,4 MiBsubsequent chunks viaHost::shared_buffer,CUSTOM+WRITE_BACK+L0, recycled inSPARE_SHAREDand trimmed inallocator_trimandtrim_spare_chunks).VICTORY_SCRATCH_SHARED(default1, A/B toggleable): whencard_steps::stage() > 0 && scratch_shared(),HostList::fill_scratchsub-allocates 256-byte-aligned (4x64-byte cache line) slots fromshared_scratchand passesSome(FillTo::Buffer(buffer, at)), falling back to uploadscratchotherwise.Benchmark & Verification (RTX 5060 Ti 16 GB, Windows 11)
host::card_steps::tests::shared_scratch_eliminates_flight_settle_end_to_end(VICTORY_RELAY=2 VICTORY_CARD_STEPS=2, 8 rounds of in-flight GPU copies + shader writes into aShadowUAV buffer followed immediately by a compute submission binding two unaligned UAV-overlapping root CBVs and one CPU-filled root CBV in the same chunk):submitsubmit(8 rounds)card_fillsrefusedWHY_READread_waitVICTORY_SCRATCH_SHARED=0(uploadscratch)7.79 ms)61,850 us0860,762 usVICTORY_SCRATCH_SHARED=1(sharedscratch)0.21 ms)3,504 us1600 ushost::card_steps::tests::shared_scratch_root_constants_plan_and_record_on_gpu: verifies 256B alignment,(src, len)deduplication, mixed CPU-filled + multi-level GPU-filled slots in one chunk with0xa5padding guard checks, liveSetComputeRootConstantBufferViewreadback on GPU,SPARE_SHAREDreuse acrossreset(), and oversized> 4 MiBfallback.cargo test -p victory-gpu --locked: 455 passed, 0 failed.cargo clippy --workspace --all-targets --all-features --locked: 0 warnings in changed files.cargo xtask policy: 294 files ok.Pull request closed