GPU: reuse unchanged page checks across shadow copy-back ranges #124

Closed
TG0000 wants to merge 1 commit from upstream-pr/124 into main
TG0000 commented 2026-11-24 00:42:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by TG0000 on 2026-11-24T00:42:02Z.


Summary

GPU buffer copy-back compares each declared write range with the pre-submission snapshot. Distinct ranges can cover many of the same pages. This change remembers fully compared unchanged 64 KiB pages until the snapshot is released. Changed pages and unchecked parts of pages still go through the existing comparison and write-back path.

Synthetic release benchmark

On Windows MSVC with a Ryzen 9 5900X, the median of five CPU comparison runs dropped from 269.9 ms to 12.6 ms (21.5×). The fixture generates 24 distinct overlapping ranges across 128 MiB and changes one byte on every 64th page. Both paths report the same changed-page count. In-game frame time remains unmeasured.

cargo +stable-x86_64-pc-windows-msvc test --release -p victory-gpu benchmark_overlapping_copy_back -- --ignored --nocapture

Verification

  • cargo +stable-x86_64-pc-windows-msvc test --workspace (258 passed, four ignored by default)
  • cargo +stable-x86_64-pc-windows-msvc clippy --workspace --all-targets (existing warnings)
  • cargo +stable-x86_64-pc-windows-msvc xtask policy (151 files passed)

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6571948636 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/124). Originally posted by [TG0000](https://github.com/TG0000) on 2026-11-24T00:42:02Z. --- ## Summary GPU buffer copy-back compares each declared write range with the pre-submission snapshot. Distinct ranges can cover many of the same pages. This change remembers fully compared unchanged 64 KiB pages until the snapshot is released. Changed pages and unchecked parts of pages still go through the existing comparison and write-back path. ## Synthetic release benchmark On Windows MSVC with a Ryzen 9 5900X, the median of five CPU comparison runs dropped from 269.9 ms to 12.6 ms (21.5×). The fixture generates 24 distinct overlapping ranges across 128 MiB and changes one byte on every 64th page. Both paths report the same changed-page count. In-game frame time remains unmeasured. ```powershell cargo +stable-x86_64-pc-windows-msvc test --release -p victory-gpu benchmark_overlapping_copy_back -- --ignored --nocapture ``` ## Verification - `cargo +stable-x86_64-pc-windows-msvc test --workspace` (258 passed, four ignored by default) - `cargo +stable-x86_64-pc-windows-msvc clippy --workspace --all-targets` (existing warnings) - `cargo +stable-x86_64-pc-windows-msvc xtask policy` (151 files passed) AI-assisted.
DaviTostes commented 2026-11-24 06:54:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T00:52:02Z.


Tested a6deb46 under Wine 11.22 + vkd3d-proton 3.1 on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with cargo xwin ... --target x86_64-pc-windows-msvc: pass, no regression.

  • victory_gpu: 40 passed, 3 failed, 1 ignored — this PR adds 4 tests and they pass.
  • The 3 failures are the environment-only ones from main (argument_clamp_builds, a_rejected_blob_gives_an_empty_library, #128's VirtualQuery upload skip). Note the last one goes through the same shadow copy-back path this PR optimises, so if it is ever fixed (#128), re-running here would exercise the new reuse path end to end.
  • shadow::tests::benchmark_overlapping_copy_back stays ignored (synthetic CPU benchmark).

No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7118517296 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/124#issuecomment-7118517296). Originally posted by [DaviTostes](https://github.com/DaviTostes) on 2026-11-24T00:52:02Z. --- Tested `a6deb46` under **Wine 11.22 + vkd3d-proton 3.1** on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with `cargo xwin ... --target x86_64-pc-windows-msvc`: **pass, no regression**. - `victory_gpu`: **40 passed, 3 failed, 1 ignored** — this PR adds 4 tests and they pass. - The 3 failures are the environment-only ones from `main` (`argument_clamp_builds`, `a_rejected_blob_gives_an_empty_library`, #128's `VirtualQuery` upload skip). Note the last one goes through the same shadow copy-back path this PR optimises, so if it is ever fixed (#128), re-running here would exercise the new reuse path end to end. - `shadow::tests::benchmark_overlapping_copy_back` stays ignored (synthetic CPU benchmark). No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
KevinPratap commented 2026-11-24 14:04:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by KevinPratap on 2026-11-24T13:27:12Z.


Measured in the world on an RTX 4050 Laptop (Windows 11, title 1.0.2.1, diagnostics build of an integration branch with per-page snapshots, scripted input): the same idea, a page that copy-back already went over in this submission is skipped by later ranges, took copying back from 1.1-4.2 s to about 0.2 s per frame, and world frames from 9-13 s to about 1 s.

Before it, stack samples of world frames found the submitting thread in copy_back's comparison in 12 of 17 samples. The world declares dozens of overlapping views of the 174 MB heap per submission, so each page was compared once per declared range.

On that branch the snapshot is per page, so the mark is a done submission number on each page's snapshot. Any write to the snapshot resets it, and it counts only when the whole snapshot part of the page was gone over.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7132850157 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/124#issuecomment-7132850157). Originally posted by [KevinPratap](https://github.com/KevinPratap) on 2026-11-24T13:27:12Z. --- Measured in the world on an RTX 4050 Laptop (Windows 11, title 1.0.2.1, diagnostics build of an integration branch with per-page snapshots, scripted input): the same idea, a page that copy-back already went over in this submission is skipped by later ranges, took **copying back from 1.1-4.2 s to about 0.2 s per frame**, and world frames from 9-13 s to about 1 s. Before it, stack samples of world frames found the submitting thread in `copy_back`'s comparison in 12 of 17 samples. The world declares dozens of overlapping views of the 174 MB heap per submission, so each page was compared once per declared range. On that branch the snapshot is per page, so the mark is a `done` submission number on each page's snapshot. Any write to the snapshot resets it, and it counts only when the whole snapshot part of the page was gone over. AI-assisted.
Yaekai commented 2026-11-24 17:04:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Yaekai on 2026-11-24T16:20:58Z.


Independent verification on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head a6deb46:

  • cargo test -p victory-gpu --lib: 43 passed, 0 failed.
  • cargo clippy -p victory-gpu -- -D warnings: 0 warnings.
  • Live GTA VI (1.0.2.1, --console series-s, 19-min world run): verified shadow copy-back page-check reuse with zero corruption or stalls. Ready to merge!
<!-- greyfinch-sync:Marvisak/VIctory:comment:7137522094 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/124#issuecomment-7137522094). Originally posted by [Yaekai](https://github.com/Yaekai) on 2026-11-24T16:20:58Z. --- Independent verification on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head `a6deb46`: - `cargo test -p victory-gpu --lib`: 43 passed, 0 failed. - `cargo clippy -p victory-gpu -- -D warnings`: 0 warnings. - Live GTA VI (`1.0.2.1`, `--console series-s`, 19-min world run): verified shadow copy-back page-check reuse with zero corruption or stalls. Ready to merge!
TG0000 commented 2026-11-24 17:04:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by TG0000 on 2026-11-24T16:30:54Z.


Thanks for testing it in a long world run on another GPU vendor, that is the case I could not cover on an RX 6800.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137784716 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/124#issuecomment-7137784716). Originally posted by [TG0000](https://github.com/TG0000) on 2026-11-24T16:30:54Z. --- Thanks for testing it in a long world run on another GPU vendor, that is the case I could not cover on an RX 6800. _AI-assisted (Claude Code)._
upstream-sync closed this pull request 2026-11-24 23:03:54 +00:00

Pull request closed

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
Marvisak/VIctory!124
No description provided.