GPU: track dynamic descriptor slots in a 64-bit word bitmap #3218
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!3218
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3218"
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?
@danielibabet on GitHub · 2026-11-26 13:33 UTC · original
danielibabet:pr/dynamic-slot-bitmap→main· +425 −34 · 1 files · 1 commits · openSummary
Replace the
Vec<bool>dynamic slot allocator inHostHeapwith a dense 64-bit word bitmap (DynamicSlots). This is a performance fix for NVIDIA GPUs where the host heap is capped at 1,000,000 shader-visible descriptors, forcingMIN_DYNAMIC= 65,536 slots to absorb all descriptor tables above slot 934,464 and all root-view runs.Problem
The previous allocator stored one
boolper slot (up to 262,144 bytes / 256 KiB for a 256K heap) and scanned byte-by-byte under the heapMutex. When the dynamic range fragmented or saturated — which happens every frame on NVIDIA with ~4,700 shadow copies requestingpair() → dynamic(2)— a single frame could scan hundreds of thousands of bytes while holding the lock, stalling all render threads.Solution
DynamicSlotspacks slot state intoVec<u64>(8× less memory: 8 KiB for the NVIDIA 64K range, fits in L1D):u64::MAX) or empty words (0) in 1–2 instructions; resolves cross-word spans withtrailing_zeros/leading_zeros; locates internal gaps of 1–63 slots in ≤6 bit-shift operations.min_failedtracks the smallestnthat did not fit after a full scan. Requests of size ≥min_failedare rejected in nanoseconds until areleaseclears at least one bit (zero false negatives, no heuristics, no frame-counter coupling).Benchmark results (cargo test --release, i9-14900KF)
Tests
descriptor::host::testson WARP: 17/17 passedcargo clippy --workspace --all-targets --all-features --locked -- -D warnings: 0 warningscargo run -p xtask -- policy: 191 files OK@Dukestar69 on GitHub · 2026-11-26 13:52 UTC · original · approved these changes
Verified on RTX 5090 against
origin/main(63bcca4):cargo test -p victory-gpu --lib descriptor::host:: -- --test-threads=1 --skip dynamic_slots_are_held_until_released: 16/16 passed (1 ignored bench; includingdynamic_slot_bitmap_handles_word_boundaries_and_failed_watermarkanddynamic_slot_bitmap_matches_reference_allocator).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Cleanly accelerates dynamic descriptor slot allocation using a 64-bit word bitmap.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@rezioliver-collab on GitHub · 2026-11-26 18:01 UTC · original
I measured how much of the saturated-heap speedup survives when releases repeatedly invalidate the cached failed request size. With 65,535 slots on Apple M1, even reopening two slots on every iteration reduced the time for the 256-iteration trace from 42.61 ms to 0.324 ms.
The heap started full. Each reopening tried a three-slot allocation, then reclaimed the two-slot hole. Holes alternated between slots 63–64 and the heap tail. Each iteration also requested 3–6 slots from the full heap. Every returned index and failed request matched between
63bcca43and249ba2a6, including the 65- and 4,095-slot controls.I compiled the allocator and release methods with their mutex into a single-threaded native CPU harness (Rust 1.98.1,
opt-level=3, macOS 14.7). Times are medians from 12 alternating pairs and measure allocator work only.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.