perf(host): honor VICTORY_WAIT_RESIDENT=textures for buffer pools and coalesce mapped() waits #1553

Manually merged
github merged 1 commit from github-bot/gh-1553 into main 2026-11-30 14:17:37 +00:00 AGit
Owner

@⁠qlfu on GitHub · 2026-11-28 21:37 UTC · original
qlfu:pr/wait-resident-buffers-and-mapped-coalesce → main · +188 −63 · 2 files · 1 commits · merged 2026-11-30 14:12 UTC

Summary

  1. Honor \VICTORY_WAIT_RESIDENT=textures\ on two remaining plain-buffer paths:
    • Expose \host::buffer_not_resident, \host::buffer_resident, and \host::buffer_mapped\ as \pub(crate).
    • Switch \Host::writeback_upload_buffer\ (\host.rs) and \pool::cpu_buffer\ (\pool.rs, Upload and Shared 64 MiB blocks) from
      ot_resident\ /
      esident\ / \mapped\ to the \uffer_*\ helpers. Both allocate plain buffers (\D3D12_RESOURCE_DIMENSION_BUFFER\ / \D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS), not textures, so under \VICTORY_WAIT_RESIDENT=textures\ they should follow the same policy as \upload_buffer, \shared_buffer_now, \mapped_card_buffer, and \uav_buffer.
  2. Coalesce concurrent \host::mapped()\ copy-queue fence waits:
    • Introduce \MappedBarrier\ in \host.rs\ with monotonic
      eeded\ / \done\ ticket counters (\AcqRel\ / \Acquire\ / \Release).
    • When multiple threads concurrently finish \CreateCommittedResource\ / \CreateHeap\ + \MakeResident\ and enter \mapped(), they coalesce onto a single copy-queue flush that begins after all of their allocations arrived, rather than serializing back-to-back GPU copy-queue fence round-trips behind \ASIDE.
    • On error, \done\ is not advanced so waiting threads still attempt a flush.
    • Adds deterministic multi-threaded unit tests (\mapped_barrier_coalesces_concurrent_waiters, \mapped_barrier_flushes_late_arrival_and_retries_after_error).

Verification

  • \cargo clippy -p victory-gpu --locked\ and --all-features: 0 new warnings.
  • \cargo test -p victory-gpu --lib --locked -- --test-threads=1: 552 passed, 0 failed (43 ignored).
  • 90s clean gameplay run on RTX 4070 Ti + Ryzen 7 5700X (-NoFrameGenReady -Dlss balanced, \VICTORY_PORT_CONSTANTS=1, \VICTORY_WAIT_RESIDENT=textures): 0 WARNs, 0 ERRORs; \MakeResident\ waits under =textures\ dropped from \2000 times, 1230.1 ms (max 8.8 ms)\ down to \1000 times, 599.9 ms (max 7.0 ms)\ (-51%).
**@⁠qlfu** on GitHub · 2026-11-28 21:37 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1553) `qlfu:pr/wait-resident-buffers-and-mapped-coalesce` → `main` · +188 −63 · 2 files · 1 commits · merged 2026-11-30 14:12 UTC ### Summary 1. **Honor \VICTORY_WAIT_RESIDENT=textures\ on two remaining plain-buffer paths:** - Expose \host::buffer_not_resident\, \host::buffer_resident\, and \host::buffer_mapped\ as \pub(crate)\. - Switch \Host::writeback_upload_buffer\ (\host.rs\) and \pool::cpu_buffer\ (\pool.rs\, Upload and Shared 64 MiB blocks) from \ ot_resident\ / \ esident\ / \mapped\ to the \uffer_*\ helpers. Both allocate plain buffers (\D3D12_RESOURCE_DIMENSION_BUFFER\ / \D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS\), not textures, so under \VICTORY_WAIT_RESIDENT=textures\ they should follow the same policy as \upload_buffer\, \shared_buffer_now\, \mapped_card_buffer\, and \uav_buffer\. 2. **Coalesce concurrent \host::mapped()\ copy-queue fence waits:** - Introduce \MappedBarrier<S>\ in \host.rs\ with monotonic \ eeded\ / \done\ ticket counters (\AcqRel\ / \Acquire\ / \Release\). - When multiple threads concurrently finish \CreateCommittedResource\ / \CreateHeap\ + \MakeResident\ and enter \mapped()\, they coalesce onto a single copy-queue flush that begins *after* all of their allocations arrived, rather than serializing back-to-back GPU copy-queue fence round-trips behind \ASIDE\. - On error, \done\ is not advanced so waiting threads still attempt a flush. - Adds deterministic multi-threaded unit tests (\mapped_barrier_coalesces_concurrent_waiters\, \mapped_barrier_flushes_late_arrival_and_retries_after_error\). ### Verification - \cargo clippy -p victory-gpu --locked\ and \--all-features\: 0 new warnings. - \cargo test -p victory-gpu --lib --locked -- --test-threads=1\: **552 passed, 0 failed** (43 ignored). - 90s clean gameplay run on RTX 4070 Ti + Ryzen 7 5700X (\-NoFrameGenReady -Dlss balanced\, \VICTORY_PORT_CONSTANTS=1\, \VICTORY_WAIT_RESIDENT=textures\): **0 WARNs, 0 ERRORs**; \MakeResident\ waits under \=textures\ dropped from \2000 times, 1230.1 ms (max 8.8 ms)\ down to \1000 times, 599.9 ms (max 7.0 ms)\ (-51%).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 21:43:06 +00:00
Author
Owner

@⁠amazedturnip on GitHub · 2026-11-29 05:38 UTC · original

Tested on 9800X3D + RTX 5070 Ti 16 GB with VICTORY_WAIT_RESIDENT=textures in a combined perf stack across 20+ min sessions. Zero residency errors or corruption; frame pacing improved noticeably with buffer-pool MakeResident stalls cut out.

**@⁠amazedturnip** on GitHub · 2026-11-29 05:38 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1553#issuecomment-7251374018) Tested on 9800X3D + RTX 5070 Ti 16 GB with VICTORY_WAIT_RESIDENT=textures in a combined perf stack across 20+ min sessions. Zero residency errors or corruption; frame pacing improved noticeably with buffer-pool MakeResident stalls cut out.
github-bot force-pushed github-bot/gh-1553 from a685c3a3e9 to a0acea9049 2026-11-29 10:17:30 +00:00 Compare
Author
Owner

@⁠qlfu on GitHub · 2026-11-29 10:14 UTC · original

Rebased onto current \main\ (\829188e9): dropped the \writeback_upload_buffer\ hunk that already landed upstream and wired \MappedBarrier\ around the shared \ASIDE\ copy queue used by \mapped()\ and \with_copy_queue_sync(). Verified with \cargo clippy, \mapped_barrier\ unit tests, and a clean 90s gameplay run (\mapped()\ total wait 449.2 ms -> 167.0 ms, 6 coalesced, 0 WARNs/0 ERRORs).

**@⁠qlfu** on GitHub · 2026-11-29 10:14 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1553#issuecomment-7254301423) Rebased onto current \main\ (\829188e9\): dropped the \writeback_upload_buffer\ hunk that already landed upstream and wired \MappedBarrier\ around the shared \ASIDE\ copy queue used by \mapped()\ and \with_copy_queue_sync()\. Verified with \cargo clippy\, \mapped_barrier\ unit tests, and a clean 90s gameplay run (\mapped()\ total wait 449.2 ms -> 167.0 ms, 6 coalesced, 0 WARNs/0 ERRORs).
github manually merged commit ebe912e128 into main 2026-11-30 14:17:37 +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!1553
No description provided.