Repository navigation
GPU: track dynamic descriptor slots in a 64-bit word bitmap - #3218
danielibabet wants to merge 1 commit into
Conversation
Dukestar69
left a comment
There was a problem hiding this comment.
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).
…in a 64-bit word bitmap
|
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 I compiled the allocator and release methods with their mutex into a single-threaded native CPU harness (Rust 1.98.1, |
|
NVIDIA test report: RTX 4070 Ti (desktop, driver 621.01), Windows 11 Pro, rustc 1.98.1. Head
Synthetic tests only, no game files. AI-assisted (Claude Code). |
|
List-call numbers for this PR (head
Method. Bases. Reading it. Neutral on the steady-state draw path. Batch 1's −6.5 % at 5 threads on Correctness. Not measured. A heap with ~4,700 shadow pairs taken (the NVIDIA case the PR is about), and any game frame. AI use: Claude Code (Claude Opus 5.5). |
Summary
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