GPU: title memory copies are brought up to date again after a title write #2240

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

@⁠denkencar-sketch on GitHub · 2026-11-25 08:31 UTC · original
denkencar-sketch:fix/memory-copy-refresh → main · +39 −3 · 2 files · 1 commits · open

Summary

A list that reads title memory through a view heap's page table queues one Step::Memory(heap) (memory::prepare, which brings every host copy up to date): memory::bind calls defer_memory once, at the list's first title-memory draw, and State::memory_map returns its cached map after that without asking again. A buffer range (defer_refresh) or a heap's views (defer_heap) is queued again after a step that writes title memory, because defer_copy and defer clear Deferred::refreshed. Step::Memory was not, so a draw recorded after an in-list copy into a title buffer read the copy's old bytes through the page table.

Change

  • HostList::defer_memory queues Step::Memory once until a title write, keyed in refreshed like defer_heap (the key is (heap, usize::MAX, 1), apart from buffer ranges and defer_heap's (ptr, usize::MAX, 0)).
  • State::memory_map calls defer_memory on its cached path too, which is a no-op unless a title write cleared the key.

Testing

host::batch::title_memory_is_refreshed_again_after_a_title_write: two defer_memory calls queue one step, after a defer_copy the next ones queue one more, another heap queues its own. On main the first assertion fails (two steps, not one). cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings is clean.

Not tried: a run in the game, or a list that actually draws after such a copy (the test covers the queueing, and memory_map's cached path is only read, not run). modules::dstorage::tests::a_page_list_filled_after_its_request_starts fails now and then on main too (5 of 20 runs of cargo test -p victory-hle --lib); it is unrelated.

AI-assisted.

**@⁠denkencar-sketch** on GitHub · 2026-11-25 08:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/2240) `denkencar-sketch:fix/memory-copy-refresh` → `main` · +39 −3 · 2 files · 1 commits · open ## Summary A list that reads title memory through a view heap's page table queues one `Step::Memory(heap)` (`memory::prepare`, which brings every host copy up to date): `memory::bind` calls `defer_memory` once, at the list's first title-memory draw, and `State::memory_map` returns its cached map after that without asking again. A buffer range (`defer_refresh`) or a heap's views (`defer_heap`) is queued again after a step that writes title memory, because `defer_copy` and `defer` clear `Deferred::refreshed`. `Step::Memory` was not, so a draw recorded after an in-list copy into a title buffer read the copy's old bytes through the page table. ## Change - `HostList::defer_memory` queues `Step::Memory` once until a title write, keyed in `refreshed` like `defer_heap` (the key is `(heap, usize::MAX, 1)`, apart from buffer ranges and `defer_heap`'s `(ptr, usize::MAX, 0)`). - `State::memory_map` calls `defer_memory` on its cached path too, which is a no-op unless a title write cleared the key. ## Testing `host::batch::title_memory_is_refreshed_again_after_a_title_write`: two `defer_memory` calls queue one step, after a `defer_copy` the next ones queue one more, another heap queues its own. On `main` the first assertion fails (two steps, not one). `cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings` is clean. Not tried: a run in the game, or a list that actually draws after such a copy (the test covers the queueing, and `memory_map`'s cached path is only read, not run). `modules::dstorage::tests::a_page_list_filled_after_its_request_starts` fails now and then on `main` too (5 of 20 runs of `cargo test -p victory-hle --lib`); it is unrelated. AI-assisted.
A list's Step::Memory (crate::memory::prepare) was queued once, by bind at the list's first title-memory draw, while a buffer range (defer_refresh) or a heap's views (defer_heap) are queued again after a step that writes title memory. A draw after an in-list copy into a title buffer then read the copy's old bytes through the page table. defer_memory now queues once until a title write (like defer_heap), and State::memory_map asks again on its cached path.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:59:38 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 09:13 UTC · original

Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head c11fb18d into main 940d32f in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings: clean; the same with --all-features: clean. cargo test --workspace --locked: 702 passed, 0 failed, 10 ignored, two runs (main alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 09:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2240#issuecomment-7158042737) Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head `c11fb18d` into `main` `940d32f` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean; the same with `--all-features`: clean. `cargo test --workspace --locked`: 702 passed, 0 failed, 10 ignored, two runs (`main` alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 13:30 UTC · original · edited 2026-11-26 01:22 UTC

Automated triage for the maintainers.

Merge candidate (a recommendation to look, not an approval). Rebased onto current main with the same change. HostList::defer_memory (crates/victory-gpu/src/host.rs) now queues Step::Memory(heap) only when the key (heap, usize::MAX, 1) is new in Deferred::refreshed. defer_copy and defer clear that set, as they already do for defer_refresh/defer_heap. State::memory_map (draw.rs) now also calls it on its cached path, so a draw recorded after an in-list title write brings the page-table copies up to date again. Before, only the first title-memory draw did. The key cannot collide with buffer ranges or with defer_heap's (.., usize::MAX, 0). The test title_memory_is_refreshed_again_after_a_title_write checks the queueing; as the description says, no draw after such a copy was run.

The branch merges cleanly. CI: check passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 13:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/2240#issuecomment-7163888061) · edited 2026-11-26 01:22 UTC <!-- victory-triage v1 head=88bbc7a1c392c37e62e7bb87acbc39879dab0b74 verdict=merge-candidate at=2026-11-26T01:22:11Z --> Automated triage for the maintainers. **Merge candidate** (a recommendation to look, not an approval). Rebased onto current `main` with the same change. `HostList::defer_memory` (`crates/victory-gpu/src/host.rs`) now queues `Step::Memory(heap)` only when the key `(heap, usize::MAX, 1)` is new in `Deferred::refreshed`. `defer_copy` and `defer` clear that set, as they already do for `defer_refresh`/`defer_heap`. `State::memory_map` (`draw.rs`) now also calls it on its cached path, so a draw recorded after an in-list title write brings the page-table copies up to date again. Before, only the first title-memory draw did. The key cannot collide with buffer ranges or with `defer_heap`'s `(.., usize::MAX, 0)`. The test `title_memory_is_refreshed_again_after_a_title_write` checks the queueing; as the description says, no draw after such a copy was run. The branch merges cleanly. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-25 08:42 UTC · original · approved these changes

Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --lib title_memory_is_refreshed_again_after_a_title_write — passed on RTX 5090
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean fix ensuring title memory copies are refreshed again after subsequent title writes. Looks good.

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-25 08:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2240#pullrequestreview-6054308263) · **approved these changes** Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu --lib title_memory_is_refreshed_again_after_a_title_write` — passed on RTX 5090 - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean fix ensuring title memory copies are refreshed again after subsequent title writes. Looks good. AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 08:48 UTC · original · reviewed

Title memory copies are brought up to date again after a step that wrote title memory; defer_memory deduped via refreshed set. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Pairs with #2235 (page-table retry) — both close title-memory freshness holes.

**@⁠catminou4** on GitHub · 2026-11-25 08:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2240#pullrequestreview-6054381609) · **reviewed** Title memory copies are brought up to date again after a step that wrote title memory; defer_memory deduped via refreshed set. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Pairs with #2235 (page-table retry) — both close title-memory freshness holes.
Author
Owner

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

Reviewed and verified 88bbc7a1c392c37e62e7bb87acbc39879dab0b74 merged onto origin/main (63bcca43c6a00a758510398fa43096ce7e4f7df0) on Windows 11 x64 (RTX 5090 + Microsoft WARP, Rust 1.98.1 MSVC).

Code Audit

  • HostList::defer_memory (crates/victory-gpu/src/host.rs:2118-2124) deduplicates Step::Memory(heap) in Deferred::refreshed using (heap, usize::MAX, 1), which is strictly disjoint from both buffer-range keys (shadow_ptr, addr, len) and defer_heap's (viewed_ptr, usize::MAX, 0).
  • Title-memory write paths (defer_copy and defer) clear Deferred::refreshed (while host/upload-only defer_fill/defer_host do not), so calling list.defer_memory(heap) on the cached path of State::memory_map (crates/victory-gpu/src/draw.rs:491-497) is a zero-step no-op until a title write occurs, and queues exactly one fresh Step::Memory(heap) afterward.

Local Verification

  • cargo xtask policy — pass.
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --all-features) — 0 warnings.
  • cargo test --locked -p victory-gpu --lib batch:: (RTX 5090 and WARP) — all passed, including title_memory_is_refreshed_again_after_a_title_write.
  • Additional end-to-end GPU execution probe in a single HostList: bound title memory (memory::bind), queued list.defer_copy writing 0xDEAD_BEEF into write-watched title memory, called list.defer_memory again, executed the list via host.execute, and verified the host shadow copy read back 0xDEAD_BEEF with zero debug-layer messages on both RTX 5090 and WARP.
  • Also verified a 4-way co-merge with #2223, #2276, and #2279 on 63bcca43c6a0 builds and passes all targeted GPU tests cleanly on RTX 5090 and WARP.

Looks good to merge.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 19:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/2240#pullrequestreview-6079533271) · **approved these changes** Reviewed and verified `88bbc7a1c392c37e62e7bb87acbc39879dab0b74` merged onto `origin/main` (`63bcca43c6a00a758510398fa43096ce7e4f7df0`) on Windows 11 x64 (RTX 5090 + Microsoft WARP, Rust 1.98.1 MSVC). ### Code Audit - `HostList::defer_memory` (`crates/victory-gpu/src/host.rs:2118-2124`) deduplicates `Step::Memory(heap)` in `Deferred::refreshed` using `(heap, usize::MAX, 1)`, which is strictly disjoint from both buffer-range keys `(shadow_ptr, addr, len)` and `defer_heap`'s `(viewed_ptr, usize::MAX, 0)`. - Title-memory write paths (`defer_copy` and `defer`) clear `Deferred::refreshed` (while host/upload-only `defer_fill`/`defer_host` do not), so calling `list.defer_memory(heap)` on the cached path of `State::memory_map` (`crates/victory-gpu/src/draw.rs:491-497`) is a zero-step no-op until a title write occurs, and queues exactly one fresh `Step::Memory(heap)` afterward. ### Local Verification - `cargo xtask policy` — pass. - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`) — 0 warnings. - `cargo test --locked -p victory-gpu --lib batch::` (RTX 5090 and WARP) — all passed, including `title_memory_is_refreshed_again_after_a_title_write`. - Additional end-to-end GPU execution probe in a single `HostList`: bound title memory (`memory::bind`), queued `list.defer_copy` writing `0xDEAD_BEEF` into write-watched title memory, called `list.defer_memory` again, executed the list via `host.execute`, and verified the host shadow copy read back `0xDEAD_BEEF` with zero debug-layer messages on both RTX 5090 and WARP. - Also verified a 4-way co-merge with `#2223`, `#2276`, and `#2279` on `63bcca43c6a0` builds and passes all targeted GPU tests cleanly on RTX 5090 and WARP. Looks good to merge.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/2240/head:github-bot/gh-2240'
git switch 'github-bot/gh-2240'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2240'
git switch 'github-bot/gh-2240'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2240'
git switch 'github-bot/gh-2240'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2240'
git switch 'main'
git merge --squash 'github-bot/gh-2240'
git switch 'main'
git merge --ff-only 'github-bot/gh-2240'
git switch 'main'
git merge 'github-bot/gh-2240'
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!2240
No description provided.