GPU: each list takes every copy of title memory by address, whichever list numbered it #370

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

@⁠joroyt on GitHub · 2026-11-25 00:01 UTC · original
joroyt:memory-copies-per-list → main · +22 −12 · 1 files · 1 commits · open

What

memory::ready brought the numbered copies up to date, and declared them written, once per list: at the list's first dispatch of a shader that reads title memory by address (first_read), at its first one that can store (first_write), and for the copies that very call numbered. A copy numbered in between by another list was left out of both. The module said so as a shortcut for the read side ("a copy another list numbers meanwhile is brought up to date by that list's submission, which may run after this one's").

The title records its lists on several threads, and a shader finds a copy through the directory whichever list numbered it. So a list could:

  • read a copy it had never refreshed (a new copy is all zeros until its first refresh);
  • store into a copy it had not declared written: no snapshot, no compare, and the stores never go back to title memory;
  • declare a copy written at its first storing dispatch without ever having refreshed it (the two conditions were separate), so the snapshot and the shaders both start from stale bytes.

Change (crates/victory-gpu/src/memory.rs, +24/-12)

Each list takes each copy once, for reading and for writing, kept per list with the keys first_use already has. Copies are only ever added, so a list walks them from the last one down and stops at the first it has taken: the cost per dispatch is one lookup plus the new copies, as before.

Measured

RTX 5070 12 GB (32-lane waves, driver 32.0.16.2124), i9-14900KF, Windows 11, diag build, Series X profile.

With VICTORY_BVH_BUILDER=1 (on 2119b0e + #156, which the builder needs on a 32-lane card, + #115), a local counter of the copies the old conditions would have skipped: 16 dispatches in the first two seconds of the structure builder found copies another list had numbered: 210 copies not brought up to date and 210 not declared written in all (1 to 9 a dispatch, and one dispatch with 146); in 13 of the 16 the list stores. One run; the counter is not part of this change.

Without the builder (this branch as it is, 423 s, into the world): no exception, 376-395 ms per frame at the end with 4,860 draws, against about 392 ms (2119b0e) and 357 ms (2119b0e + #156) in the same scene in two runs earlier the same evening. The runs are not a clean A/B (different lengths, the shader cache refilled after each rebuild), so read that as "no visible cost", not as a number.

Checks: cargo clippy --workspace --all-targets --locked -- -D warnings, the same with --all-features, and cargo test --workspace --locked (496 passed, 0 failed, 7 ignored), all on this branch.

What this does not do

  • It does not fix #16. With this change, #156, #115 and the fix to #115 linked there (Spexivus/victory-fork#1), the title still crashes 5-15 s after the builder starts, at the same sites.
  • No test: the function needs a host device, a list and a view heap, and I found no seam to drive it without them. The counts above are the evidence.

Not tested

  • AMD and Intel GPUs, Windows 10, VICTORY_RELAY, VICTORY_LATE_WAIT.
  • Frame time with the builder on (it is dominated by the snapshots of every numbered window, 12 GB a frame here, which this does not touch).

AI use: found, written and measured with Claude (Anthropic) running in OpenCode on my machine, with my own copy of the title. No game data attached; counts and log lines only.

**@⁠joroyt** on GitHub · 2026-11-25 00:01 UTC · [original](https://github.com/fxceless/victory-fork/pull/370) `joroyt:memory-copies-per-list` → `main` · +22 −12 · 1 files · 1 commits · open ## What `memory::ready` brought the numbered copies up to date, and declared them written, once per list: at the list's first dispatch of a shader that reads title memory by address (`first_read`), at its first one that can store (`first_write`), and for the copies that very call numbered. A copy numbered in between by **another list** was left out of both. The module said so as a shortcut for the read side ("a copy another list numbers meanwhile is brought up to date by that list's submission, which may run after this one's"). The title records its lists on several threads, and a shader finds a copy through the directory whichever list numbered it. So a list could: - read a copy it had never refreshed (a new copy is all zeros until its first refresh); - store into a copy it had not declared written: no snapshot, no compare, and the stores never go back to title memory; - declare a copy written at its first storing dispatch without ever having refreshed it (the two conditions were separate), so the snapshot and the shaders both start from stale bytes. ## Change (`crates/victory-gpu/src/memory.rs`, +24/-12) Each list takes each copy once, for reading and for writing, kept per list with the keys `first_use` already has. Copies are only ever added, so a list walks them from the last one down and stops at the first it has taken: the cost per dispatch is one lookup plus the new copies, as before. ## Measured RTX 5070 12 GB (32-lane waves, driver 32.0.16.2124), i9-14900KF, Windows 11, diag build, Series X profile. With `VICTORY_BVH_BUILDER=1` (on `2119b0e` + #156, which the builder needs on a 32-lane card, + #115), a local counter of the copies the old conditions would have skipped: **16 dispatches in the first two seconds of the structure builder found copies another list had numbered: 210 copies not brought up to date and 210 not declared written in all (1 to 9 a dispatch, and one dispatch with 146)**; in 13 of the 16 the list stores. One run; the counter is not part of this change. Without the builder (this branch as it is, 423 s, into the world): no exception, 376-395 ms per frame at the end with 4,860 draws, against about 392 ms (`2119b0e`) and 357 ms (`2119b0e` + #156) in the same scene in two runs earlier the same evening. The runs are not a clean A/B (different lengths, the shader cache refilled after each rebuild), so read that as "no visible cost", not as a number. Checks: `cargo clippy --workspace --all-targets --locked -- -D warnings`, the same with `--all-features`, and `cargo test --workspace --locked` (496 passed, 0 failed, 7 ignored), all on this branch. ## What this does not do - **It does not fix #16.** With this change, #156, #115 and the fix to #115 linked there (Spexivus/victory-fork#1), the title still crashes 5-15 s after the builder starts, at the same sites. - No test: the function needs a host device, a list and a view heap, and I found no seam to drive it without them. The counts above are the evidence. ## Not tested - AMD and Intel GPUs, Windows 10, `VICTORY_RELAY`, `VICTORY_LATE_WAIT`. - Frame time with the builder on (it is dominated by the snapshots of every numbered window, 12 GB a frame here, which this does not touch). AI use: found, written and measured with Claude (Anthropic) running in OpenCode on my machine, with my own copy of the title. No game data attached; counts and log lines only.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:41:52 +00:00
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/370/head:github-bot/gh-370'
git switch 'github-bot/gh-370'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-370'
git switch 'github-bot/gh-370'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-370'
git switch 'github-bot/gh-370'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-370'
git switch 'main'
git merge --squash 'github-bot/gh-370'
git switch 'main'
git merge --ff-only 'github-bot/gh-370'
git switch 'main'
git merge 'github-bot/gh-370'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.