xmem: tell the GPU side of an unmapped view after unmapping it, not before #1003

Open
SpaghettiMaster545 wants to merge 1 commit from upstream-pr/1005 into main
SpaghettiMaster545 commented 2026-11-25 15:40:19 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by SpaghettiMaster545 on 2026-11-25T15:40:19Z.


What was wrong

xmem::unmap told victory_gpu that a view's memory had changed (title_memory_remapped) before it unmapped the view. A GPU copy refreshing that range in between could guard the blocks that were still mapped and note them clean. Once the view was gone they stayed clean, so copies kept the view's old bytes until something was mapped there again.

How it shows in game

Buffers and textures in physical-page memory that the title unmaps and later reads (zeros, or whatever it maps there next) can keep showing their old contents on the card.

What the change does

The GPU side is told once the view is unmapped. That clears the stale guard state, and the next refresh takes the memory as it now is: its blocks known unmapped, their zeros copied once. The shown bookkeeping is unchanged.

How it was tested

  • cargo test --locked -p victory-hle --lib passes (98 passed). cargo clippy -p victory-hle --no-deps --all-targets --locked -- -D warnings is clean. Without --no-deps, clippy stops on the errors main already has in victory-gpu.
  • Played with this change in our integration branch.
  • GPU and driver: NVIDIA GeForce RTX 5070 Ti, driver 621.40, Windows 11.

Developed with AI assistance (Claude Code).

<!-- greyfinch-sync:fxceless/victory-fork:issue:6608190517 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1005). Originally posted by [SpaghettiMaster545](https://github.com/SpaghettiMaster545) on 2026-11-25T15:40:19Z. --- ## What was wrong `xmem::unmap` told `victory_gpu` that a view's memory had changed (`title_memory_remapped`) before it unmapped the view. A GPU copy refreshing that range in between could guard the blocks that were still mapped and note them clean. Once the view was gone they stayed clean, so copies kept the view's old bytes until something was mapped there again. ## How it shows in game Buffers and textures in physical-page memory that the title unmaps and later reads (zeros, or whatever it maps there next) can keep showing their old contents on the card. ## What the change does The GPU side is told once the view is unmapped. That clears the stale guard state, and the next refresh takes the memory as it now is: its blocks known unmapped, their zeros copied once. The `shown` bookkeeping is unchanged. ## How it was tested - `cargo test --locked -p victory-hle --lib` passes (98 passed). `cargo clippy -p victory-hle --no-deps --all-targets --locked -- -D warnings` is clean. Without `--no-deps`, clippy stops on the errors `main` already has in `victory-gpu`. - Played with this change in our integration branch. - GPU and driver: NVIDIA GeForce RTX 5070 Ti, driver 621.40, Windows 11. Developed with AI assistance (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/1005:upstream-pr/1005'
git switch 'upstream-pr/1005'

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