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

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

@⁠Calvix2k on GitHub · 2026-11-25 15:38 UTC · original
Calvix2k:codex/gpu-remapped-aliases-unchanged → main · +42 −4 · 1 files · 1 commits · open

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.

**@⁠Calvix2k** on GitHub · 2026-11-25 15:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2549) `Calvix2k:codex/gpu-remapped-aliases-unchanged` → `main` · +42 −4 · 1 files · 1 commits · open 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.
`title_memory_remapped` marked `[at, at + len)` changed through `changed`,
which follows the alias links: another mapping of the same physical pages was
marked changed too, with nothing saved, although it still shows what it did.
If such a copy was armed for a marked write in a running submission,
`copy_back_marked` then found it changed with nothing saved and kept the
title's bytes, dropping the shaders' writes there (#2414). A title write to
it afterwards does not fault either, so it saves nothing.

Only the pages the runtime remapped are marked now (`changed_here`), which is
also 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.

`remapping_one_mapping_leaves_the_other_unchanged` is the issue's case: a
tracked page taken and armed, a second mapping linked to it, then the second
remapped. Without the change the tracked page counts changed (the assertion
fails); with it, it keeps what it had.

Lib suite: 146 passed, 2 ignored, plus the known placed-view failure on a
runtime without `ID3D12Device10` (#1999); clippy `-D warnings` clean.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:08:57 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 18:36 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 18:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/2549#issuecomment-7171135218) <!-- 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)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 00:50 UTC · original

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.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 00:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/2549#issuecomment-7179170713) 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.
github-bot force-pushed github-bot/gh-2549 from 50c4355375 to 0060ec9c33 2026-11-26 18:58:24 +00:00 Compare
Author
Owner

@⁠fyernald on GitHub · 2026-11-25 16:41 UTC · original · approved these changes

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.

**@⁠fyernald** on GitHub · 2026-11-25 16:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2549#pullrequestreview-6061371075) · **approved these changes** 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.
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-26 18:52 UTC · original

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.

**@⁠Calvix2k** on GitHub · 2026-11-26 18:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2549#issuecomment-7200955419) 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`.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 19:11 UTC · original · approved these changes

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).

**@⁠Dukestar69** on GitHub · 2026-11-26 19:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/2549#pullrequestreview-6079355304) · **approved these changes** 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).
This pull request can be merged automatically.
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/2549/head:github-bot/gh-2549'
git switch 'github-bot/gh-2549'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2549'
git switch 'github-bot/gh-2549'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2549'
git switch 'github-bot/gh-2549'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2549'
git switch 'main'
git merge --squash 'github-bot/gh-2549'
git switch 'main'
git merge --ff-only 'github-bot/gh-2549'
git switch 'main'
git merge 'github-bot/gh-2549'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2549
No description provided.