Shadows: batch GPU copy-back writes safely #1124
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1124
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1124"
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?
@divyeshganta on GitHub · 2026-11-24 15:58 UTC · original
divyeshganta:fix/shadow-batched-copyback-boundary→main· +117 −26 · 1 files · 2 commits · openRelated to #918.
This carries cybx's copy-back batching change (commit
4c0d57d5ceec0b836de6849318ae58a404107f91) and fixes the short-range fallback regression reported by DrDarkDK in #918. A changed run shorter than 64 KiB can still cross a 64 KiB boundary; the fallback now splits the run and preserves readable pieces instead of skipping the whole range.Credit: batching implementation by cybx; boundary-case correction based on DrDarkDK's reproducer and fix report.
The issue report measured copy-back decreasing from 555 ms to 133 ms per frame and total frame time from about 1,033 ms to 750 ms on its test setup. DrDarkDK reported the fallback fix passing synthetic Windows checks on WARP and an RTX 4070 Ti. I have not run tests or performance measurements locally.
@adamdotpy on GitHub · 2026-11-24 16:04 UTC · original
Reviewed on Windows 11 / Rust 1.98.1,
b3d8f95onffe310e.cargo test -p victory-gpu: 51 passed, 1 ignoredcargo test -p victory-gpu --features diagnostics: 54 passed, 1 ignoredcargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings: cleancargo build --release -p victory: buildsThe merge is byte-for-byte the old per-piece loop, which is the point of a change like this. I went through it against the code it replaces: the run test
host(a, b) != &before[a - from..b - from]is exactly the oldhost != oldper piece;merge'sfirstchunking reproduces the piece cut including a run that begins mid-piece (first = PIECE - (start + from) % PIECE), and then steps byPIECEfrom there;syncedcomes out with the same pages because runs contain no gaps — coalescing happens only whenrun.1 == at, so a piece the GPU did not write splits the run instead of being passed over;write_mapped's source pointertitle[a..].as_ptr()with lengthb - amatches the oldtitle.as_ptr()withn; and the fallback keeps the old behaviour exactly — a piece that cannot be read is skipped, andput_back's recursion is bounded at depth two (first == to - fromreturns 0), so an unmapped page cannot recurse forever. Thediffersclosure's borrows are all dead beforeput_backtakes the mutable slice over the same region, so there is no overlap there.One caveat, and it is the only thing I would change: the window a run opens.
copy_back's own doc comment says the title's threads write these buffers while the GPU runs, and the merge reads, then merges, then writes back withWriteProcessMemory. At 64 KiB that window was a piece; a run can now be the whole range, so a title byte written between ourread_intoand ourwrite_mappedis overwritten with the stale title byte we read. It is the same race at a different width, so this is not a regression — but the PR title says "safely" and the commit says title writes are preserved, and a reader will take that as absolute. Either a sentence input_backnaming the window, or a cap on a run (say 16 pieces, still 16 calls saved per 16 pieces) would make the claim true as written. I would take the sentence.Smaller.
host::write_mappedsplits at its own literal64 << 10;PIECEis the same 64 KiB now named inshadow.rs. Same alignment in two places is fine until one moves.first == PIECE(a run that starts on a piece boundary, where the first chunk is a whole piece) and a range where nothing changed (mergereturning no runs). Both are a few lines in the existing test and they are the two places theat == 0 { first }versusat + PIECEsplit could go wrong.@Zipettte on GitHub · 2026-11-24 18:01 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
b3d8f95:cargo test -p victory-gpupasses, 51 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@Marvisak on GitHub · 2026-11-25 00:35 UTC · original
Automated triage for the maintainers.
Needs rebase. This PR does not merge cleanly into current
main(ac2525d). Conflicting files:crates/victory-gpu/src/shadow.rs.The content has not been reviewed yet; it will be once the branch is rebased onto
main.Generated by Claude Code
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.