HLE/GPU: invalidate write trackers on 32-bit XMem allocation release and reuse #2822

Open
VlREX wants to merge 2 commits from upstream-pr/2824 into main
VlREX commented 2026-11-25 21:32:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by VlREX on 2026-11-25T21:32:21Z.


Summary

Notify GPU write trackers when 32-bit XMem allocations
are released and reused. Complementary to #2612.

Reproduced failure

new allocation was invisible: clean=true, taken=[]

Native verification

Ryzen 5 3600X / RX 5700 XT / Windows 10
Rust 1.98.1

  • Targeted regression: PASS
  • Clippy GPU + HLE: PASS
  • GPU suite: 194 passed, 1 failed, 2 ignored
  • Existing texture failure reproduced on exact baseline.

Baseline: 13f91ca
Tested head: 88c5ea1

Remaining: full XMem integration regression,
workspace/HLE results and concurrent copy-back review.

No gameplay or FPS claims.
AI-assisted development (ChatGPT).
Native verification by VlREX.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6614172885 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2824). Originally posted by [VlREX](https://github.com/VlREX) on 2026-11-25T21:32:21Z. --- ### Summary Notify GPU write trackers when 32-bit XMem allocations are released and reused. Complementary to #2612. ### Reproduced failure new allocation was invisible: clean=true, taken=[] ### Native verification Ryzen 5 3600X / RX 5700 XT / Windows 10 Rust 1.98.1 - Targeted regression: PASS - Clippy GPU + HLE: PASS - GPU suite: 194 passed, 1 failed, 2 ignored - Existing texture failure reproduced on exact baseline. Baseline: 13f91ca Tested head: 88c5ea1 Remaining: full XMem integration regression, workspace/HLE results and concurrent copy-back review. No gameplay or FPS claims. AI-assisted development (ChatGPT). Native verification by VlREX.
kotekompotek commented 2026-11-25 22:04:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T21:57:27Z.

Review: COMMENTED


Correct: VirtualQuery walks the allocation across split guard regions, fails closed on overflow or non-advancing regions, and the guard lock is held across VirtualFree + retain so no concurrent writing() can VirtualProtect a page another allocator may already have reused. remapped() drops both alias directions. LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6065545884 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2824#pullrequestreview-6065545884). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T21:57:27Z. **Review:** COMMENTED --- Correct: VirtualQuery walks the allocation across split guard regions, fails closed on overflow or non-advancing regions, and the guard lock is held across VirtualFree + retain so no concurrent writing() can VirtualProtect a page another allocator may already have reused. remapped() drops both alias directions. LGTM.
fuzeofficlal commented 2026-11-25 23:06:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T22:41:08Z.


Verified 88c5ea1d merged onto main (f3578e3) on Windows 11:

  • watch::tests::release_and_reuse_marks_the_whole_title_allocation (--ignored --exact): 1/1 passed.
  • watch::tests: 15/15 passed (1 ignored); victory-hle modules::xmem::tests: 12/12 passed.
  • cargo clippy --locked -p victory-gpu -p victory-hle --all-targets -- -D warnings (default & victory-gpu/diagnostics): 0 warnings; cargo xtask policy: 190 files ok.
  • Audited release_title_allocation: walking VirtualQuery (AllocationBase == address && Type == MEM_PRIVATE) captures multi-protection regions split by PAGE_GUARD while rejecting interior pointers; performing VirtualFree(MEM_RELEASE) inside guards() before clearing g.protected and calling remapped() avoids calling VirtualProtect on freed/reused VA space and clears changed/armed/alias_of atomically without lock-order issues.

Looks clean and ready to merge.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176666256 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2824#issuecomment-7176666256). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T22:41:08Z. --- Verified `88c5ea1d` merged onto `main` (`f3578e3`) on Windows 11: - `watch::tests::release_and_reuse_marks_the_whole_title_allocation` (`--ignored --exact`): 1/1 passed. - `watch::tests`: 15/15 passed (1 ignored); `victory-hle` `modules::xmem::tests`: 12/12 passed. - `cargo clippy --locked -p victory-gpu -p victory-hle --all-targets -- -D warnings` (default & `victory-gpu/diagnostics`): 0 warnings; `cargo xtask policy`: `190 files ok`. - Audited `release_title_allocation`: walking `VirtualQuery` (`AllocationBase == address && Type == MEM_PRIVATE`) captures multi-protection regions split by `PAGE_GUARD` while rejecting interior pointers; performing `VirtualFree(MEM_RELEASE)` inside `guards()` before clearing `g.protected` and calling `remapped()` avoids calling `VirtualProtect` on freed/reused VA space and clears `changed`/`armed`/`alias_of` atomically without lock-order issues. Looks clean and ready to merge.
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/2824:upstream-pr/2824'
git switch 'upstream-pr/2824'

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