perf(gpu): use AddressHash on hot maps, cache HostHeap gpu base, and fast-path twins_written #54

Merged
ahmetbagci8 merged 1 commit from upstream-pr/54 into main 2026-12-01 17:45:47 +00:00
ahmetbagci8 commented 2026-12-01 16:55:42 +00:00 (Migrated from github.com)

Imported from edsuuu/VI-BR-PORT. Originally posted by ahmetbagci8 on 2026-12-01T16:55:42Z.


Towards #27 (lower per-frame CPU preparing cost).

Changes

  1. Use AddressHash on 6 missed hot integer/pointer maps:
    • State::root_srv_slots and State::root_uav_slots (crates/victory-gpu/src/draw.rs)
    • Deferred::textures and Deferred::texture_aliases (crates/victory-gpu/src/host.rs)
    • Spans::by_slot and Spans::first (crates/victory-gpu/src/descriptor/host.rs)
      (Adjacent maps in the same structs already use BuildHasherDefault.)
  2. Cache gpu: u64 on HostHeap (crates/victory-gpu/src/descriptor/host.rs): HostHeap::new() already queries GetGPUDescriptorHandleForHeapStart().ptr; caching it avoids a COM vtable call on every gpu_handle() root table bind.
  3. Lock-free fast path in HostList::twins_written() (crates/victory-gpu/src/host.rs): Called at the end of every State::bind(); tracking active twin writes with an AtomicBool avoids acquiring self.twins.lock() on >99.9% of draws/dispatches that have no active depth-twin writes.

Verification

  • cargo test -p victory-gpu --lib descriptor::host::tests::spans_say (passed)
  • cargo clippy -p victory-gpu --tests (0 warnings)
  • cargo test -p xtask english (5 passed, 0 failed)
<!-- greyfinch-sync:edsuuu/VI-BR-PORT:issue:5590377809 --> Imported from [edsuuu/VI-BR-PORT](https://github.com/edsuuu/VI-BR-PORT/pull/54). Originally posted by [ahmetbagci8](https://github.com/ahmetbagci8) on 2026-12-01T16:55:42Z. --- Towards #27 (lower per-frame CPU preparing cost). ## Changes 1. **Use AddressHash on 6 missed hot integer/pointer maps:** - State::root_srv_slots and State::root_uav_slots (crates/victory-gpu/src/draw.rs) - Deferred::textures and Deferred::texture_aliases (crates/victory-gpu/src/host.rs) - Spans::by_slot and Spans::first (crates/victory-gpu/src/descriptor/host.rs) (Adjacent maps in the same structs already use BuildHasherDefault<AddressHash>.) 2. **Cache gpu: u64 on HostHeap (crates/victory-gpu/src/descriptor/host.rs):** HostHeap::new() already queries GetGPUDescriptorHandleForHeapStart().ptr; caching it avoids a COM vtable call on every gpu_handle() root table bind. 3. **Lock-free fast path in HostList::twins_written() (crates/victory-gpu/src/host.rs):** Called at the end of every State::bind(); tracking active twin writes with an AtomicBool avoids acquiring self.twins.lock() on >99.9% of draws/dispatches that have no active depth-twin writes. ## Verification - cargo test -p victory-gpu --lib descriptor::host::tests::spans_say (passed) - cargo clippy -p victory-gpu --tests (0 warnings) - cargo test -p xtask english (5 passed, 0 failed)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
edsuuu/VI-BR-PORT!54
No description provided.