Buffers made ahead sixteen at a time, with one residency call and one wait #682

Open
0xkn0wh3r3 wants to merge 7 commits from upstream-pr/682 into main
0xkn0wh3r3 commented 2026-11-28 03:32:43 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by 0xkn0wh3r3 on 2026-11-28T03:32:43Z.


Stacked on #630. Its commits come first on this branch. New here: the last two commits, Buffers made ahead sixteen at a time, with one residency call and one wait and Buffers made together: a bench.

Why

Every title buffer gets a 64 KiB copy in the PC's memory (and, with card copies, one on the card), and a scene's first frame asks for thousands of them. The thread that makes them ahead (crate::ahead) made them one at a time: a committed resource, a MakeResident, and a mapping copy waited for, each. At a scene start the title took buffers faster than the store refilled, and the rest were made by the threads a frame waits for.

What

  • Host::shared_buffers_now(size, n) and Host::uav_buffers(size, n) make n buffers together, with one MakeResident call for all of them and one mapping copy. shared_buffer_now and uav_buffer are the same with n = 1, so nothing else changes.
  • The ahead thread makes 16 at a time (VICTORY_AHEAD_BATCH; 1: one at a time, as before), and pauses 50 ms if the host refuses, instead of asking again at once.

Before / after

bench_buffers_made_one_at_a_time_or_together (--ignored --nocapture), 256 buffers of 64 KiB, RTX card, three runs. Time per buffer:

card, 1 at a time card, 16 at a time shared, 1 at a time shared, 16 at a time
idle 0.39–0.51 ms 0.21–0.29 ms 0.29–0.39 ms 0.15–0.22 ms
beside 64 MiB buffers being made (VICTORY_BENCH_AHEAD_KB=65536) 1.45–1.59 ms 0.77–0.94 ms 1.31–1.44 ms 0.47–0.71 ms

Correctness

  • buffers_made_together_are_whole_and_their_own: 16 shared and 16 card buffers made together are as many as were asked for, don't overlap in the card's address space, each have their own CPU mapping (each written and read back), and the debug layer reports nothing (VICTORY_D3D12_DEBUG=1, diagnostics build).
  • CI steps run locally on this branch: clippy in both builds with -D warnings, and cargo test --workspace --locked, all pass.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5536263136 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/682). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-28T03:32:43Z. --- **Stacked on #630.** Its commits come first on this branch. New here: the last two commits, `Buffers made ahead sixteen at a time, with one residency call and one wait` and `Buffers made together: a bench`. ## Why Every title buffer gets a 64 KiB copy in the PC's memory (and, with card copies, one on the card), and a scene's first frame asks for thousands of them. The thread that makes them ahead (`crate::ahead`) made them one at a time: a committed resource, a `MakeResident`, and a mapping copy waited for, each. At a scene start the title took buffers faster than the store refilled, and the rest were made by the threads a frame waits for. ## What - `Host::shared_buffers_now(size, n)` and `Host::uav_buffers(size, n)` make `n` buffers together, with one `MakeResident` call for all of them and one mapping copy. `shared_buffer_now` and `uav_buffer` are the same with `n = 1`, so nothing else changes. - The ahead thread makes 16 at a time (`VICTORY_AHEAD_BATCH`; `1`: one at a time, as before), and pauses 50 ms if the host refuses, instead of asking again at once. ## Before / after `bench_buffers_made_one_at_a_time_or_together` (`--ignored --nocapture`), 256 buffers of 64 KiB, RTX card, three runs. Time per buffer: | | card, 1 at a time | card, 16 at a time | shared, 1 at a time | shared, 16 at a time | |---|---|---|---|---| | idle | 0.39–0.51 ms | 0.21–0.29 ms | 0.29–0.39 ms | 0.15–0.22 ms | | beside 64 MiB buffers being made (`VICTORY_BENCH_AHEAD_KB=65536`) | 1.45–1.59 ms | 0.77–0.94 ms | 1.31–1.44 ms | 0.47–0.71 ms | ## Correctness - `buffers_made_together_are_whole_and_their_own`: 16 shared and 16 card buffers made together are as many as were asked for, don't overlap in the card's address space, each have their own CPU mapping (each written and read back), and the debug layer reports nothing (`VICTORY_D3D12_DEBUG=1`, diagnostics build). - CI steps run locally on this branch: clippy in both builds with `-D warnings`, and `cargo test --workspace --locked`, all pass.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/682:upstream-pr/682'
git switch 'upstream-pr/682'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/682'
git switch 'upstream-pr/682'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/682'
git switch 'upstream-pr/682'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/682'
git switch 'main'
git merge --squash 'upstream-pr/682'
git switch 'main'
git merge --ff-only 'upstream-pr/682'
git switch 'main'
git merge 'upstream-pr/682'
git push origin 'main'
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!682
No description provided.