GPU: the parallel compare after a submission compares a big range from its first byte (its first cut wrapped below the copy's start) #1407
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!1407
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1407"
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?
@PiloteCode on GitHub · 2026-11-26 23:40 UTC · original
PiloteCode:pr/compare-cut→main· +38 −1 · 1 files · 1 commits · closed without mergingBased on
a42b627e(main). One commit, one line and a test, inshadow.rs.The bug was found by a review of stellarr-studio/kelvaroq (its patch 0009), which named it. This PR is that one-line fix, with a test of ours.
What was wrong
After a submission,
Shadow::copy_back_withfinds the 64 KiB pieces of a declared range that the shaders changed (Shadow::differing), and copies only those back into title memory. A range of 32 MiB or more is compared on several threads, 16 MiB or more each. Each slice is cut on a piece of title memory:For the first cut,
atis the range's start. When the copy's title buffer does not start on a 64 KiB boundary and the range starts within its first piece, that piece begins before the copy:(start + at) % PIECEis larger thanat, and the subtraction wraps.max(from)keeps the huge value, so the first thread gets an empty slice:The other cuts lie 16 MiB or more into the range, past any such piece, and were right.
What changes
The cut saturates:
at.saturating_sub((start + at) % PIECE).max(from). The first slice starts at the range's start; every other cut is as before.Tested
On the software adapter (the test needs a buffer for its copy, nothing else of the device):
shadow::card_merge_tests::a_big_compare_finds_changes_in_its_first_slice: a 48 MiB copy whose title address lies 32 KiB into a piece, with changes at its first byte, in its first two pieces, at 3, 20 and 40 MiB and at its last byte, compared from its first byte. It checks that every change is found, that no unchanged piece is, and that each piece ends on a piece of title memory or at the range's end.mainwithout the fix: it panics with "attempt to subtract with overflow" at the cut (debug). In a release build (cargo test --release) it finds only the three pieces past the first slice; the changes at 0, 100, 0xFFFF, 0x10005 and 3 MiB are missed.cargo test -p victory-gpu --features diagnostics -- --test-threads=1 --skip stacks_that_mean_nothing_are_walked_without_a_faultwithVICTORY_D3D12_WARP=1: 247 passed, 1 failed, 7 ignored. The failure ispipeline::make::tests::pending_pipeline_is_recorded_for_the_next_launch, which fails the same way onmain(246 passed, 1 failed). The skipped test ends the test process with an access violation on this machine, onmaintoo.cargo test -p victory-hle -- --test-threads=1: 103 passed (and 1 in its second test binary).cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with--all-features: clean.cargo build --release -p victoryandcargo build --profile diag -p victory --features diagnosticspass.cargo xtask policyfails onmainitself (host.rs533,931 bytes andemit/lower.rs535,588, over the 524,288-byte limit). This branch adds 1,939 bytes toshadow.rs(234,708), which stays under it.Overlaps with open pull requests
return fromfor the first cut) among its 9,959 added lines (lazy write-back, ReBAR and AVX2 paths behind switches). Its description does not mention it.Not tested
Where this also lives
This fix is also in PiloteBox (https://github.com/PiloteCode/PiloteBox), a tree kept up to date for NVIDIA cards.
@UwUCammie on GitHub · 2026-11-27 00:03 UTC · original
I backported this to the AMD branch in #35. The Windows MSVC regression passed under Wine 11.22 on the RX 7900 XT host fixture with RADV 26.3.1. The generated 48 MiB input found all the expected changes, including byte zero and the last byte, with no extra changed pieces.
@fxceless on GitHub · 2026-11-27 01:36 UTC · original
Merged by hand in
81d54b06(the context had moved on main). Thank you.Pull request closed