gpu: clip write-combined subranges from mixed copy-backs (VICTORY_WC_SUBRANGE_NO_BACK) #4998

Open
danielibabet wants to merge 1 commit from upstream-pr/4998 into main
danielibabet commented 2026-12-01 17:01:58 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by danielibabet on 2026-12-01T17:01:58Z.


Summary

  • Add VICTORY_WC_SUBRANGE_NO_BACK=1 (opt-in, off by default) to clip write-combined sub-ranges out of Shadow::gpu_writes and Shadow::shader_writes on mixed copies (copies that span both write-combined and non-write-combined title memory, such as large graphics pools).
  • Leave whole-copy VICTORY_WC_NO_BACK behavior completely untouched.
  • Track WRITE_COMBINED_BOUNDS (AtomicU64) on title_memory_write_combined / write_combined_freed for a lock-free, zero-allocation fast path when a write declaration does not overlap any write-combined region.
  • Record skipped WC sub-ranges via note_batch_write and WC_LEFT, and compose cleanly with VICTORY_GPU_RO_SKIP on remaining non-WC sub-ranges in shader_writes.
  • Surface VICTORY_WC_SUBRANGE_NO_BACK in say_separation_switches (host.rs) and add unit tests (split_wc_subranges_handles_disjoint_overlapping_and_mixed_ranges, wc_subranges_track_title_memory_write_combined_and_freed).

Verification

  • cargo test --locked -p victory-gpu --lib -j 16 -- shadow::: 86 passed, 0 failed, 6 ignored.
  • cargo clippy --workspace --all-targets --locked -j 16 (default & --all-features, ignoring pre-existing origin/main lints in host/{font,menu,panel}.rs): passed.
  • cargo xtask policy: asset policy: 464 files ok.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5590483844 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4998). Originally posted by [danielibabet](https://github.com/danielibabet) on 2026-12-01T17:01:58Z. --- ## Summary - Add `VICTORY_WC_SUBRANGE_NO_BACK=1` (opt-in, off by default) to clip write-combined sub-ranges out of `Shadow::gpu_writes` and `Shadow::shader_writes` on mixed copies (copies that span both write-combined and non-write-combined title memory, such as large graphics pools). - Leave whole-copy `VICTORY_WC_NO_BACK` behavior completely untouched. - Track `WRITE_COMBINED_BOUNDS` (`AtomicU64`) on `title_memory_write_combined` / `write_combined_freed` for a lock-free, zero-allocation fast path when a write declaration does not overlap any write-combined region. - Record skipped WC sub-ranges via `note_batch_write` and `WC_LEFT`, and compose cleanly with `VICTORY_GPU_RO_SKIP` on remaining non-WC sub-ranges in `shader_writes`. - Surface `VICTORY_WC_SUBRANGE_NO_BACK` in `say_separation_switches` (`host.rs`) and add unit tests (`split_wc_subranges_handles_disjoint_overlapping_and_mixed_ranges`, `wc_subranges_track_title_memory_write_combined_and_freed`). ## Verification - `cargo test --locked -p victory-gpu --lib -j 16 -- shadow::`: 86 passed, 0 failed, 6 ignored. - `cargo clippy --workspace --all-targets --locked -j 16` (default & `--all-features`, ignoring pre-existing `origin/main` lints in `host/{font,menu,panel}.rs`): passed. - `cargo xtask policy`: `asset policy: 464 files ok`.
cloph-dsp commented 2026-12-01 17:25:37 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by cloph-dsp on 2026-12-01T17:25:37Z.


Verification (independent, AI-assisted: Hy4 flash). Windows, Rust 1.100.0 (Scoop rust-msvc), MSVC, commit-scoped shallow worktree.

Base 5fabb46eaf6ed8771321787f8871051abde69b9b, head e4cb0e4ed763aea6a4192db29e1f988514220f55. git diff --numstat → host.rs 1/0, shadow.rs 224/1.

Both tests are new on the base (git grep -F <name> 5fabb46e -- . → no match, exit 1):
shadow::gpu_readonly_tests::split_wc_subranges_handles_disjoint_overlapping_and_mixed_ranges and
shadow::gpu_readonly_tests::wc_subranges_track_title_memory_write_combined_and_freed.

git diff --check "5fabb46e..e4cb0e4e" → no output, exit 0.

$env:CARGO_TARGET_DIR='D:\Victory-Contrib\NVIDIA-Contrib\target-4998'
cargo test --locked -p victory-gpu --lib -- shadow::gpu_readonly_tests::split_wc_subranges_handles_disjoint_overlapping_and_mixed_ranges --exact --test-threads=1 --quiet
cargo test --locked -p victory-gpu --lib -- shadow::gpu_readonly_tests::wc_subranges_track_title_memory_write_combined_and_freed --exact --test-threads=1 --quiet

Result, each: running 1 test, test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1162 filtered out.

Worth noting what the tests actually pin, since it is arithmetic only: the first is a split_wc_subranges_in case over a mixed span 0x8000..0x68000 with overlapping write-combined intervals 0x30000..0x50000 and 0x40000..0x60000, expecting the merged interval out and the non-WC parts back; the second registers two ranges via title_memory_write_combined, checks is_write_combined on a covered and an uncovered address, checks the three-way split, then frees the first range with write_combined_freed(.., 0) and expects the merged 0x10000..0x50000 span. Synthetic addresses only, no title memory mapped, no device; GPU/driver N/A. No game data.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7319280006 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4998#issuecomment-7319280006). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-12-01T17:25:37Z. --- Verification (independent, AI-assisted: Hy4 flash). Windows, Rust 1.100.0 (Scoop rust-msvc), MSVC, commit-scoped shallow worktree. Base `5fabb46eaf6ed8771321787f8871051abde69b9b`, head `e4cb0e4ed763aea6a4192db29e1f988514220f55`. `git diff --numstat` → host.rs 1/0, shadow.rs 224/1. Both tests are new on the base (`git grep -F <name> 5fabb46e -- .` → no match, exit 1): `shadow::gpu_readonly_tests::split_wc_subranges_handles_disjoint_overlapping_and_mixed_ranges` and `shadow::gpu_readonly_tests::wc_subranges_track_title_memory_write_combined_and_freed`. `git diff --check "5fabb46e..e4cb0e4e"` → no output, exit 0. ``` $env:CARGO_TARGET_DIR='D:\Victory-Contrib\NVIDIA-Contrib\target-4998' cargo test --locked -p victory-gpu --lib -- shadow::gpu_readonly_tests::split_wc_subranges_handles_disjoint_overlapping_and_mixed_ranges --exact --test-threads=1 --quiet cargo test --locked -p victory-gpu --lib -- shadow::gpu_readonly_tests::wc_subranges_track_title_memory_write_combined_and_freed --exact --test-threads=1 --quiet ``` Result, each: `running 1 test`, `test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1162 filtered out`. Worth noting what the tests actually pin, since it is arithmetic only: the first is a `split_wc_subranges_in` case over a mixed span 0x8000..0x68000 with overlapping write-combined intervals 0x30000..0x50000 and 0x40000..0x60000, expecting the merged interval out and the non-WC parts back; the second registers two ranges via `title_memory_write_combined`, checks `is_write_combined` on a covered and an uncovered address, checks the three-way split, then frees the first range with `write_combined_freed(.., 0)` and expects the merged 0x10000..0x50000 span. Synthetic addresses only, no title memory mapped, no device; GPU/driver N/A. No game data.
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/4998:upstream-pr/4998'
git switch 'upstream-pr/4998'

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