GPU: inline CBV/placed records, wait-free ShapeArena, and RwLock ViewMap #3831
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3831"
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 CaullenOmdahl on 2026-11-29T12:16:28Z.
Problem
Every
create_cbv,create_placed_srv, andcreate_placed_uavcall currently acquires a single globalMutex<Views>, searches aBTreeMap<View, u32>over 124-byteViewvalues, and appends a permanent entry toViews::list. Meanwhile, command-list recorders (view_at) and heap sync scans (views_current, ~700,000 slots/frame) contend on that same global mutex and stride across(View, u32)tuples just to check 4-byte generations.Changes
CONSTANTandPLACEDdescriptor records: Encode standard constant buffer views (< 47-bitVA,< 16 KiBbyte-exact or256-byte aligned< 4 MiB) and placed-memory views (< 1 TiBVA plus a 22-bit shape index) directly in the 62 payload bits below twoKIND_SHIFTbits ingeneration. Recycled table generations wrap within1..=GENERATIONS(2^30 - 1) so they never become0or enter the kind bits.ShapeArena: Intern distinct placed-view shapes in a segmented append-only slab arena (2048 x 2048capacity) published viaRelease/Acquireatomics soPLACEDlookups (view_at,views_current) never touch theViewslock.RwLock<Views>+ word-hashedViewMap+ densecurrentVec: ReplaceMutex<Views>andBTreeMapwith anRwLockover word-hashed maps, a read-lock fast path for already-registered views inwords_for, and a separatedcurrent: Vec<u32>generation slice.Ported from
CaullenOmdahl/Boxon(measured+2.3%steady-state frame-time improvement in world scenes on Ryzen 9 5900X + RX 6800).Validation
cargo xtask policycargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warningscargo clippy --workspace --all-targets --all-features --locked --target x86_64-pc-windows-msvc -- -D warningscrates/victory-gpu/src/descriptor.rscovering inline CBV/placed encoding, fallback table entries, 30-bit generation wrap-around,ShapeKeycollision chains,views_current, and concurrent wait-freeShapeArenareads across slab boundaries.Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-29T16:40:45Z.
Hardware check on a Radeon 780M (RDNA3, Ryzen 7 8845HS), merged onto main
63bcca4:cargo test --profile diag -p victory-gpu --features diagnostics --libpasses 250/250 twice, and 251/251 twice together with #3832 (the two merge clean). No frame-time claim from me: the syntheticworld_frame_preparingbench (#2134) doesn't exercise the descriptor paths this changes.AI-assisted (Claude).
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.