GPU: a refresh takes the whole pages it touches #3289

Open
github-bot wants to merge 2 commits from github-bot/gh-3289 into main AGit
Owner

@⁠QalityDev on GitHub · 2026-11-26 16:02 UTC · original
QalityDev:pr/refresh-whole-pages → main · +138 −2 · 3 files · 2 commits · open

A refresh of a range that cuts a 64 KiB page copied that part and left the page changed (Tracked::take), so every later refresh reaching it copied it again, whether or not the title had written it since. GTA VI refreshes small ranges inside its 174 MB GPU-heap buffer dozens of times per frame: on an RTX 4060 Ti, 410-550 MB of the 550-690 MB copied per frame came from such partial pages.

Shadow::update now widens the range to the whole pages it touches (cut to the copy). Taken whole, a page is guarded and copied again only once the title writes it. Ranges whose shaders' writes stay in the copy (keep_writes) are remembered and the widening stops short of them; ranges shaders are writing still go through the busy split. This generalises what #2172 does for marked UAV refreshes to every refresh.

Measured in the intro cutscene (diagnostics build):

  • before: copies 290-395 ms, 550-690 MB per frame; 700-730 ms/frame
  • after: copies 69-108 ms, 73-120 MB per frame; 380-445 ms/frame

New test a_partial_refresh_takes_the_whole_page; the copy-stats line reports bytes taken from whole and partial pages. On main 63bcca4: victory-gpu lib tests 230 passed (dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views fail on main as well on this RTX 4060 Ti); clippy clean with and without diagnostics.

**@⁠QalityDev** on GitHub · 2026-11-26 16:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/3289) `QalityDev:pr/refresh-whole-pages` → `main` · +138 −2 · 3 files · 2 commits · open A refresh of a range that cuts a 64 KiB page copied that part and left the page changed (`Tracked::take`), so every later refresh reaching it copied it again, whether or not the title had written it since. GTA VI refreshes small ranges inside its 174 MB GPU-heap buffer dozens of times per frame: on an RTX 4060 Ti, 410-550 MB of the 550-690 MB copied per frame came from such partial pages. `Shadow::update` now widens the range to the whole pages it touches (cut to the copy). Taken whole, a page is guarded and copied again only once the title writes it. Ranges whose shaders' writes stay in the copy (`keep_writes`) are remembered and the widening stops short of them; ranges shaders are writing still go through the busy split. This generalises what #2172 does for marked UAV refreshes to every refresh. Measured in the intro cutscene (diagnostics build): - before: copies 290-395 ms, 550-690 MB per frame; 700-730 ms/frame - after: copies 69-108 ms, 73-120 MB per frame; 380-445 ms/frame New test `a_partial_refresh_takes_the_whole_page`; the copy-stats line reports bytes taken from whole and partial pages. On main 63bcca4: victory-gpu lib tests 230 passed (`dynamic_slots_are_held_until_released` and `lists_share_a_table_and_copies_keep_their_views` fail on main as well on this RTX 4060 Ti); clippy clean with and without `diagnostics`.
A refresh of a range that cuts a 64 KiB page copied that part and left
the page changed (`Tracked::take`), so every later refresh reaching it
copied it again, whether or not the title had written it since. The
world refreshes small ranges inside the title's 174 MB GPU-heap buffer
dozens of times per frame: on an RTX 4060 Ti, 410-550 MB of the
550-690 MB copied per frame came from such partial pages, against
100-140 MB from pages taken whole.

`Shadow::update` now widens the range to the pages it touches (cut to
the copy). Taken whole, a page is guarded and copied again only once
the title writes it. Ranges whose shaders' writes stay in the copy
(`keep_writes`) are remembered and the widening stops short of them;
ranges shaders are writing go through the existing busy split.

Measured in the intro cutscene (diagnostics build, the four heaviest
compute pipelines skipped to isolate CPU preparation):

  before: copies 290-395 ms, 550-690 MB per frame; 700-730 ms/frame
  after:  copies  69-108 ms,  73-120 MB per frame; 380-445 ms/frame

Diagnostics: the copy-stats line reports bytes taken from whole and
partial pages. New test `a_partial_refresh_takes_the_whole_page`;
On main 63bcca4: victory-gpu lib tests 230 passed (the two that fail,
dynamic_slots_are_held_until_released and
lists_share_a_table_and_copies_keep_their_views, fail on main as well
on this RTX 4060 Ti); clippy clean with and without `diagnostics`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 16:04:28 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 16:08 UTC · original · approved these changes

Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090):

  • Widening tracked refreshes in Shadow::widen to 64 KiB page boundaries (clamped to the buffer and stopping short of Shadow::kept ranges, with busy ranges still subtracted afterward) cleanly lets touched pages be taken whole and guarded instead of repeatedly re-copying partial pages, with TakenWholeBytes/TakenPartBytes diagnostics counters matching.
  • cargo test -p victory-gpu --lib shadow:: -- --test-threads=1 (RTX 5090): 11 passed, 0 failed (including a_partial_refresh_takes_the_whole_page).
  • cargo test -p victory-gpu --lib draw:: -- --test-threads=1 (RTX 5090): 20 passed, 0 failed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo clippy -p victory-gpu --features diagnostics --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 16:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/3289#pullrequestreview-6077279448) · **approved these changes** Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090): - Widening tracked refreshes in `Shadow::widen` to 64 KiB page boundaries (clamped to the buffer and stopping short of `Shadow::kept` ranges, with `busy` ranges still subtracted afterward) cleanly lets touched pages be taken whole and guarded instead of repeatedly re-copying partial pages, with `TakenWholeBytes`/`TakenPartBytes` diagnostics counters matching. - `cargo test -p victory-gpu --lib shadow:: -- --test-threads=1` (RTX 5090): 11 passed, 0 failed (including `a_partial_refresh_takes_the_whole_page`). - `cargo test -p victory-gpu --lib draw:: -- --test-threads=1` (RTX 5090): 20 passed, 0 failed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo clippy -p victory-gpu --features diagnostics --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠oni-swr on GitHub · 2026-11-26 16:42 UTC · original

WARP verification report (test report only, no code changes)

  • PR head: d99e868f
  • main: 63bcca43 (control); WARP software adapter forced with VICTORY_WARP=1 VICTORY_D3D12_WARP=1, --features diagnostics, d3d10warp.dll 10.0.26100.9818; dxil.dll 1.8.2502.11 (Windows Kit 10.0.26100.0, via VICTORY_DXIL). No physical GPU. Synthetic tests only, no game data.
  • Commands: cargo test -p victory-gpu --lib --features diagnostics --no-run -j 4, then the test binary with --exact <name> --test-threads 1 per test, then the whole lib suite.
  • New test shadow::tests::a_partial_refresh_takes_the_whole_page: passes on the PR (1 passed, 0.22 s).
  • Control: main plus only this test added (no source change). It fails on main at the written page, whole (left 16, right 65536): the refresh copies the 16 bytes asked for, not the page.
  • victory-gpu lib suite: PR 246 passed, 1 failed, 1 ignored; main plus the test 245 passed, 2 failed, 1 ignored (the new test and the failure below).
  • The one failure on both is frame::tests::waits_end_on_ticks_and_count_frames (left: 0, right: 1 at frame.rs:231). It also fails alone in its own process on the PR and on main, so it is not caused by this PR.
  • Not tested: physical GPU.

AI use: Claude Code (Claude Sonnet 5.5)

**@⁠oni-swr** on GitHub · 2026-11-26 16:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/3289#issuecomment-7197994600) WARP verification report (test report only, no code changes) - PR head: `d99e868f` - main: `63bcca43` (control); WARP software adapter forced with `VICTORY_WARP=1 VICTORY_D3D12_WARP=1`, `--features diagnostics`, d3d10warp.dll 10.0.26100.9818; dxil.dll 1.8.2502.11 (Windows Kit 10.0.26100.0, via `VICTORY_DXIL`). No physical GPU. Synthetic tests only, no game data. - Commands: `cargo test -p victory-gpu --lib --features diagnostics --no-run -j 4`, then the test binary with `--exact <name> --test-threads 1` per test, then the whole lib suite. - New test `shadow::tests::a_partial_refresh_takes_the_whole_page`: **passes on the PR** (1 passed, 0.22 s). - Control: main plus only this test added (no source change). It **fails on main** at `the written page, whole` (left 16, right 65536): the refresh copies the 16 bytes asked for, not the page. - `victory-gpu` lib suite: PR 246 passed, 1 failed, 1 ignored; main plus the test 245 passed, 2 failed, 1 ignored (the new test and the failure below). - The one failure on both is `frame::tests::waits_end_on_ticks_and_count_frames` (`left: 0, right: 1` at frame.rs:231). It also fails alone in its own process on the PR and on main, so it is not caused by this PR. - Not tested: physical GPU. AI use: Claude Code (Claude Sonnet 5.5)
Author
Owner

@⁠Venom2054 on GitHub · 2026-11-26 17:17 UTC · original

I tested a port of d99e868 on an RTX 5070 Ti with a tuned Series S profile. Two fresh launches used the same executable, save and warmed pipeline library. Only whole-page refresh changed. The port avoids widening across ranges previously written by a GPU shader because this fork can retain those writes.

At the stationary prison window, median copy volume fell from 75.0 to 55.4 MB per frame. The partial-page counter fell from 26.72 to 0.03 MB per frame. Write-watch time fell from 27.51 to 23.28 ms with 2,251 and 2,271 queries per frame, respectively. The runs issued 4,424 and 4,488 draws per frame.

Seven complete presentation batches per run covered 35.3 and 35.4 seconds. Presentation rate rose from 9.88 to 11.35 FPS (349 and 402 presents). Median frame time went from 101 to 85 ms and p90 from 142 to 120 ms. This is one pair of launches. A separate in-process toggle reproduced the reduction in copy volume. Disabling the change did not immediately restore the original volume because already refreshed pages stayed current.

Codex assisted with the port and measurements.

**@⁠Venom2054** on GitHub · 2026-11-26 17:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/3289#issuecomment-7198768178) I tested a port of `d99e868` on an RTX 5070 Ti with a tuned Series S profile. Two fresh launches used the same executable, save and warmed pipeline library. Only whole-page refresh changed. The port avoids widening across ranges previously written by a GPU shader because this fork can retain those writes. At the stationary prison window, median copy volume fell from 75.0 to 55.4 MB per frame. The partial-page counter fell from 26.72 to 0.03 MB per frame. Write-watch time fell from 27.51 to 23.28 ms with 2,251 and 2,271 queries per frame, respectively. The runs issued 4,424 and 4,488 draws per frame. Seven complete presentation batches per run covered 35.3 and 35.4 seconds. Presentation rate rose from 9.88 to 11.35 FPS (349 and 402 presents). Median frame time went from 101 to 85 ms and p90 from 142 to 120 ms. This is one pair of launches. A separate in-process toggle reproduced the reduction in copy volume. Disabling the change did not immediately restore the original volume because already refreshed pages stayed current. Codex assisted with the port and measurements.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 17:21 UTC · original

I checked a scaling case for the kept-write lookup on d99e868. Repeated overlapping declarations kept 131 entries for two disjoint regions, and widen walked the full set for each refresh. Follow-up 6d3e953 keeps the union of overlapping and adjacent ranges. Each lookup uses the nearest kept ranges to find the same boundaries.

The new regression gets two records, preserves both clipping boundaries, and keeps a request that overlaps a GPU write narrow. The original WARP kept-texel and whole-page tests pass. Full diagnostics on verified app-local Agility 1.620.2/WARP 1.0.22 had 249 passed, 0 failed, 1 ignored, including runtime identity. Strict Clippy in both configurations and asset policy passed.

I also built an optimized isolated benchmark from the two exact widen implementations. It first checked 2,500 mixed overlap insertions/lookups and 16,384 matching lookup results per disjoint-set size, then alternated nine timed runs. Median lookup time stayed at 19 ns with zero kept regions, went from 215 to 101 ns with 64 disjoint regions, and from 12.8 to 0.163 microseconds with 4,096. These are CPU lookup timings on synthetic ranges; a title trace would show how often a real buffer reaches those counts.

@⁠QalityDev this is one commit directly on your head if the follow-up fits. Please retain its Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding it into another commit. AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 17:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/3289#issuecomment-7198883376) I checked a scaling case for the kept-write lookup on `d99e868`. Repeated overlapping declarations kept 131 entries for two disjoint regions, and `widen` walked the full set for each refresh. [Follow-up `6d3e953`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/6d3e9539f2765ed187f62f1db4cc29357a2a506c) keeps the union of overlapping and adjacent ranges. Each lookup uses the nearest kept ranges to find the same boundaries. The new regression gets two records, preserves both clipping boundaries, and keeps a request that overlaps a GPU write narrow. The original WARP kept-texel and whole-page tests pass. Full diagnostics on verified app-local Agility 1.620.2/WARP 1.0.22 had 249 passed, 0 failed, 1 ignored, including runtime identity. Strict Clippy in both configurations and asset policy passed. I also built an optimized isolated benchmark from the two exact `widen` implementations. It first checked 2,500 mixed overlap insertions/lookups and 16,384 matching lookup results per disjoint-set size, then alternated nine timed runs. Median lookup time stayed at 19 ns with zero kept regions, went from 215 to 101 ns with 64 disjoint regions, and from 12.8 to 0.163 microseconds with 4,096. These are CPU lookup timings on synthetic ranges; a title trace would show how often a real buffer reaches those counts. @⁠QalityDev this is one commit directly on your head if the follow-up fits. Please retain its Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding it into another commit. AI-assisted with Codex.
Author
Owner

@⁠QalityDev on GitHub · 2026-11-26 18:14 UTC · original

Thanks @⁠andrewpozdnakov7-jpg — reviewed and added as-is: 6d3e953 is now on the branch with your authorship. Checked here on an RTX 4060 Ti: shadow::/watch:: tests 27 passed (including overlapping_kept_writes_remember_their_union), strict Clippy clean with and without diagnostics.

**@⁠QalityDev** on GitHub · 2026-11-26 18:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/3289#issuecomment-7200221371) Thanks @⁠andrewpozdnakov7-jpg — reviewed and added as-is: 6d3e953 is now on the branch with your authorship. Checked here on an RTX 4060 Ti: `shadow::`/`watch::` tests 27 passed (including `overlapping_kept_writes_remember_their_union`), strict Clippy clean with and without `diagnostics`.
Author
Owner

@⁠borosf on GitHub · 2026-11-26 19:03 UTC · original

Independent local verification on Windows 11 x64, Intel Arc B580 12 GB (12 cores), at this PR's head 6d3e953:

cargo test -p victory-gpu --lib --locked --no-fail-fast -- --test-threads=1
cargo clippy -p victory-gpu --all-targets --locked -- -D warnings
cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings

Result: victory-gpu lib: 2 known baseline failures only; the new a_partial_refresh_takes_the_whole_page test passed.

Both clippy runs exit 0 (-D warnings, both feature sets). The B580 baseline failures pristine main also hits are: victory-gpu descriptor::host::tests::dynamic_slots_are_held_until_released + memory::tests::lists_share_a_table_and_copies_keep_their_views (#1744/#1829); victory-shader emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros + emit::valu_tests::fspx_programs_run_with_the_hardwares_dot_products. No PR regressions.

Synthetic tests only; no game data used. Full log kept locally. — borosf

**@⁠borosf** on GitHub · 2026-11-26 19:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/3289#issuecomment-7201151389) Independent local verification on Windows 11 x64, Intel Arc B580 12 GB (12 cores), at this PR's head `6d3e953`: ``` cargo test -p victory-gpu --lib --locked --no-fail-fast -- --test-threads=1 cargo clippy -p victory-gpu --all-targets --locked -- -D warnings cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings ``` Result: victory-gpu lib: 2 known baseline failures only; the new a_partial_refresh_takes_the_whole_page test passed. Both clippy runs exit 0 (-D warnings, both feature sets). The B580 baseline failures pristine main also hits are: victory-gpu descriptor::host::tests::dynamic_slots_are_held_until_released + memory::tests::lists_share_a_table_and_copies_keep_their_views (#1744/#1829); victory-shader emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros + emit::valu_tests::fspx_programs_run_with_the_hardwares_dot_products. No PR regressions. Synthetic tests only; no game data used. Full log kept locally. — borosf
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3289'
git switch 'github-bot/gh-3289'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3289'
git switch 'github-bot/gh-3289'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3289'
git switch 'main'
git merge --squash 'github-bot/gh-3289'
git switch 'main'
git merge --ff-only 'github-bot/gh-3289'
git switch 'main'
git merge 'github-bot/gh-3289'
git push origin 'main'
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/Marvisak--VIctory!3289
No description provided.