GPU/HLE: cap default VICTORY_LATE_WAIT_LISTS on <= 6 GiB cards and replace global remap lock with RangeLock (Refs #431) #570

Open
github-bot wants to merge 7 commits from github-bot/gh-570 into main AGit
Owner

@⁠BE29ZZ on GitHub · 2026-11-25 02:18 UTC · original
BE29ZZ:fix-issue-431 → main · +554 −59 · 6 files · 7 commits · open

Summary

Addresses two of the dominant bottlenecks identified in #431 on 6 GB VRAM cards (e.g., RTX 2060 6 GB, vram_budget_mb=5187):

  1. Tier 1 — Cap default VICTORY_LATE_WAIT_LISTS to 64 on <= 6 GiB local VRAM budget (crates/victory-gpu/src/host.rs):

    • Queries Host::video_memory() lazily when VICTORY_LATE_WAIT_LISTS is unset/invalid and defaults to 64 when the adapter's local DXGI budget is non-zero and <= 6 GiB (keeping 256 on 8 GB+ cards or when unavailable).
    • Preserves explicit VICTORY_LATE_WAIT_LISTS overrides (without querying DXGI) and logs vram_budget_mb alongside most on startup.
    • Leaves DYNAMIC = 1 << 18 unchanged (raising it on NVIDIA's 1M view heap cap would cut into the title's ~720k slots) and preserves QUEUE_ORDER / card_merge_relay ordering intact.
  2. Tier 2 — Replace the global title-memory remap RwLock<()> with a range lock (watch.rs, lib.rs, texture.rs, draw.rs, xmem.rs):

    • Replaces watch::MAPPING: RwLock<()> with an interval lock (RangeLock) over half-open virtual address ranges [start, end), preventing unrelated streaming remaps in XMemMapPhysicalPages / map_alias from stalling texture refreshes on disjoint memory ("waiting for title memory to hold still").
    • Computes the full affected view hull in xmem::affected_range and handles placeholder coalescing (MEM_COALESCE_PLACEHOLDERS) so UnmapViewOfFile2 view splits still serialize cleanly against readers on any page of an affected view.
    • Drops the read guard before kernel-copied (copy_mapped) hashing/detiling on the !committed and through_copy() paths in Staging::refresh_timed, and scopes State::rectangles to its vertex slice.

What Is Not Changed

  • Relay fetch queue placement (QUEUE_ORDER): relay_card_back remains on the direct queue so Shadow::card_merge_relay keeps exact ordering against card_before uploads.
  • "title memory read" (WHY_READ / Step::Fill) settles: Left intact so CPU upload fills cannot observe stale bytes ahead of in-flight shader writes.

Verification Status

  • Disclosure: Implemented with AI assistance and verified via GitHub Actions CI.
  • CI checks (passing on fork branch):
    • Clippy — passed
    • Clippy, diagnostics build — passed
    • Tests — passed, including new unit tests:
      • victory-gpu::host::late_tests::late_most_scales_with_vram_budget_and_honours_override
      • victory-gpu::watch::mapping_tests::{disjoint_ranges_do_not_block_each_other, waiting_writer_blocks_overlapping_readers_without_blocking_disjoint, overlapping_writers_serialize_in_fifo_order_without_deadlock}
      • victory-hle::modules::xmem::tests::{affected_range_expands_to_overlapping_views, a_range_read_in_place_never_meets_a_split_view_gap}
  • Hardware profiling needed: No runtime frame-time or FPS gains are claimed here until measured on real 6 GB hardware. @⁠CIS-C0 — if you are still up for testing builds from #431 on the RTX 2060 6 GB, it would be great to compare:
    1. Default startup log (vram_budget_mb, most=64) and whether "a draw whose descriptor table found no free slots is dropped" stays at zero without setting VICTORY_LATE_WAIT_LISTS=64.
    2. Per-frame "waiting for title memory to hold still (the runtime remapping it)" ms during world streaming (previously 75–500 ms), and stability (no access violations in Staging::refresh_now / Layout::detile).

Refs #431

**@⁠BE29ZZ** on GitHub · 2026-11-25 02:18 UTC · [original](https://github.com/fxceless/victory-fork/pull/570) `BE29ZZ:fix-issue-431` → `main` · +554 −59 · 6 files · 7 commits · open ## Summary Addresses two of the dominant bottlenecks identified in #431 on 6 GB VRAM cards (e.g., RTX 2060 6 GB, `vram_budget_mb=5187`): 1. **Tier 1 — Cap default `VICTORY_LATE_WAIT_LISTS` to `64` on <= 6 GiB local VRAM budget (`crates/victory-gpu/src/host.rs`):** - Queries `Host::video_memory()` lazily when `VICTORY_LATE_WAIT_LISTS` is unset/invalid and defaults to `64` when the adapter's local DXGI budget is non-zero and `<= 6 GiB` (keeping `256` on 8 GB+ cards or when unavailable). - Preserves explicit `VICTORY_LATE_WAIT_LISTS` overrides (without querying DXGI) and logs `vram_budget_mb` alongside `most` on startup. - Leaves `DYNAMIC = 1 << 18` unchanged (raising it on NVIDIA's 1M view heap cap would cut into the title's ~720k slots) and preserves `QUEUE_ORDER` / `card_merge_relay` ordering intact. 2. **Tier 2 — Replace the global title-memory remap `RwLock<()>` with a range lock (`watch.rs`, `lib.rs`, `texture.rs`, `draw.rs`, `xmem.rs`):** - Replaces `watch::MAPPING: RwLock<()>` with an interval lock (`RangeLock`) over half-open virtual address ranges `[start, end)`, preventing unrelated streaming remaps in `XMemMapPhysicalPages` / `map_alias` from stalling texture refreshes on disjoint memory (`"waiting for title memory to hold still"`). - Computes the full affected view hull in `xmem::affected_range` and handles placeholder coalescing (`MEM_COALESCE_PLACEHOLDERS`) so `UnmapViewOfFile2` view splits still serialize cleanly against readers on any page of an affected view. - Drops the read guard before kernel-copied (`copy_mapped`) hashing/detiling on the `!committed` and `through_copy()` paths in `Staging::refresh_timed`, and scopes `State::rectangles` to its vertex slice. ## What Is *Not* Changed - **Relay fetch queue placement (`QUEUE_ORDER`):** `relay_card_back` remains on the direct queue so `Shadow::card_merge_relay` keeps exact ordering against `card_before` uploads. - **`"title memory read"` (`WHY_READ` / `Step::Fill`) settles:** Left intact so CPU upload fills cannot observe stale bytes ahead of in-flight shader writes. ## Verification Status - **Disclosure:** Implemented with AI assistance and verified via GitHub Actions CI. - **CI checks (passing on fork branch):** - `Clippy` — passed - `Clippy, diagnostics build` — passed - `Tests` — passed, including new unit tests: - `victory-gpu::host::late_tests::late_most_scales_with_vram_budget_and_honours_override` - `victory-gpu::watch::mapping_tests::{disjoint_ranges_do_not_block_each_other, waiting_writer_blocks_overlapping_readers_without_blocking_disjoint, overlapping_writers_serialize_in_fifo_order_without_deadlock}` - `victory-hle::modules::xmem::tests::{affected_range_expands_to_overlapping_views, a_range_read_in_place_never_meets_a_split_view_gap}` - **Hardware profiling needed:** No runtime frame-time or FPS gains are claimed here until measured on real 6 GB hardware. @⁠CIS-C0 — if you are still up for testing builds from #431 on the RTX 2060 6 GB, it would be great to compare: 1. Default startup log (`vram_budget_mb`, `most=64`) and whether `"a draw whose descriptor table found no free slots is dropped"` stays at zero without setting `VICTORY_LATE_WAIT_LISTS=64`. 2. Per-frame `"waiting for title memory to hold still (the runtime remapping it)"` ms during world streaming (previously 75–500 ms), and stability (no access violations in `Staging::refresh_now` / `Layout::detile`). Refs #431
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:46:35 +00:00
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/lib.rs
  • crates/victory-gpu/src/watch.rs
  • crates/victory-hle/src/modules/xmem.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/570/head:github-bot/gh-570'
git switch 'github-bot/gh-570'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-570'
git switch 'github-bot/gh-570'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-570'
git switch 'github-bot/gh-570'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-570'
git switch 'main'
git merge --squash 'github-bot/gh-570'
git switch 'main'
git merge --ff-only 'github-bot/gh-570'
git switch 'main'
git merge 'github-bot/gh-570'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.