GPU/Bindless: O(1) texture forget reverse index, FxHash maps, and identical-rewrite fast-path #2940
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2940
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2940"
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?
@RVZO6 on GitHub · 2026-11-26 00:57 UTC · original
RVZO6:rvzo/bindless-fast→main· +234 −30 · 1 files · 1 commits · openSummary
Optimizes bindless heap slot/texture tracking in
crates/victory-gpu/src/bindless.rswithout changing observable semantics or lock-ordering safety:FxMap<usize, TextureSlots>): replacestextures: BTreeMap<usize, u32>sobindless::forget()(called from everyResource::drop) removes only the slot(s) viewing the dropped texture in O(slots viewing texture) instead of scanning all ~130,000 slots withinner.slots.retain(...)under theviewed.innermutex. Uses an inlineTextureSlots::One(u32)variant for the common 1-slot case (zero extra heap allocation per texture).FxMapforslots,ranges,textures,hulls,ends: replacesranges: BTreeMap(which is never iterated in sorted order;log()now counts distinct copies via sorted/dedupedends.keys()) with O(1) hashing instead of O(log N) tree traversals on every descriptor rewrite.Viewed::set: returns early without mutatingslots,ranges,ends,hulls, ortextureswhen overwriting a slot with the identicalSeentarget (or clearing an already-empty slot).uploads(): skips allocating/hashing the cross-heap dedupHashSetwhenheaps.len() == 1. (viewed.innerremains held acrossmade_copy/stagingto preserveResourceliveness against concurrentResource::drop -> bindless::forget().)Zero overlap with #2487/#2489 (which only update test fixtures in
rounds/heap_views_*), #2821, or #2848.Measured (
--release bench_bindless_forget_and_set, median of 3 runs, 130,000-slot heap on63bcca4)63bcca4)forget_hit(texture drops)Viewed::set(50% identical, 50% changing)forget_miss(non-bindless drops)Verification
bindless::tests::texture_reverse_index_tracks_multi_slot_and_forgetcovers single-slot, multi-slot, identical overwrite, rebind, andforget_resource.windows-latestMSVC + WARP SM 6.6 CI (clippy default +--tests+--features diagnostics,xtask policy, full workspace tests including existing bindless WARP tests): https://github.com/RVZO6/VIctory/actions/runs/45730729035Not run: the title; any hardware GPU.
AI-assisted: T3 Code (Antigravity, gemini-4-neon).
@fuzeofficlal on GitHub · 2026-11-26 01:08 UTC · original
Code review and RTX 5090 + WARP + release benchmark verification at head
5bed3341d008merged cleanly ontomain(63bcca43c6a0):crates/victory-gpu/src/bindless.rs):TextureSlots(One(u32)/Many(Vec<u32>)withswap_removeback toOne) givesforget_resourceO(slots viewing texture) cleanup instead of scanning ~130k slots.same_seenshort-circuits identical rewrites inInner::set_seenbefore mutating counts or pushing duplicate slots intoTextureSlots::Many, while replacements strictly remove/decrement old state before inserting/incrementing new state.HEAPS.lock()clone -> drop -> per-heapinnerlock) stays deadlock-free, anduploadsskipsHashSetallocation in the common single-heap case.VICTORY_D3D12_DEBUG=1, Rust 1.98.1):cargo xtask policy:191 files ok;cargo clippy(default +--features diagnostics): 0 warningsbindless:: draw::tests: 24/24 passed (1 ignored bench) on both RTX 5090 and WARP (includingtexture_reverse_index_tracks_multi_slot_and_forget)--releasebench_bindless_forget_and_set(130k slots):500 forget_hit = 0.180 ms,10k forget_miss = 62.6 us,100k set = 1.332 ms.Clean invariants and great speedup; LGTM.
@Marvisak on GitHub · 2026-11-26 04:27 UTC · original
Automated triage for the maintainers.
Merge candidate. A texture-to-slots reverse index (
TextureSlots) replaces the counter inbindless::Inner, soforget()on every resource drop no longer runsslots.retainover the whole heap under the lock; the maps move to an Fx hasher, and unchanged rewrites are skipped (set_seen/same_seen).rangesis never iterated in order,TextureSlots::removeempties correctly, andforget_resourcegives the same result as the oldretain; the unit test checks real invariants. Small fixes: theVieweddoc comment is stale, andvictory-gpucould share one Fx hasher rather than adding copies (see #2941, #2942).CI: passing.
Generated by Claude Code
@Dukestar69 on GitHub · 2026-11-26 04:48 UTC · original · approved these changes
Tested merged onto
origin/main(63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090):cargo test -p victory-gpu --lib bindless::tests: 4 passed, 0 failed, 1 ignored (including newtexture_reverse_index_tracks_multi_slot_and_forget).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).
@MeMako on GitHub · 2026-11-26 07:50 UTC · original
Verified
#2940(5bed334) on native Windows 11 (10.0.26200) + AMD Radeon RX 9070 XT (RDNA 4, driver32.0.32029.2010, Ryzen 9 7950X, 32 GB RAM).cargo clippy -p victory-gpu -p victory --all-targets --locked -- -D warnings: clean;cargo test -p victory-gpu --lib --locked -- --test-threads=1: 274/274 passed (includingtexture_reverse_index_tracks_multi_slot_and_forget).bench_bindless_forget_and_set(--release, 130k slots on Ryzen 9 7950X):500 forget_hit = 0.123 ms,10k forget_miss = 37.1 µs,100k set = 0.595 ms.#3052+#3061on local integration stack onmain63bcca4+#2051+#2472+#2918+#1010+#2130flags off +#3055+#2914+#2985+#2849+#3035+#2958): 0 crashes, 0 visual regressions, noticeably faster world asset streaming (+14% draws resident in the first 26 heavy frames).Hardware runs were performed by me on my 7950X / RX 9070 XT; comment drafted with Antigravity.
@fuzeofficlal on GitHub · 2026-11-26 13:51 UTC · original · approved these changes
Reviewed and verified head
5bed3341d008cc0871f6c20db8410cb8521cf9e7(clean merge withorigin/main63bcca43) on Windows 11 x64 (Ryzen 9 9950X, NVIDIA GeForce RTX 5090 + D3D12 WARP,VICTORY_D3D12_DEBUG=1, Rust 1.98.1).Code review (
crates/victory-gpu/src/bindless.rs)FxHasher/FxMap(L24-51) adds zero new dependencies and is appropriate for internal integer/pointer maps.TextureSlots(L54-84) +Inner::set_seen(L211-227) +Inner::forget_resource(L229-242) preserve the exact bidirectional invariant betweenslotsandtextures(slotintextures[r]iffslots[slot] == Seen::Texture(r)): overwrites strictly remove/decrement the old entry before inserting the new one,TextureSlots::removecollapsesManyback toOneand deletes empty texture entries, andforget_resourceremoves the exact slot set thatslots.retainpreviously scanned.same_seen(L99-108) checks every field of everySeenvariant (Arc::ptr_eq,address,len,uavfor buffers; resource pointer for textures; full(kind, address, bytes)tuple forLeft). BecauseHostHeap::mirrorwrites the updated D3D12 descriptor before callingViewed::set, rewriting a slot with a different view descriptor (e.g., different swizzle/mip) of the same texture still updates the host descriptor while safely short-circuiting redundantViewedchurn and preventing duplicate slot insertion.uploads()fast path (L344-354) is sound becauseinner.textureskeys are unique per heap, andlog()(L510-513) derives the identical distinct-copy count from sorted/dedupedinner.endskeys.Viewed(L114-115) still mentions slot counts rather than the reverse slot index; if #3213 lands alongside this, itsis_live_texture(r)guard underViewed::innerwill need to sit insideInner::set_seen.Verification
cargo xtask policy:191 files ok;cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default &--all-features): 0 warningsbindless:: draw::tests: 24 passed, 0 failed, 1 ignored on RTX 5090 (default), RTX 5090 (--features diagnostics,VICTORY_D3D12_DEBUG=1), and WARP (VICTORY_D3D12_WARP=1,--features diagnostics,VICTORY_D3D12_DEBUG=1)--releasebench_bindless_forget_and_set(Ryzen 9 9950X, 130k slots, 3 runs, median):500 forget_hit = 0.205 ms(0.068–0.219 ms),10k forget_miss = 45.0 us(40.3–46.1 us),100k set = 0.524 ms(0.517–0.598 ms)set_seen/forget_resourcesteps checking full map equivalence after every step, including buffer SRV↔UAV flips,Leftaddress changes, and A→B rebinds followed byforget(A)) plus live heap SRV swizzle-overwrite/rebind/multi-heapuploadsprobe passed on both RTX 5090 and WARP with 0 D3D12 Debug Layer messages.Solid optimization with clean invariants; approving.
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.