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

Open
BE29ZZ wants to merge 7 commits from upstream-pr/570 into main
BE29ZZ commented 2026-11-25 02:18:00 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by BE29ZZ on 2026-11-25T02:18:00Z.


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

<!-- greyfinch-sync:fxceless/victory-fork:issue:6595642176 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/570). Originally posted by [BE29ZZ](https://github.com/BE29ZZ) on 2026-11-25T02:18:00Z. --- ## 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
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/570:upstream-pr/570'
git switch 'upstream-pr/570'

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/570'
git switch 'upstream-pr/570'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/570'
git switch 'upstream-pr/570'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/570'
git switch 'main'
git merge --squash 'upstream-pr/570'
git switch 'main'
git merge --ff-only 'upstream-pr/570'
git switch 'main'
git merge 'upstream-pr/570'
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
fxceless/victory-fork!570
No description provided.