GPU/watch+inplace: release/reopen views across MANY_VIEWS transitions and clear g.aliased #763

Open
AscilCH wants to merge 1 commit from upstream-pr/763 into main
AscilCH commented 2026-11-25 06:44:53 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by AscilCH on 2026-11-25T06:44:53Z.


Problem

Three multi-view guard state bugs when physical pages cross the MANY_VIEWS (64) threshold (crates/victory-gpu/src/{inplace,watch}.rs):

  1. Crossing MANY_VIEWS upward (64 -> 65 views): title_memory_view() inserted the 65th view into v.pages before calling watch::views_mapped(), which queried views_of_section() and skipped pages with shown.len() > MANY_VIEWS. None of the 64 previously guarded views were opened: v_0 remained clean and PAGE_READONLY, v_1..v_63 remained trapped PAGE_READONLY and in g.aliased, and writes through v_64 were silently missed.
  2. Crossing MANY_VIEWS downward (> 64 -> 2..=64 views): When views_gone() dropped a page's view count back into 2..=MANY_VIEWS, a remaining view that had been guarded alone above MANY_VIEWS stayed clean and PAGE_READONLY while its remaining sibling views stayed PAGE_READWRITE and unguarded.
  3. Stale g.aliased entries in views_mapped(): views_mapped() called open_here() without removing opened blocks from g.aliased.

Fix

  • In inplace::title_memory_view(), collect views to open whenever before is in 1..=MANY_VIEWS (catching both normal additions and the exact 64 -> 65 crossing while keeping > 65 filler pages O(1)) and pass coalesced runs to watch::views_mapped().
  • In inplace::views_gone(), return coalesced runs of remaining views for any page whose count dropped from > MANY_VIEWS into 2..=MANY_VIEWS, and reopen them in watch::title_memory_remapped().
  • Remove opened blocks from g.aliased in watch::views_mapped() and when reopening downward-transitioned views.

Verification

  • cargo test -p victory-gpu --locked -- watch:: inplace::: 20 passed; 0 failed (including new tests crossing_many_views_upward_releases_aliases_and_reports_dirty and crossing_many_views_downward_reopens_remaining_views_for_shared_guarding).
  • cargo clippy -p victory-gpu --all-targets --all-features --locked: 0 warnings in inplace.rs and watch.rs (only pre-existing 8dd30ab warnings in draw.rs:2377 and indirect.rs:1322).
  • cargo xtask policy: 171 files ok.

(AI-assisted; synthetic unit tests only, no game data.)

<!-- greyfinch-sync:fxceless/victory-fork:issue:6598880481 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/763). Originally posted by [AscilCH](https://github.com/AscilCH) on 2026-11-25T06:44:53Z. --- ### Problem Three multi-view guard state bugs when physical pages cross the `MANY_VIEWS` (64) threshold (`crates/victory-gpu/src/{inplace,watch}.rs`): 1. **Crossing `MANY_VIEWS` upward (64 -> 65 views)**: `title_memory_view()` inserted the 65th view into `v.pages` before calling `watch::views_mapped()`, which queried `views_of_section()` and skipped pages with `shown.len() > MANY_VIEWS`. None of the 64 previously guarded views were opened: `v_0` remained `clean` and `PAGE_READONLY`, `v_1..v_63` remained trapped `PAGE_READONLY` and in `g.aliased`, and writes through `v_64` were silently missed. 2. **Crossing `MANY_VIEWS` downward (> 64 -> 2..=64 views)**: When `views_gone()` dropped a page's view count back into `2..=MANY_VIEWS`, a remaining view that had been guarded alone above `MANY_VIEWS` stayed `clean` and `PAGE_READONLY` while its remaining sibling views stayed `PAGE_READWRITE` and unguarded. 3. **Stale `g.aliased` entries in `views_mapped()`**: `views_mapped()` called `open_here()` without removing opened blocks from `g.aliased`. ### Fix - In `inplace::title_memory_view()`, collect views to open whenever `before` is in `1..=MANY_VIEWS` (catching both normal additions and the exact `64 -> 65` crossing while keeping `> 65` filler pages O(1)) and pass coalesced runs to `watch::views_mapped()`. - In `inplace::views_gone()`, return coalesced runs of remaining views for any page whose count dropped from `> MANY_VIEWS` into `2..=MANY_VIEWS`, and reopen them in `watch::title_memory_remapped()`. - Remove opened blocks from `g.aliased` in `watch::views_mapped()` and when reopening downward-transitioned views. ### Verification - `cargo test -p victory-gpu --locked -- watch:: inplace::`: `20 passed; 0 failed` (including new tests `crossing_many_views_upward_releases_aliases_and_reports_dirty` and `crossing_many_views_downward_reopens_remaining_views_for_shared_guarding`). - `cargo clippy -p victory-gpu --all-targets --all-features --locked`: 0 warnings in `inplace.rs` and `watch.rs` (only pre-existing `8dd30ab` warnings in `draw.rs:2377` and `indirect.rs:1322`). - `cargo xtask policy`: `171 files ok`. *(AI-assisted; synthetic unit tests only, no game data.)*
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/763:upstream-pr/763'
git switch 'upstream-pr/763'

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