gpu: cache heap handles, fast-path twins_written, reuse Deferred allocations, and stack-allocate hot list paths #347

Manually merged
github merged 2 commits from github-bot/gh-347 into main 2026-11-29 08:22:15 +00:00 AGit
Owner

@⁠Wiktorxd-1 on GitHub · 2026-11-27 21:15 UTC · original
Wiktorxd-1:perf/host-handles-and-deferred-reuse → main · +115 −32 · 4 files · 2 commits · merged 2026-11-29 08:16 UTC

What this fixes

Command-list translation (victory_gpu::list::thin) and draw recording hit several avoidable per-call overheads on every draw, barrier, render-target bind, and list reset:

  • HostHeap::gpu_handle called ID3D12DescriptorHeap::GetGPUDescriptorHandleForHeapStart() on every descriptor lookup, even though HostHeap::new already computes gpu.
  • Host::rtv and Host::dsv called GetCPUDescriptorHandleForHeapStart() on every RTV/DSV creation.
  • HostList::twins_written() locked self.twins at the end of every draw::State::bind, even on lists that never touch a depth twin.
  • HostList::reset replaced *self.deferred() = Deferred::default(), dropping all Vec, HashSet, and HashMap heap capacities on every list reset.
  • list::state::targets, list::barrier, and draw::State::bind heap-allocated small temporary Vecs ([u64; 8], Vec<Barrier>, Vec::with_capacity(2)) on every call.

I can't give a clean 3D-scene fps delta yet: the local launch test (90s, Series S, DLSS Performance, FG 6x) only ran through boot and the intro/menu at 120 presents/s (warns=0, crashes.log=False) without loading into a heavy 3D save.

The commits

  1. Cache heap start handles (HostHeap::gpu, Host::rtv_start, Host::dsv_start). HostHeap::new and Host::new store the descriptor heap start pointers once instead of querying COM on every handle/view lookup.
  2. Lockless HostList::twins_written() fast path. Added has_twins: AtomicBool on HostList (set in twin_use, cleared in HostList::reset) so twins_written() returns immediately when no depth twin is in use.
  3. Reuse Deferred allocations across HostList::reset. Added Deferred::clear() (preserving give_chunks and ALIVE[6]/ALIVE[7] accounting from Drop) so copies, uploads, kept, bound, refreshed, gpu_written, filled, textures, writes, backs, and back_wanted/texture_backs keep their capacities.
  4. Stack-allocate hot list slices. list::state::targets uses a [u64; 8] stack buffer for one_range (and borrows items(handles, count) directly otherwise); list::barrier uses [MaybeUninit<Barrier>; 16] for < 16 barriers; draw::State::bind uses [Option<ID3D12DescriptorHeap>; 2].

Tests

  • cargo test --locked -p victory-gpu --lib descriptor (110 passed, 0 failed, 16 ignored across descriptor + host::)
  • cargo test --locked -p victory-gpu --lib host:: (passed, 0 failed)
  • cargo build --release --locked -p victory (succeeded)
  • Launched target\release\victory.exe via scripts\play-nvidia.ps1 (90s, warns=0, crashes.log=False).

Setup

NVIDIA GeForce RTX 5070, driver 621.14.0, Windows 11 (10.0.26300). Series S profile, DLSS Performance, Frame Generation 6x. My own dump: <game dir>. No game files are attached or quoted.

This change and its testing were done with an AI assistant (Antigravity), and I checked the results on my machine.

**@⁠Wiktorxd-1** on GitHub · 2026-11-27 21:15 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/347) `Wiktorxd-1:perf/host-handles-and-deferred-reuse` → `main` · +115 −32 · 4 files · 2 commits · merged 2026-11-29 08:16 UTC ## What this fixes Command-list translation (`victory_gpu::list::thin`) and draw recording hit several avoidable per-call overheads on every draw, barrier, render-target bind, and list reset: - `HostHeap::gpu_handle` called `ID3D12DescriptorHeap::GetGPUDescriptorHandleForHeapStart()` on every descriptor lookup, even though `HostHeap::new` already computes `gpu`. - `Host::rtv` and `Host::dsv` called `GetCPUDescriptorHandleForHeapStart()` on every RTV/DSV creation. - `HostList::twins_written()` locked `self.twins` at the end of every `draw::State::bind`, even on lists that never touch a depth twin. - `HostList::reset` replaced `*self.deferred() = Deferred::default()`, dropping all `Vec`, `HashSet`, and `HashMap` heap capacities on every list reset. - `list::state::targets`, `list::barrier`, and `draw::State::bind` heap-allocated small temporary `Vec`s (`[u64; 8]`, `Vec<Barrier>`, `Vec::with_capacity(2)`) on every call. I can't give a clean 3D-scene fps delta yet: the local launch test (`90s`, Series S, DLSS Performance, FG 6x) only ran through boot and the intro/menu at 120 presents/s (`warns=0`, `crashes.log=False`) without loading into a heavy 3D save. ## The commits 1. **Cache heap start handles (`HostHeap::gpu`, `Host::rtv_start`, `Host::dsv_start`).** `HostHeap::new` and `Host::new` store the descriptor heap start pointers once instead of querying COM on every handle/view lookup. 2. **Lockless `HostList::twins_written()` fast path.** Added `has_twins: AtomicBool` on `HostList` (set in `twin_use`, cleared in `HostList::reset`) so `twins_written()` returns immediately when no depth twin is in use. 3. **Reuse `Deferred` allocations across `HostList::reset`.** Added `Deferred::clear()` (preserving `give_chunks` and `ALIVE[6]`/`ALIVE[7]` accounting from `Drop`) so `copies`, `uploads`, `kept`, `bound`, `refreshed`, `gpu_written`, `filled`, `textures`, `writes`, `backs`, and `back_wanted`/`texture_backs` keep their capacities. 4. **Stack-allocate hot list slices.** `list::state::targets` uses a `[u64; 8]` stack buffer for `one_range` (and borrows `items(handles, count)` directly otherwise); `list::barrier` uses `[MaybeUninit<Barrier>; 16]` for `< 16` barriers; `draw::State::bind` uses `[Option<ID3D12DescriptorHeap>; 2]`. ## Tests - `cargo test --locked -p victory-gpu --lib descriptor` (110 passed, 0 failed, 16 ignored across `descriptor` + `host::`) - `cargo test --locked -p victory-gpu --lib host::` (passed, 0 failed) - `cargo build --release --locked -p victory` (succeeded) - Launched `target\release\victory.exe` via `scripts\play-nvidia.ps1` (`90s`, `warns=0`, `crashes.log=False`). ## Setup NVIDIA GeForce RTX 5070, driver `621.14.0`, Windows 11 (`10.0.26300`). Series S profile, DLSS Performance, Frame Generation 6x. My own dump: `<game dir>`. No game files are attached or quoted. This change and its testing were done with an AI assistant (Antigravity), and I checked the results on my machine.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 21:17:46 +00:00
github-bot force-pushed github-bot/gh-347 from 0b4cfccfb8 to 65e275c9e8 2026-11-27 23:47:42 +00:00 Compare
github manually merged commit 06cd70b563 into main 2026-11-29 08:22:15 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!347
No description provided.