gpu, scripts: fix 5s VirtualQuery frame-pacing spikes, glass reflection specks, and 6-core thread sizing #2783

Open
wilderr24 wants to merge 1 commit from upstream-pr/2783 into main
wilderr24 commented 2026-11-29 17:17:16 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by wilderr24 on 2026-11-29T17:17:16Z.


Summary

Three measured runtime and launcher fixes from v2026.11.29.01 release runs on Windows 11 26200 (AMD Ryzen 5 5600 6C/12T, NVIDIA GeForce RTX 5070 12 GB, driver 621.24, 32 GB RAM, Series S + DLSS Quality Preset K + 6x Frame Generation):

  1. crates/victory-gpu/src/procmem.rs — Make the 5-second VirtualQuery full address-space walk diagnostics-only by default (VICTORY_PROCESS_MEMORY=1 to opt in on release):

    • Once the title maps its heaps and streaming pools, the process reaches 87,313–87,650 committed regions.
    • Walking the entire user address space via VirtualQuery every 5 seconds took 1,514–1,607 ms per sweep (n=67, 68) and contended on the Windows process address-space lock with VirtualProtect / write-watch resets on shadow pages.
    • This produced periodic 222.8–271.8 ms p99 frame-time spikes (13.1 <-> 18.6 fps oscillation every ~5 seconds).
    • Defaulting the walk to cfg!(feature = "diagnostics") (with VICTORY_PROCESS_MEMORY=1 still enabling it on release builds and =0 disabling it on diagnostics builds) dropped LONGEST frame time to 88 ms with a flat frametime graph (16.9 native fps / 101.1 fps shown).
  2. crates/victory-gpu/src/draw.rs & scripts/play-foxhound.ps1 — Preserve CS_RayMiss on transparent surfaces (MISS_ALPHA) and align VICTORY_AMBIENT_SPECULAR default:

    • Skipping CS_RayMiss on MISS_ALPHA (layer == MISS_ALPHA) left stale/uninitialised neon-green texels on vehicle rear windows and taillights when ray tracing was off.
    • Restrict sky_miss_left_out (should_skip_sky_miss) to MISS_OPAQUE when !keep && !builder_runs, preserving CS_RayMiss on MISS_ALPHA (matching MISS_WATER) as well as whenever builder_runs() is active.
    • Remove the VICTORY_AMBIENT_SPECULAR = '1' override in scripts/play-foxhound.ps1 so it matches apps/victory/src/play.rs.
  3. scripts/play-foxhound.ps1 & scripts/play-gta6-framegen.ps1 — 6-core / 12-thread CPU sizing and launcher robustness:

    • On >16 GiB RAM hosts, cap VICTORY_PIPELINE_WORKERS to min(12, max(4, ProcessorCount - 8)) so 20/24+ thread CPUs still use 12, 16-thread CPUs use 8, and 6C/12T CPUs use 4 instead of saturating 12/12 logical processors during gameplay.
    • Add < 16 logical processor pool sizing in play-gta6-framegen.ps1 (VICTORY_THIN_THREADS=4, VICTORY_UNDER_THREADS=3, VICTORY_LAND_THREADS=2), reducing preparing time from 87.8 ms (10.4 fps) when over-threaded to 56.8 ms (16.5–18.6 fps).
    • Check victory.toml game_dir in Find-GameDir and guard Get-CimInstance Win32_VideoController with try/catch under $ErrorActionPreference = 'Stop'.

Verification

  • Added unit tests:
    • draw::tests::sky_miss_keeps_transparent_and_water_layers_and_ray_tracing
    • procmem::tests::address_space_walk_is_diagnostics_only_unless_asked_for
  • cargo test --locked -p victory-gpu --lib passes.
  • cargo xtask policy --staged passes (4 files ok).
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5553139439 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2783). Originally posted by [wilderr24](https://github.com/wilderr24) on 2026-11-29T17:17:16Z. --- ### Summary Three measured runtime and launcher fixes from `v2026.11.29.01` release runs on Windows 11 26200 (AMD Ryzen 5 5600 6C/12T, NVIDIA GeForce RTX 5070 12 GB, driver 621.24, 32 GB RAM, Series S + DLSS Quality Preset K + 6x Frame Generation): 1. **`crates/victory-gpu/src/procmem.rs` — Make the 5-second `VirtualQuery` full address-space walk diagnostics-only by default (`VICTORY_PROCESS_MEMORY=1` to opt in on release):** - Once the title maps its heaps and streaming pools, the process reaches **87,313–87,650 committed regions**. - Walking the entire user address space via `VirtualQuery` every 5 seconds took **1,514–1,607 ms** per sweep (`n=67, 68`) and contended on the Windows process address-space lock with `VirtualProtect` / write-watch resets on shadow pages. - This produced periodic **222.8–271.8 ms p99 frame-time spikes** (`13.1 <-> 18.6 fps` oscillation every ~5 seconds). - Defaulting the walk to `cfg!(feature = "diagnostics")` (with `VICTORY_PROCESS_MEMORY=1` still enabling it on release builds and `=0` disabling it on diagnostics builds) dropped `LONGEST` frame time to **88 ms** with a flat frametime graph (**16.9 native fps / 101.1 fps shown**). 2. **`crates/victory-gpu/src/draw.rs` & `scripts/play-foxhound.ps1` — Preserve `CS_RayMiss` on transparent surfaces (`MISS_ALPHA`) and align `VICTORY_AMBIENT_SPECULAR` default:** - Skipping `CS_RayMiss` on `MISS_ALPHA` (`layer == MISS_ALPHA`) left stale/uninitialised neon-green texels on vehicle rear windows and taillights when ray tracing was off. - Restrict `sky_miss_left_out` (`should_skip_sky_miss`) to `MISS_OPAQUE` when `!keep && !builder_runs`, preserving `CS_RayMiss` on `MISS_ALPHA` (matching `MISS_WATER`) as well as whenever `builder_runs()` is active. - Remove the `VICTORY_AMBIENT_SPECULAR = '1'` override in `scripts/play-foxhound.ps1` so it matches `apps/victory/src/play.rs`. 3. **`scripts/play-foxhound.ps1` & `scripts/play-gta6-framegen.ps1` — 6-core / 12-thread CPU sizing and launcher robustness:** - On `>16 GiB` RAM hosts, cap `VICTORY_PIPELINE_WORKERS` to `min(12, max(4, ProcessorCount - 8))` so 20/24+ thread CPUs still use `12`, 16-thread CPUs use `8`, and 6C/12T CPUs use `4` instead of saturating 12/12 logical processors during gameplay. - Add `< 16` logical processor pool sizing in `play-gta6-framegen.ps1` (`VICTORY_THIN_THREADS=4`, `VICTORY_UNDER_THREADS=3`, `VICTORY_LAND_THREADS=2`), reducing `preparing` time from **87.8 ms** (`10.4 fps`) when over-threaded to **56.8 ms** (`16.5–18.6 fps`). - Check `victory.toml` `game_dir` in `Find-GameDir` and guard `Get-CimInstance Win32_VideoController` with `try/catch` under `$ErrorActionPreference = 'Stop'`. ### Verification - Added unit tests: - `draw::tests::sky_miss_keeps_transparent_and_water_layers_and_ray_tracing` - `procmem::tests::address_space_walk_is_diagnostics_only_unless_asked_for` - `cargo test --locked -p victory-gpu --lib` passes. - `cargo xtask policy --staged` passes (`4 files ok`).
dyshay commented 2026-11-29 17:49:06 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dyshay on 2026-11-29T17:49:06Z.


The procmem.rs part of this PR is merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch janus-prs). The draw.rs window part overlaps #2369, which we had already merged, so I left it out. I read the full diff first: no network access, processes, binaries, build or dependency changes. It builds, and the touched crates' CPU tests pass.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7259987599 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2783#issuecomment-7259987599). Originally posted by [dyshay](https://github.com/dyshay) on 2026-11-29T17:49:06Z. --- The `procmem.rs` part of this PR is merged into our fork's integration branch for testing ([dyshay/VIctory-NVIDIA](https://github.com/dyshay/VIctory-NVIDIA/tree/janus-prs), branch `janus-prs`). The `draw.rs` window part overlaps #2369, which we had already merged, so I left it out. I read the full diff first: no network access, processes, binaries, build or dependency changes. It builds, and the touched crates' CPU tests pass.
icdmkg2 commented 2026-11-29 18:20:00 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by icdmkg2 on 2026-11-29T18:20:00Z.


An in-game data point from an 8 GB laptop. It covers this PR together with four others, so it can't attribute the gain to this one alone.

Setup: RTX 5060 Laptop GPU (8 GB), Ryzen 7 H 260 (8 cores), 32 GB, Windows 11, driver 621.24. main at 55d06914, release build, Series S, DLSS performance, VICTORY_LEVELS_ON_DEMAND=0 and VICTORY_COMMIT_FLOOR_MB=1024 in both builds (see #1411 for why). Same save (the prologue's cell), driven by a script: 60 s measured after a 30 s settle, warm shader cache, two alternating pairs.

Combo: main + #2549 + #2783 + #2647 + #2665 + #2795. These merge cleanly together. #2796, #2656, #2604 and #2587 conflict with that set, so they weren't tested.

median frame time frames >50 ms per 5 s submitting thread, ms per frame
main 60.7 / 56.7 ms 15.2 / 15.4 52 / 60
combo 49.3 / 48.6 ms 7.6 / 5.8 47 / 44

That's about 15–18 % shorter frames and half the slow frames, with no crash and no device removal. A frame capture of the combo (diagnostics build, VICTORY_CAPTURE_WORLD) matched main's brightness (mean luma 66.4 against 66.2), with no black holes.

One thing for the diagnostics build: with these merged together, --features diagnostics no longer compiles. A local timing in submit shadows host::timing() at three call sites, and copystat::log_heap_elsewhere uses an mb helper it doesn't define. Both are one-line fixes; mentioning it in case whichever lands second hits it.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7260398182 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2783#issuecomment-7260398182). Originally posted by [icdmkg2](https://github.com/icdmkg2) on 2026-11-29T18:20:00Z. --- An in-game data point from an 8 GB laptop. It covers this PR **together with four others**, so it can't attribute the gain to this one alone. **Setup:** RTX 5060 Laptop GPU (8 GB), Ryzen 7 H 260 (8 cores), 32 GB, Windows 11, driver 621.24. `main` at `55d06914`, release build, Series S, DLSS performance, `VICTORY_LEVELS_ON_DEMAND=0` and `VICTORY_COMMIT_FLOOR_MB=1024` in both builds (see #1411 for why). Same save (the prologue's cell), driven by a script: 60 s measured after a 30 s settle, warm shader cache, two alternating pairs. **Combo:** `main` + #2549 + #2783 + #2647 + #2665 + #2795. These merge cleanly together. #2796, #2656, #2604 and #2587 conflict with that set, so they weren't tested. | | median frame time | frames >50 ms per 5 s | submitting thread, ms per frame | |---|---|---|---| | `main` | 60.7 / 56.7 ms | 15.2 / 15.4 | 52 / 60 | | **combo** | **49.3 / 48.6 ms** | **7.6 / 5.8** | **47 / 44** | That's about 15–18 % shorter frames and half the slow frames, with no crash and no device removal. A frame capture of the combo (diagnostics build, `VICTORY_CAPTURE_WORLD`) matched `main`'s brightness (mean luma 66.4 against 66.2), with no black holes. One thing for the diagnostics build: with these merged together, `--features diagnostics` no longer compiles. A local `timing` in `submit` shadows `host::timing()` at three call sites, and `copystat::log_heap_elsewhere` uses an `mb` helper it doesn't define. Both are one-line fixes; mentioning it in case whichever lands second hits it.
DoubleD17 commented 2026-11-30 04:52:18 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by DoubleD17 on 2026-11-30T04:52:18Z.


We ran a test of the procmem.rs part only, through VICTORY_PROCESS_MEMORY=0 on current main (41adb551), which gives the same release default. We did not test the draw.rs or script changes. We don't see the 222 to 272 ms spikes every 5 s here.

On this machine the walk takes about 1.1 to 1.2 s (at most 1.5 s) over about 103,000 regions, every 5 s, on its own thread.

run with the walk off CPU prep (ms/frame) controls at that point fps (mean) controls at that point
1 65.1 69.2 12.39 11.82
2 59.9 68.5 14.13 11.68
3 62.8 62.7 12.88 12.79
4 63.6 62.7 11.93 12.90
5 61.6 61.3 13.69 12.99

Runs 1 and 2 came from a session whose controls drifted by 9 ms, so they looked like a gain. We ran 3 to 5 in ABBA order with three controls that agreed within 1.4 ms: +0.4 ms and −0.5 %, so no change.

We also split the 1 s frame-time lines of five control runs (walk on) into the seconds that overlap a walk and the others. The seconds during a walk have the same median frame (+0.3 ms) and the same longest frame per second (+0.2 ms, median).

The one place it may show is the rarest hitch. The single worst frame of the run fell during a walk in 4 of the 5 control runs, while only about a third of the seconds overlap a walk. With the walk off, the worst frames were 269 to 284 ms, against 310 to 391 ms in the same session's controls. The p99 did not move (114 to 142 ms both ways). So on an 8-core CPU it does not touch the typical frame; a 6-core CPU may differ.

Picture: 0 defects in 400 frames with the walk off.

Setup:

  • Ryzen 7 5800X (8 cores, 16 threads), RTX 5070 12 GB (DXGI budget 11,175 MB), 64 GB RAM, Windows 11;
  • Series X, 1440p with DLAA (DLSS at native resolution; corrected, this line said DLSS Performance at first), frame generation and ray tracing off;
  • main 41adb551 with VICTORY_PROCESS_MEMORY=0, against 41adb551 without it;
  • 150 s runs: two in a first session with four controls, then three more in ABBA order with three controls;
  • every run starts from the same save, restored before each run;
  • prep is the median of the 5 s host lines, fps the mean; each run is compared with the controls interpolated in time.

AI Assisted

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7269153943 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2783#issuecomment-7269153943). Originally posted by [DoubleD17](https://github.com/DoubleD17) on 2026-11-30T04:52:18Z. --- We ran a test of the `procmem.rs` part only, through `VICTORY_PROCESS_MEMORY=0` on current main (41adb551), which gives the same release default. We did not test the `draw.rs` or script changes. We don't see the 222 to 272 ms spikes every 5 s here. On this machine the walk takes about 1.1 to 1.2 s (at most 1.5 s) over about 103,000 regions, every 5 s, on its own thread. | run with the walk off | CPU prep (ms/frame) | controls at that point | fps (mean) | controls at that point | |---|---|---|---|---| | 1 | 65.1 | 69.2 | 12.39 | 11.82 | | 2 | 59.9 | 68.5 | 14.13 | 11.68 | | 3 | 62.8 | 62.7 | 12.88 | 12.79 | | 4 | 63.6 | 62.7 | 11.93 | 12.90 | | 5 | 61.6 | 61.3 | 13.69 | 12.99 | Runs 1 and 2 came from a session whose controls drifted by 9 ms, so they looked like a gain. We ran 3 to 5 in ABBA order with three controls that agreed within 1.4 ms: **+0.4 ms and −0.5 %**, so no change. We also split the 1 s frame-time lines of five control runs (walk on) into the seconds that overlap a walk and the others. The seconds during a walk have the same median frame (+0.3 ms) and the same longest frame per second (+0.2 ms, median). The one place it may show is the rarest hitch. The single worst frame of the run fell during a walk in 4 of the 5 control runs, while only about a third of the seconds overlap a walk. With the walk off, the worst frames were 269 to 284 ms, against 310 to 391 ms in the same session's controls. The p99 did not move (114 to 142 ms both ways). So on an 8-core CPU it does not touch the typical frame; a 6-core CPU may differ. **Picture:** 0 defects in 400 frames with the walk off. **Setup:** - Ryzen 7 5800X (8 cores, 16 threads), RTX 5070 12 GB (DXGI budget 11,175 MB), 64 GB RAM, Windows 11; - Series X, 1440p with DLAA (DLSS at native resolution; corrected, this line said DLSS Performance at first), frame generation and ray tracing off; - main 41adb551 with `VICTORY_PROCESS_MEMORY=0`, against 41adb551 without it; - 150 s runs: two in a first session with four controls, then three more in ABBA order with three controls; - every run starts from the same save, restored before each run; - prep is the median of the 5 s host lines, fps the mean; each run is compared with the controls interpolated in time. AI Assisted
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/2783:upstream-pr/2783'
git switch 'upstream-pr/2783'

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