perf(gpu): lock-free kept_raw, packed u64 ListViews, and RwLock PLACED_TEXTURES #23

Closed
github-bot wants to merge 1 commit from gh-pr/23/head into gh-pr/23/base
Owner

@⁠justadudeinbulgaria on GitHub · 2026-11-30 23:19 UTC · original
justadudeinbulgaria:pr/descriptor-host-and-placed-fastpath → main · +107 −38 · 2 files · 1 commits · closed without merging

Summary

Cuts hot descriptor-slot and placed-texture lock contention and hash-table overhead:

  • crates/victory-gpu/src/descriptor/host.rs:
    • Adds a lock-free AtomicUsize kept_raw mirror and keep_ref() so single-owner dynamic descriptor slots (index >= count) skip COM AddRef/Release and the per-slot mutex completely when rebinding the same resource.
    • Guards clear_twin() with a relaxed AtomicBool::load before atomic swap.
    • Packs ListViews hash keys (words[1], words[2]) into a single u64 with single-lookup entry() in make_listed.
  • crates/victory-gpu/src/resource.rs:
    • Migrates PLACED_TEXTURES from Mutex<BTreeMap<...>> to OnceLock<RwLock<HashMap<..., AddressHash>>> with a read-lock fast-hit path in texture_at(), eliminating exclusive lock contention across concurrent descriptor/list threads.

Verification

  • Unit tests: cargo test --release -p victory-gpu --lib descriptor:: (66/66 passed) and cargo test --release -p victory-gpu --lib resource:: (15/15 passed).
  • Live verified on RTX 2060 SUPER 8 GB + i5-10600K (D3D12Core.dll / descriptor thread CPU overhead cut cleanly with zero visual issues).
**@⁠justadudeinbulgaria** on GitHub · 2026-11-30 23:19 UTC · [original](https://github.com/ToLIManl/VIctory-Hydra/pull/23) `justadudeinbulgaria:pr/descriptor-host-and-placed-fastpath` → `main` · +107 −38 · 2 files · 1 commits · closed without merging ## Summary Cuts hot descriptor-slot and placed-texture lock contention and hash-table overhead: - **`crates/victory-gpu/src/descriptor/host.rs`:** - Adds a lock-free `AtomicUsize` `kept_raw` mirror and `keep_ref()` so single-owner dynamic descriptor slots (`index >= count`) skip COM `AddRef`/`Release` and the per-slot mutex completely when rebinding the same resource. - Guards `clear_twin()` with a relaxed `AtomicBool::load` before atomic `swap`. - Packs `ListViews` hash keys `(words[1], words[2])` into a single `u64` with single-lookup `entry()` in `make_listed`. - **`crates/victory-gpu/src/resource.rs`:** - Migrates `PLACED_TEXTURES` from `Mutex<BTreeMap<...>>` to `OnceLock<RwLock<HashMap<..., AddressHash>>>` with a read-lock fast-hit path in `texture_at()`, eliminating exclusive lock contention across concurrent descriptor/list threads. ## Verification - Unit tests: `cargo test --release -p victory-gpu --lib descriptor::` (66/66 passed) and `cargo test --release -p victory-gpu --lib resource::` (15/15 passed). - Live verified on RTX 2060 SUPER 8 GB + i5-10600K (`D3D12Core.dll` / descriptor thread CPU overhead cut cleanly with zero visual issues).
Cut hot descriptor-slot and placed-texture mutex/hashing overhead:

- descriptor/host.rs: add lock-free AtomicUsize kept_raw mirror and keep_ref() so single-owner dynamic descriptor slots skip COM AddRef/Release and the per-slot mutex when rebinding the same resource; guard clear_twin() with a relaxed AtomicBool load before atomic swap; pack ListViews hash keys into u64 with single-lookup entry().
- resource.rs: migrate PLACED_TEXTURES from Mutex<BTreeMap> to OnceLock<RwLock<HashMap<..., AddressHash>>> with a read-lock fast-hit path in texture_at() to eliminate exclusive lock contention across concurrent descriptor/list threads.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 17:09:06 +00:00
github-bot closed this pull request 2026-12-02 17:09:06 +00:00
Author
Owner

@⁠ToLIManl on GitHub · 2026-12-01 00:48 UTC · original

Integrated into \main\ in commit \64f4cb9\ (with \Co-authored-by\ attribution).

Verified via \ ictory-gpu\ release tests (\descriptor::\ --test-threads=1\ \66 passed,
esource::\ \15 passed) and live RTX 3060 runs.

**@⁠ToLIManl** on GitHub · 2026-12-01 00:48 UTC · [original](https://github.com/ToLIManl/VIctory-Hydra/pull/23#issuecomment-7296754463) Integrated into \main\ in commit \64f4cb9\ (with \Co-authored-by\ attribution). Verified via \ ictory-gpu\ release tests (\descriptor::\ \--test-threads=1\ \66 passed\, \ esource::\ \15 passed\) and live RTX 3060 runs.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.