GPU: Speed up shadow buffer writeback merging #2054
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!2054
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2054/head"
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?
@GaussianGuaicai on GitHub · 2026-11-25 04:11 UTC · original
GaussianGuaicai:gpu/shadow-writeback-merge→main· +41 −18 · 1 files · 1 commits · merged 2026-11-25 21:53 UTCShare a branch-free byte merge between the two shadow-buffer writeback paths so the compiler can vectorize the loop. The GPU byte still wins only when it differs from the saved byte; otherwise the guest byte is preserved. The helper reports whether guest memory needs to be written, as before.
Validation
cargo test --locked -p victory-gpu --lib --features diagnostics: 146 passed, 1 failed, 2 ignored. Unmodified base940d32f: 145 passed, 1 failed, 2 ignored. Both failed the same assertion indraw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_view.git diff --checkpassed.An earlier diagnostic comparison measured merge cost of 0.392 vs. 0.088 ms/MB. The workloads differed; this measures only the merge step and does not establish an end-to-end frame-time improvement.
Prepared with assistance from GitHub Copilot.
@RKouchoo on GitHub · 2026-11-25 04:19 UTC · original
On 7800X3D, #2054 cut a 4 MiB writeback merge from 4.22 ms to 0.34 ms when about one byte in 64 changed. In a separate replay of Story’s buffer-copy workload, #2051 cut the median from 54.1 ms to 30.5 ms.
@Dathinel on GitHub · 2026-11-25 04:33 UTC · original
The 64 KiB piece size used in
shadow.rsshows a clear gain on a Ryzen 7 7435HS. The direction reverses for very short, sparsely changed spans. I compared the merge loop from940d32f6withmerge_writebackfrom857f630on identical synthetic buffers.Each row processes 1 MiB total, split into equal spans. Windows/MSVC, rustc 1.98.1
-O, standalone CPU harness with direct calls. Each range is the min/max of three process medians (30 paired samples per process, alternating order). Buffer resets were outside the timer. Both output buffers and the count of changed spans matched.The four-byte row deliberately calls the merge on every span, including unchanged ones. The saved-page path does that after clipping; the other caller first checks
host != old. Actual clipping frequency, GPU readback and frame time were outside this measurement. AI-assisted.@upipibi on GitHub · 2026-11-25 04:41 UTC · original
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
857f630.victory-gpu: 142 passed, 2 failed, 2 ignored; the newwriteback_merge_matches_bytewise_oraclepasses. The 2 failures are #1744's heap-cap failures onmain. Same asmainon this hardware. Not run: a title.AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-25 09:23 UTC · original
Automated triage for the maintainers.
Merge candidate.
In
crates/victory-gpu/src/shadow.rs, the two copies of the byte-merge loop (incopy_back_or_notand the saved-page path) become one branch-freemerge_writeback. I checked that it does the same thing as the old loop. Where the host byte differs from the snapshot, the title byte takes the host byte; the copy then takes the title byte; it returns true when any title byte changed. The oracle test compares against that rule written out byte by byte, not against the new code. Two people measured it in the thread: about 10x faster on 64 KiB pieces, a little slower on 4-byte spans on the saved-page path.Overlap: #1867 does the same merge with AVX2,
unsafeand an added doc file. This PR is the simpler, portable version of that. #1986 (also marked merge candidate) restructures the same loop incopy_back_or_notto skip withheld ranges, and #1998/#2242 rewrite the copy-back too. Whichever of those lands second will need a rebase. Optional nit: the new test could go in the existing#[cfg(test)] mod testsat the end of the file.CI: passing (
check).Recommending a look, not approving.
Generated by Claude Code