[pr-fix] GPU: a write-combined commit inside a plain reservation is forgotten with the reservation #481

Open
Indy2l wants to merge 1 commit from upstream-pr/481 into main
Indy2l commented 2026-11-30 21:20:03 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by Indy2l on 2026-11-30T21:20:03Z.


Related: #462

What it changes

When the title releases an allocation, title_memory_freed gets length 0, and write_combined_freed with length 0 only drops a write-combined region that starts at the allocation's base. A write-combined commit inside a reservation that was made without write-combining starts further in, so it stays registered after the release. Memory the title later gets at that address is then still treated as write-combined, and shader writes to it stay on the card.

The fix works out the released allocation's whole extent and forgets every write-combined region over it, as the code already does for other lengths.

Kal0s-design found this during the review of #462 and wrote the test. cafeoh wrote the fix there (320d657b, on the line main used before #468). This is the same change on the current main, with cafeoh as the commit's author and Kal0s-design as co-author, at cafeoh's request on #462. cafeoh confirmed there that the current main still has the bug.

How it was tested

  • Graphics card, RAM, and profile: RTX 3060 12 GB, 16 GB RAM, i5-12400F. This is a bookkeeping fix with a unit test; no game run, so no before/after frame rate is claimed.
  • Before: a_write_combined_commit_goes_with_its_reservation (crates/vice-tay-gpu/src/shadow.rs) fails without the watch.rs change: the region is still write-combined after the reservation's release ("stale after the reservation's release").
  • After: the test passes.
  • For shader changes, the wave sizes tested: no shader change.
  • cargo test passed for the crates it touches: yes, apart from one test that fails on main as well. cargo test --locked -p vice-tay-gpu: 923 passed, 3 failed while a GPU-heavy job ran on the same card (watch::tests::ask_rest_falls_back_per_piece_when_touching_unwatched_neighbour and two texback GPU tests); each passes when run on its own. cargo test --locked -p vice-tay-gpu --all-features -- --test-threads=1: 1,010 passed, 1 failed, compose::tests::bgrx_plane_selects_a_typed_view (compose.rs:584), which fails the same way on main at 206e07b4 without this change.

Also run: cargo clippy --locked -p vice-tay-gpu --all-targets -- -D warnings, with and without --all-features (no warnings from the code; the only warning is the unknown clippy::chunks_exact_to_as_chunks lint the build's flags allow); cargo run --locked -p xtask -- policy (426 files ok); git diff --check (clean).

Nobody has checked whether GTA VI itself commits write-combined memory inside a plain reservation (cafeoh noted the same on #462), so this fixes a defect the test shows, not a visible problem in the game.

Has this been tried here before?

Yes, on the previous line: cafeoh committed it as 320d657b on #462's branch, and that PR was closed with every other PR against the old main (#468), so the fix never reached the current main. Nothing is different except that it is rebuilt on the current main.

  • I searched the open pull requests for the same issue and for the files this touches. Related: #462

AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:TaynanGT/Vice-Tay:issue:5573965788 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/481). Originally posted by [Indy2l](https://github.com/Indy2l) on 2026-11-30T21:20:03Z. --- Related: #462 ## What it changes When the title releases an allocation, `title_memory_freed` gets length 0, and `write_combined_freed` with length 0 only drops a write-combined region that starts at the allocation's base. A write-combined commit inside a reservation that was made without write-combining starts further in, so it stays registered after the release. Memory the title later gets at that address is then still treated as write-combined, and shader writes to it stay on the card. The fix works out the released allocation's whole extent and forgets every write-combined region over it, as the code already does for other lengths. Kal0s-design found this during the review of #462 and wrote the test. cafeoh wrote the fix there (320d657b, on the line `main` used before #468). This is the same change on the current `main`, with cafeoh as the commit's author and Kal0s-design as co-author, at cafeoh's request on #462. cafeoh confirmed there that the current `main` still has the bug. ## How it was tested - Graphics card, RAM, and profile: RTX 3060 12 GB, 16 GB RAM, i5-12400F. This is a bookkeeping fix with a unit test; no game run, so no before/after frame rate is claimed. - Before: `a_write_combined_commit_goes_with_its_reservation` (`crates/vice-tay-gpu/src/shadow.rs`) fails without the `watch.rs` change: the region is still write-combined after the reservation's release ("stale after the reservation's release"). - After: the test passes. - For shader changes, the wave sizes tested: no shader change. - `cargo test` passed for the crates it touches: yes, apart from one test that fails on `main` as well. `cargo test --locked -p vice-tay-gpu`: 923 passed, 3 failed while a GPU-heavy job ran on the same card (`watch::tests::ask_rest_falls_back_per_piece_when_touching_unwatched_neighbour` and two `texback` GPU tests); each passes when run on its own. `cargo test --locked -p vice-tay-gpu --all-features -- --test-threads=1`: 1,010 passed, 1 failed, `compose::tests::bgrx_plane_selects_a_typed_view` (compose.rs:584), which fails the same way on `main` at 206e07b4 without this change. Also run: `cargo clippy --locked -p vice-tay-gpu --all-targets -- -D warnings`, with and without `--all-features` (no warnings from the code; the only warning is the unknown `clippy::chunks_exact_to_as_chunks` lint the build's flags allow); `cargo run --locked -p xtask -- policy` (426 files ok); `git diff --check` (clean). Nobody has checked whether GTA VI itself commits write-combined memory inside a plain reservation (cafeoh noted the same on #462), so this fixes a defect the test shows, not a visible problem in the game. ## Has this been tried here before? Yes, on the previous line: cafeoh committed it as 320d657b on #462's branch, and that PR was closed with every other PR against the old `main` (#468), so the fix never reached the current `main`. Nothing is different except that it is rebuilt on the current `main`. - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #462 AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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/481:upstream-pr/481'
git switch 'upstream-pr/481'

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