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

Open
github-bot wants to merge 1 commit from github-bot/gh-481 into main AGit
Owner

@⁠Indy2l on GitHub · 2026-11-30 21:20 UTC · original
Indy2l:gpu/wc-commit-goes-with-reservation → main · +28 −1 · 2 files · 1 commits · open

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

**@⁠Indy2l** on GitHub · 2026-11-30 21:20 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/481) `Indy2l:gpu/wc-commit-goes-with-reservation` → `main` · +28 −1 · 2 files · 1 commits · open 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)
title_memory_freed passed the release's length 0 on, so write_combined_freed
dropped only regions starting at the allocation base. A write-combined commit
inside a reservation made without write-combining stayed registered after the
release, and later memory at that address kept shader writes on the card.
Forget the regions over the allocation's whole extent instead.

Found by Kal0s-design, who also wrote the test (#462).

Co-authored-by: Kal0s-design <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 21:21:05 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/481/head:github-bot/gh-481'
git switch 'github-bot/gh-481'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-481'
git switch 'github-bot/gh-481'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-481'
git switch 'github-bot/gh-481'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-481'
git switch 'main'
git merge --squash 'github-bot/gh-481'
git switch 'main'
git merge --ff-only 'github-bot/gh-481'
git switch 'main'
git merge 'github-bot/gh-481'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.