Repository navigation
Conversation
…ntical-rewrite fast-path Optimize bindless heap tracking in crates/victory-gpu/src/bindless.rs: - Replace BTreeMap<usize, u32> textures with FxMap<usize, TextureSlots> reverse index (inline single slot for the common 1-slot case) so bindless::forget() removes only the slots viewing that texture in O(slots viewing texture) instead of scanning all ~130,000 slots with slots.retain() under viewed.inner. - Switch Inner::ranges from BTreeMap to FxMap (O(1) vs O(log N) per slot rewrite) and use FxMap on slots/textures/hulls/ends. - Short-circuit Viewed::set when overwriting a slot with the identical Seen target (or None -> None) to avoid redundant map and hull mutations. - Skip the cross-heap dedup HashSet in uploads() when there is only one heap. - Keep viewed.inner held across made_copy/staging in uploads() to preserve liveness against concurrent Resource::drop -> bindless::forget(). Measured (--release bench_bindless_forget_and_set, median of 3 runs, 130,000 slots): - 500 forget_hit: 263.939 ms -> 0.092 ms (2,869x, -99.97%) - 100k set: 26.155 ms -> 1.235 ms (21.2x, -95.3%) - 10k forget_miss: 155.1 us -> 89.0 us (1.74x, -42.6%) Assisted-by: T3 Code (Antigravity, gemini-4-neon)
|
Code review and RTX 5090 + WARP + release benchmark verification at head
Clean invariants and great speedup; LGTM. |
|
Automated triage for the maintainers. Merge candidate. A texture-to-slots reverse index ( CI: passing. Generated by Claude Code |
Dukestar69
left a comment
There was a problem hiding this comment.
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).
… sparse shadow/delta & spare buffer reuse Eliminate redundant bindless table generations, descriptor writes, and linear scans in runtime/src/vulkan_bindless.h: - Short-circuit identical descriptor rewrites in BindlessSet::queue() and cancel pre-flush no-op round-trips in O(1), avoiding phantom vkUpdateDescriptorSets calls and delta_log_/write_seq_ churn (inspired by Marvisak/VIctory#2940, GPL-3.0, RVZO6). - Add compact open-addressed FlatHandleIndex reverse map (VkImageView/VkSampler -> packed (binding, index) slots with inline single-slot fast path and backward-shift deletion) powering O(slots_referencing_handle) clear_image()/forget_image_view() and clear_sampler()/forget_sampler(). - Track sparse written_slots_ per binding so write_shadow() avoids scanning 153k+ slots on partially_bound sets (and emits a single O(1) write when fully populated), coalesce contiguous runs in write_delta() with reused scratch buffers, and add O(1) lowest-free allocation hints and free counters. - Opportunistically recycle completed retired generations before allocating new pools/buffers, perform idle in-place table rewrites when completed >= retire_ticket, retain up to 3 freshest spare sets + same-size DEVICE_LOCAL TableBuffers when pool budget allows (>=13 sets) to skip redundant vkCreateBuffer/vkAllocateMemory/vkCreateDescriptorPool/write_table_binding overhead. - Expand bindless_sizing_test and d3d12_bindless_churn_test with CPU fast-path and GPU LEONIDA_VK_VALIDATION=1 steady-state coverage.
|
Verified
Hardware runs were performed by me on my 7950X / RX 9070 XT; comment drafted with Antigravity. |
Summary
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).