GPU: track numbered title-memory copies per command list in memory::ready (#16) #205
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!205
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-205"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@AscilCH on GitHub · 2026-11-24 22:33 UTC · original
AscilCH:fix/memory-per-list-copy-sync→main· +73 −17 · 2 files · 1 commits · openProblem
Related to #16 (ray-tracing BVH builder stale inputs / missing box-bound updates).
In
crates/victory-gpu/src/memory.rs,ready()tracked whether a command list had refreshed and declaredgpu_writesfor numbered title-memory copies using binary flags (list.first_use(READ)/list.first_use(WRITE)) plusn >= numberedfor copies newly added during the current call:When two command lists are recorded concurrently (e.g. BVH builder stages across worker command lists):
m.copies.len() == 10(first_read = true,first_write = true, covers0..10).10..15(m.copies.len() == 15).first_read = false,first_write = false,numbered = 15):n >= numberedis false for copies10..15, so List A never refreshes copies10..15(stale inputs if List A runs before List B) and never callsshadow.gpu_writeson copies10..15(writes from List A into copies10..15are never copied back to title memory).Step::CopyorStep::Run(defer_copy/defer) runs mid-list between twoready()dispatches,refreshedwas cleared, butfirst_use(READ)stayed set so numbered copies were not refreshed after the copy.Fix
READ/WRITEflags with per-listmemory_read_seenandmemory_write_seenwatermarks onDeferred(crates/victory-gpu/src/host.rs), reset onHostList::reset()(memory_read_seenis also reset indefer_copyanddeferalongsiderefreshed.clear()).memory::ready()(crates/victory-gpu/src/memory.rs), advance the list's watermarks vialist.memory_sync_range(m.copies.len(), writes)and refreshm.copies[read_from..]followed bygpu_writesonm.copies[write_from..]whenwritesis true, keepingm.directory.0andm.faults.0once per list viafirst_use(KEEP).host::relay_tests::memory_sync_range_covers_copies_numbered_by_other_listscovering interleaved lists, read-only → read-write promotion, mid-list title copies, and list reset.Verification
rustfmt --edition 2024 --check crates/victory-gpu/src/memory.rs: cleancargo test -p victory-gpu --locked -- --test-threads=1: 111 passed, 0 failedcargo xtask policy: 169 files okcargo clippy -p victory-gpu --all-targets --locked -- -D warnings: cleancargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings: clean(AI-assisted; synthetic unit tests only, no game data.)
@Etr0p on GitHub · 2026-11-25 00:31 UTC · original
A note for anyone who stacks this PR together with #293 ("Performance fixes", now closed but used in several local integration trees).
This PR adds two per-list watermarks to
Deferred(memory_read_seen,memory_write_seen) and relies on a list reset making a freshDeferredto zero them. #293 changesHostList::resetto callDeferred::clear(), which keeps the container capacities but does not touch those two fields. With both merged, a reused command list keeps its old watermarks: on its next recording,memory_sync_rangereturns ranges that start past copies the list has never refreshed or declared written in this recording, so copies numbered before the reset (possibly by another list) are read stale and their shader stores are not looked for on copy-back, which is exactly the case #205 is meant to close.The fix is two lines in
Deferred::clear():(Without #293's
clear()reset nothing is needed.indirect_readableis left alone on purpose, as #293 keeps the scratch buffer readable between executions.)How it was checked: I merged #293 onto a tree that already had this PR and resolved the conflicts by hand. Reading the merged code,
Deferred::default()was no longer called on reset, so the watermarks survived it. After adding the two lines above,cargo test -p victory-gpupasses (152 tests, including #205'smemory_sync_range_covers_copies_numbered_by_other_lists), and so doescargo test -p victory-shader. This was found by reading the code; I have no in-game measurement of the stale-copy case itself.AI-assisted (Claude Code); measured on my own machine.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.