GPU: a remapped mapping does not mark the mappings that still show it #2547

Open
Calvix2k wants to merge 1 commit from upstream-pr/2549 into main
Calvix2k commented 2026-11-25 15:38:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T15:38:09Z.


Fixes #2414.

The failure

title_memory_remapped marked [at, at + len) changed through changed, which follows the alias links (watch.rs: changed → changed_here per page, then every page linked to them). A mapping that still shows the same physical pages was therefore marked changed with nothing saved, although it shows what it did. If such a copy was armed for a marked write in a running submission, copy_back_marked found saved.is_none() && changed(page) and kept the title's bytes — the shaders' writes to those pages were dropped. A title write to them afterwards does not fault either, so nothing is saved then.

What the change does

Only the pages the runtime remapped are marked (changed_here), which is what the function's own description says: "what it shows is new". The links are still dropped — those pages no longer show what they did, so a later write there must be seen at the new address only.

Verification

  • remapping_one_mapping_leaves_the_other_unchanged: a tracked page taken and armed, a second mapping linked to it (title_memory_aliased), then the second remapped. Without the change it fails ("the other mapping still shows what it did"); with it the tracked page keeps its state.
  • cargo test -p victory-gpu --features diagnostics --lib on Windows 10 19045 / RX 7800 XT: 146 passed, 2 ignored, plus the known placed-view failure on a runtime without ID3D12Device10 (#1999, identical on main); clippy -D warnings clean.

The other half of this family — guard_aliases ignoring protect's result when the alias is busy (#2454) — is not touched here: it needs the busy/open-write state at the call sites, which is a different change.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5494449621 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2549). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T15:38:09Z. --- Fixes #2414. ### The failure `title_memory_remapped` marked `[at, at + len)` changed through `changed`, which **follows the alias links** (`watch.rs`: `changed` → `changed_here` per page, then every page linked to them). A mapping that still shows the same physical pages was therefore marked changed *with nothing saved*, although it shows what it did. If such a copy was armed for a marked write in a running submission, `copy_back_marked` found `saved.is_none() && changed(page)` and kept the title's bytes — the shaders' writes to those pages were dropped. A title write to them afterwards does not fault either, so nothing is saved then. ### What the change does Only the pages the runtime remapped are marked (`changed_here`), which is what the function's own description says: "what it shows is new". The links are still dropped — those pages no longer show what they did, so a later write there must be seen at the new address only. ### Verification - `remapping_one_mapping_leaves_the_other_unchanged`: a tracked page taken and armed, a second mapping linked to it (`title_memory_aliased`), then the second remapped. **Without the change it fails** ("the other mapping still shows what it did"); with it the tracked page keeps its state. - `cargo test -p victory-gpu --features diagnostics --lib` on Windows 10 19045 / RX 7800 XT: **146 passed**, 2 ignored, plus the known placed-view failure on a runtime without `ID3D12Device10` (#1999, identical on `main`); clippy `-D warnings` clean. The other half of this family — `guard_aliases` ignoring `protect`'s result when the alias is busy (#2454) — is not touched here: it needs the busy/open-write state at the call sites, which is a different change.
fyernald commented 2026-11-25 16:41:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fyernald on 2026-11-25T16:41:47Z.

Review: APPROVED


Tested on an RTX 3080 (617.42), Windows 10 (19045), main 67e8ae1. cargo test -p victory-gpu --lib --locked -- --test-threads=1: 193 passed, 3 failed (the 3 also fail on main here). remapping_one_mapping_leaves_the_other_unchanged passes.

The change matches what title_memory_remapped says it does: only the remapped pages show something new, and the links are still dropped.

One small thing in the test: free(a) and free(b) run while tracked is still alive, after tracked.taken(..) guarded a. So page a stays in the global protected and holders sets until tracked drops at the end of the function. A parallel test that gets the same address from VirtualAlloc in that window sees its page as already guarded, and its writes go unseen. Every other test in watch.rs does drop(t); free(p); doing the same here (drop(tracked) before the frees) closes that window. It's not needed for correctness, but this crate has had enough parallel-run flakes.

<!-- greyfinch-sync:Marvisak/VIctory:review:6061371075 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2549#pullrequestreview-6061371075). Originally posted by [fyernald](https://github.com/fyernald) on 2026-11-25T16:41:47Z. **Review:** APPROVED --- Tested on an **RTX 3080 (617.42), Windows 10 (19045)**, `main` `67e8ae1`. `cargo test -p victory-gpu --lib --locked -- --test-threads=1`: 193 passed, 3 failed (the 3 also fail on `main` here). `remapping_one_mapping_leaves_the_other_unchanged` passes. The change matches what `title_memory_remapped` says it does: only the remapped pages show something new, and the links are still dropped. One small thing in the test: `free(a)` and `free(b)` run while `tracked` is still alive, after `tracked.taken(..)` guarded `a`. So page `a` stays in the global `protected` and `holders` sets until `tracked` drops at the end of the function. A parallel test that gets the same address from `VirtualAlloc` in that window sees its page as already guarded, and its writes go unseen. Every other test in `watch.rs` does `drop(t); free(p)`; doing the same here (`drop(tracked)` before the frees) closes that window. It's not needed for correctness, but this crate has had enough parallel-run flakes.
Marvisak commented 2026-11-25 19:06:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T18:36:08Z.


Automated triage for the maintainers.

Merge candidate. watch::title_memory_remapped (crates/victory-gpu/src/watch.rs) now marks only the remapped pages as changed (changed_here) instead of also marking every alias (changed). The callers are xmem.rs (map and unmap of a view of physical pages) and list.rs (Upload::drop). In each case only the virtual mapping changes; other mappings of the same physical page still show the same bytes. Marking them changed with nothing saved could drop a marked copy-back (#2414). The alias links are still removed. The new test covers the case from the issue. CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171135218 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2549#issuecomment-7171135218). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T18:36:08Z. --- <!-- victory-triage v1 head=50c43553755f6a44b74170bce0de491318c75c26 verdict=merge-candidate at=2026-11-25T18:35:58Z --> Automated triage for the maintainers. **Merge candidate.** `watch::title_memory_remapped` (`crates/victory-gpu/src/watch.rs`) now marks only the remapped pages as changed (`changed_here`) instead of also marking every alias (`changed`). The callers are `xmem.rs` (map and unmap of a view of physical pages) and `list.rs` (`Upload::drop`). In each case only the virtual mapping changes; other mappings of the same physical page still show the same bytes. Marking them changed with nothing saved could drop a marked copy-back (#2414). The alias links are still removed. The new test covers the case from the issue. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-26 01:04:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T00:50:45Z.


Heads-up from testing head 50c43553755f merged onto current main (63bcca43c6a0):

  • Build failure after clean merge (silent semantic conflict):
    • Git merges crates/victory-gpu/src/watch.rs with zero text conflicts, so GitHub reports the PR as mergeable, but victory-gpu fails to compile on main (63bcca43):
      error[E0425]: cannot find function 'changed_here' in this scope (crates/victory-gpu/src/watch.rs:819:5)
    • Commit 384b0c0b (#2239) refactored watch.rs (lines 714-742) into separate mark_changed and open_guarded passes and removed changed_here.
  • Logic note & fix:
    • The intent in title_memory_remapped — marking and unprotecting only the remapped VA range [first, last) without propagating across alias_of to sibling mappings that still show the same physical pages (while clearing bidirectional alias_of links) — is sound.
    • Rebasing onto main and replacing changed_here(&mut g, first, last, false) at watch.rs:819 with mark_changed(&mut g, first, last, false); open_guarded(&mut g, first, last); (or restoring a local helper) should make it build and pass cleanly.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7179170713 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2549#issuecomment-7179170713). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T00:50:45Z. --- Heads-up from testing head `50c43553755f` merged onto current `main` (`63bcca43c6a0`): - **Build failure after clean merge (silent semantic conflict)**: - Git merges `crates/victory-gpu/src/watch.rs` with zero text conflicts, so GitHub reports the PR as mergeable, but `victory-gpu` fails to compile on `main` (`63bcca43`): `error[E0425]: cannot find function 'changed_here' in this scope` (`crates/victory-gpu/src/watch.rs:819:5`) - Commit `384b0c0b` (`#2239`) refactored `watch.rs` (`lines 714-742`) into separate `mark_changed` and `open_guarded` passes and removed `changed_here`. - **Logic note & fix**: - The intent in `title_memory_remapped` — marking and unprotecting only the remapped VA range `[first, last)` without propagating across `alias_of` to sibling mappings that still show the same physical pages (while clearing bidirectional `alias_of` links) — is sound. - Rebasing onto `main` and replacing `changed_here(&mut g, first, last, false)` at `watch.rs:819` with `mark_changed(&mut g, first, last, false); open_guarded(&mut g, first, last);` (or restoring a local helper) should make it build and pass cleanly.
Calvix2k commented 2026-11-26 18:52:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-26T18:52:57Z.


Thanks — reproduced on a 7800 XT / Windows 10 rebase as well: upstream folded changed_here into changed, mark_changed and open_guarded, so the call in title_memory_remapped no longer resolved.

The branch now carries a local changed_here built from mark_changed + open_guarded (the alias-free half of changed, which is what a remap needs), rebased on current main. cargo check -p victory-gpu --all-targets passes here, and GitHub reports it mergeable again. Head 0060ec9.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7200955419 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2549#issuecomment-7200955419). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-26T18:52:57Z. --- Thanks — reproduced on a 7800 XT / Windows 10 rebase as well: upstream folded `changed_here` into `changed`, `mark_changed` and `open_guarded`, so the call in `title_memory_remapped` no longer resolved. The branch now carries a local `changed_here` built from `mark_changed` + `open_guarded` (the alias-free half of `changed`, which is what a remap needs), rebased on current main. `cargo check -p victory-gpu --all-targets` passes here, and GitHub reports it mergeable again. Head `0060ec9`.
Dukestar69 commented 2026-11-26 19:11:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T19:11:10Z.

Review: APPROVED


LGTM — verified on Windows against origin/main (63bcca4).

  • Using changed_here in title_memory_remapped marks and opens only the remapped VA range, leaving other virtual mappings that still reference the same physical pages (and their armed trackers) undisturbed.
  • cargo test -p victory-gpu --lib watch:: -- --test-threads=1: 16 passed, 0 failed (including remapping_one_mapping_leaves_the_other_unchanged).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6079355304 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2549#pullrequestreview-6079355304). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T19:11:10Z. **Review:** APPROVED --- LGTM — verified on Windows against `origin/main` (`63bcca4`). - Using `changed_here` in `title_memory_remapped` marks and opens only the remapped VA range, leaving other virtual mappings that still reference the same physical pages (and their armed trackers) undisturbed. - `cargo test -p victory-gpu --lib watch:: -- --test-threads=1`: 16 passed, 0 failed (including `remapping_one_mapping_leaves_the_other_unchanged`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
dux14 commented 2026-11-29 05:39:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by dux14 on 2026-11-29T05:39:45Z.


#2415 makes the same mark_changed/open_guarded change and also opens alias pages that only the removed link guarded. It has an end-to-end test through copy_back_marked. This diff also has two problems: let guarded = …; and let others … are on one line, and the doc comment for changed is now attached to changed_here. Its test only checks tracked.changed and never reaches copy_back_marked. Suggest closing in favour of #2415.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7251385365 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2549#issuecomment-7251385365). Originally posted by [dux14](https://github.com/dux14) on 2026-11-29T05:39:45Z. --- #2415 makes the same `mark_changed`/`open_guarded` change and also opens alias pages that only the removed link guarded. It has an end-to-end test through `copy_back_marked`. This diff also has two problems: `let guarded = …;` and `let others …` are on one line, and the doc comment for `changed` is now attached to `changed_here`. Its test only checks `tracked.changed` and never reaches `copy_back_marked`. Suggest closing in favour of #2415.
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/2549:upstream-pr/2549'
git switch 'upstream-pr/2549'

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