descriptor: replace HostHeap::dynamic Vec<bool> scan with u64 bitset #444

Merged
Wiktorxd-1 merged 1 commit from upstream-pr/444 into main 2026-11-29 08:16:59 +00:00
Wiktorxd-1 commented 2026-11-27 22:35:44 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Wiktorxd-1 on 2026-11-27T22:35:44Z.


What this fixes

HostHeap::dynamic (crates/victory-gpu/src/descriptor/host.rs) tracks 262,144 to 1,048,576 dynamic descriptor slots behind a single Mutex shared by all VICTORY_THIN=1 recording threads. Previously it stored Vec<bool> (256 KiB–1 MiB) and scanned 1 byte at a time on every uncached descriptor table, root SRV, and root UAV allocation, and HostHeap::release iterated slots.iter() byte-by-byte.

Replacing Vec<bool> with a Vec<u64> bitset (4 KiB–16 KiB, 64 slots per u64):

  • shrinks the ring 16× so it fits in L1 cache;
  • skips 64 taken/free slots in a single instruction (taken == u64::MAX / taken == 0) and locates free runs via trailing_zeros() / trailing_ones();
  • clears and counts released slots via count_ones() and word masks in HostHeap::release;
  • preserves non-multiple-of-64 self.dynamic bounds (trailing padding bits in the final word are initialized to 1 and never cleared by release) and no-wrap-past-end semantics across cursor.

The commits

  1. Replace HostHeap::dynamic Vec<bool> scan with u64 bitset (find_free_run, set_bits, clear_and_count_bits).

Tests

  • cargo test --locked -p victory-gpu --lib descriptor::host::tests (47 passed; 0 failed, including dynamic_slots_are_held_until_released, dynamic_search_can_find_a_run_across_the_cursor, dynamic_slots_populate_and_clear_stride_table, dynamic_slots_are_given_back_only_to_the_heap_that_took_them)
  • cargo build --release --locked -p victory (succeeded)
  • Launched target\release\victory.exe via scripts\play-nvidia.ps1 (35s, 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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5533975605 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/444). Originally posted by [Wiktorxd-1](https://github.com/Wiktorxd-1) on 2026-11-27T22:35:44Z. --- ## What this fixes `HostHeap::dynamic` (`crates/victory-gpu/src/descriptor/host.rs`) tracks 262,144 to 1,048,576 dynamic descriptor slots behind a single `Mutex` shared by all `VICTORY_THIN=1` recording threads. Previously it stored `Vec<bool>` (256 KiB–1 MiB) and scanned 1 byte at a time on every uncached descriptor table, root SRV, and root UAV allocation, and `HostHeap::release` iterated `slots.iter()` byte-by-byte. Replacing `Vec<bool>` with a `Vec<u64>` bitset (4 KiB–16 KiB, 64 slots per `u64`): - shrinks the ring 16× so it fits in L1 cache; - skips 64 taken/free slots in a single instruction (`taken == u64::MAX` / `taken == 0`) and locates free runs via `trailing_zeros()` / `trailing_ones()`; - clears and counts released slots via `count_ones()` and word masks in `HostHeap::release`; - preserves non-multiple-of-64 `self.dynamic` bounds (trailing padding bits in the final word are initialized to `1` and never cleared by `release`) and no-wrap-past-end semantics across `cursor`. ## The commits 1. **Replace `HostHeap::dynamic` `Vec<bool>` scan with `u64` bitset** (`find_free_run`, `set_bits`, `clear_and_count_bits`). ## Tests - `cargo test --locked -p victory-gpu --lib descriptor::host::tests` (`47 passed; 0 failed`, including `dynamic_slots_are_held_until_released`, `dynamic_search_can_find_a_run_across_the_cursor`, `dynamic_slots_populate_and_clear_stride_table`, `dynamic_slots_are_given_back_only_to_the_heap_that_took_them`) - `cargo build --release --locked -p victory` (succeeded) - Launched `target\release\victory.exe` via `scripts\play-nvidia.ps1` (`35s`, `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.
Rafa7046 commented 2026-11-28 01:28:26 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Rafa7046 on 2026-11-28T01:28:26Z.


Measured on an RTX 5080 16 GB + Ryzen 9 9950X3D (Series X, 1440p, DLSS Performance, frame generation off, diagnostics build on 64d4931 with only this PR applied, pipelines made ahead with victory warm), same stretch each run: Lucia's arrest cutscenes, then Jason on the boat and a minute standing still.

Cutscenes, fps (median) Boat, fps preparing in the cutscenes
main, run 1 37.4 35.8 19.6 ms
main, run 2 35.0 34.7 21.4 ms
with #444 35.5 35.0 21.2 ms

Two runs of plain main differ by about 2.4 fps, so this is within the run-to-run spread on this machine: no measurable change in frame rate here, and no new warnings, faults or crashes in the log. On this card the frame is set by the submitting thread (about 21 ms of a 28 ms frame), which is probably why a saving of this size does not show.

Same machine and scene with and without the title's ray tracing: #535.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7231690115 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/444#issuecomment-7231690115). Originally posted by [Rafa7046](https://github.com/Rafa7046) on 2026-11-28T01:28:26Z. --- Measured on an RTX 5080 16 GB + Ryzen 9 9950X3D (Series X, 1440p, DLSS Performance, frame generation off, diagnostics build on `64d4931` with only this PR applied, pipelines made ahead with `victory warm`), same stretch each run: Lucia's arrest cutscenes, then Jason on the boat and a minute standing still. | | Cutscenes, fps (median) | Boat, fps | `preparing` in the cutscenes | |---|---|---|---| | `main`, run 1 | 37.4 | 35.8 | 19.6 ms | | `main`, run 2 | 35.0 | 34.7 | 21.4 ms | | **with #444** | **35.5** | **35.0** | **21.2 ms** | Two runs of plain `main` differ by about 2.4 fps, so this is within the run-to-run spread on this machine: no measurable change in frame rate here, and no new warnings, faults or crashes in the log. On this card the frame is set by the submitting thread (about 21 ms of a 28 ms frame), which is probably why a saving of this size does not show. Same machine and scene with and without the title's ray tracing: #535.
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
trustno1-coder/VIctory-NVIDIA!444
No description provided.