GPU: reuse descriptor table scratch buffers and stack roots in bind #1443
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1443"
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 fxceless/victory-fork. Originally posted by DoktorTK on 2026-11-27T07:39:32Z.
Summary
State::bind(crates/victory-gpu/src/draw.rs) runs on every draw and dispatch call and previously allocated multiple freshVecs per stage/draw:State::tablesallocated newmade,entries, andselectedVecs on every stage invocation.State::memory_readyallocated newaddressesandconstantsVecs whenever a shader boundSLOT_MEMORY.This change:
State::tables_intosoState::bindreusesmade,entries, andselectedscratchVecs across shader stages (while keepingState::tablesintact for callers/tests).[u64; 64]and[u32; 64]buffers (bounded to D3D12's 64 root parameter / 64 DWORD limit, with an overflowVecfallback) inState::memory_ready.Verification
cargo clippy -p victory-gpu --lib -- -D warningscargo test -p victory-gpu --lib -- draw::Imported from fxceless/victory-fork. Originally posted by Filip722 on 2026-11-27T09:08:25Z.
At
7a61bf0e, theState::bindstage loop still callsself.tables(...). The new wrapper constructsmade,entriesandselectedeach time before callingtables_into, so the per-stage allocations in that loop are still present. The stack storage inmemory_readyis wired in.Could the stage loop pass the same three scratch vectors directly to
tables_into? That would make the production call site exercise the reuse described here. This is from reading the exact diff.Assisted by Codex (GPT-6.2-Sol High).
Imported from fxceless/victory-fork. Originally posted by DoktorTK on 2026-11-27T12:51:17Z.
Good catch, thank you! When splitting this out onto
mainseparately fromstage_spans, theState::bindcall site was missed and still calledself.tables(...). Updated the PR branch (ff63c74) soState::bindallocatesmade,entries, andselectedonce before the stage loop and passes them directly toself.tables_into(...).Imported from fxceless/victory-fork. Originally posted by KainanP on 2026-11-27T15:13:49Z.
Independent A/B of this PR on the RTX 4060 Laptop, against
main9a9091d(its base). This head does change the production caller:bindnow callstables_intowith its reused buffers.Bench:
pipeline::list_bench::table_bench(KainanP/victory-forkbench/desc-tables,#[ignore]) ports the draw sequence of our VIctory list bench to the fork. Each draw binds a material table (one constant buffer view and five textures the title placed in memory), and each table sits at its own place in the title's heap. A list has 2,000 tables, and half of them repeat the contents of an earlier one, as in #1379. A list is closed (timed) and reset every 2,000 draws. Cells are ns per draw for the whole sequence (table, root CBV, 4 constants, index buffer, draw), each the median of 7 interleaved processes, each process the best of 5. RTX 4060 Laptop, i7-14650HX. A headless Chrome from other work used about 2 cores. This bench times recording only: lists are not submitted, so fills done at submission do not show here.main9a9091dff63c74An earlier run of 7 agrees:
main11,990 / 22,095, PR 11,524 / 22,240.So it is neutral within noise. The allocations it saves are small next to the roughly 17 µs it takes to make a 6-slot table afresh here (diagnostics build).
Correctness. Our
tables_show_their_viewspasses: every texture slot of the tables made for 64 draws, over three lists, holds the descriptor the host makes of its view, and its host texture.For the texture-view part: #1484.
AI use: Claude Code (Claude Opus 5.5).
Imported from fxceless/victory-fork. Originally posted by DoktorTK on 2026-11-27T15:21:20Z.
Thank you for the thorough A/B benchmark and correctness check on
ff63c74, and awesome to see#1484caching the texture views directly! Closing this PR now sincemainhas rebased ontoVIctory-NVIDIA(foxhound) and#1484tackles the dominant cost.Pull request closed