Shaders: lower a subtract atomic as an add of the wrapping negation #3142
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!3142
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3142"
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?
@Mdemets on GitHub · 2026-11-26 10:06 UTC · original
Mdemets:contrib/atomic-sub→main· +15 −1 · 2 files · 1 commits · openatomicrmw subremoves the WARP device when the LDS subtract atomic is used; lowering it as an add of the wrapping negation is bit-identical and does not.What changes
bitcode.rs:Rmw::Subkeeps its index for LLVM table alignment but is no longer constructed; the comment records why.lower.rs:sub_u32maps toRmw::Add, and the operand is pre-negated with the existingBin::Subagainsti32(0).Why not fix WARP instead
The shader validates and hardware is exact. The device removal is in the D3D12 WARP path for
atomicrmw sub— not something this tree controls.Verification
cargo check -p victory-shader --libclean on63bcca4. I also have a hardware test (a subtract atomic over a per-thread 16-byte slice, readback compared against the wrapping negation) on my test branch; it is not in this PR becauselds_tests.rsno longer exists onmain. Happy to re-home it intomemory_tests.rsif you want it here.Ported from my test branch (commit
cf99d62).@oni-swr on GitHub · 2026-11-26 10:28 UTC · original
WARP test report: head
e9b92c8a(parent / main63bcca43)Coordinated under #1633 (claim: #1633).
Environment (software adapter only, no physical GPU used): Windows 11 Pro 10.0.26200 (UBR 9974);
d3d10warp.dll10.0.26100.9818; SDKdxil.dll1.8.2502.11 (Windows SDK 10.0.26100.0,VICTORY_DXIL);dxc.exe/dxcompiler.dll1.8.2502.11; rustc/cargo 1.98.1.VICTORY_D3D12_WARP=1 VICTORY_WARP=1(the second forces the victory-shader test host onto WARP, which otherwise also opens the default hardware adapter). A temporary local probe confirmed DXGI reports the adapter asMicrosoft Basic Render Driver(flags 0x2 software, vendor 0x1414, 0 dedicated VRAM). Everyhardwarelabel in the output below therefore also ran on WARP. Shared env for all commands:CARGO_TARGET_DIR=D:\victory-3146-3142-warp-target,-j 4.The PR adds no test, so I wrote a temporary local oracle (not pushed) in
semantics_tests.rsusing the existingprobe/checkharness, against the ISA modelMEM[a] = MEM[a] - DATA(wrapping, old value returned by_rtn). 340 inputs per probe (every pair ofU32_EDGESx the first 10), three probes: (1) write[own]=a,ds_sub_rtn_u32 v5, [own], b, read back,ds_sub_u32(no return), read back; (2) the same atoffset:512(out of the LDS allocation: returns 0, write dropped); (3) EXEC-masked lanes (masked-out lanes keep their old register).Parent control (
63bcca4+ the local test):cargo test -p victory-shader --lib -j 4 -- zz_local_lds_sub --nocapture --test-threads 1-> every probe fails withThe GPU device instance has been suspended. Use GetDeviceRemovedReason ...(the WARP device is removed), test FAILED. Reproduces the PR's claim.Head
e9b92c8a: same command ->test ... ok; all three probes reportmodel mismatches [hardware 0, warp 0]over 340 inputs each (both labels WARP), and DXIL passes the validator.cargo test -p victory-shader --lib -j 4: 300 passed, 4 failed, 3 ignored; the 4 failures are the same hardware-onlysynthetic_teststhat fail on the parent with WARP forced (see the #3146 report), unrelated to this PR.cargo test -p victory-gpu --lib --features diagnostics -j 4: 246 passed, 0 failed, 1 ignored.Observations (not blockers): the lowering maps both
sub_u32andsub_rtn_u32toRmw::Addwith the data negated, so the returned old value is unchanged, as the oracle confirms.ds_rsub_*is not touched by this PR and I did not test it.Not run: Clippy,
cargo xtask policy, any real-GPU run (on real hardwareatomicrmw subis reportedly fine, so this was not checked there), and anything using game files.Result: on WARP the parent removes the device and the head computes the ISA result for all 3 probes; no defect found.
AI use: tested by Claude Code (Claude Sonnet 5.5), coordinated by Claude Code (Claude Opus 5.5). No game files, dumps, shader names or hashes were used.
@Dukestar69 on GitHub · 2026-11-26 10:30 UTC · original · approved these changes
Verified on RTX 5090 & WARP against
origin/main(63bcca4):cargo test -p victory-shader --lib atomic -- --test-threads=1: passed on RTX 5090 and WARP.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Bit-identical two's-complement lowering (
atomicrmw add (0 - v0)) that avoids WARP device removal onatomicrmw sub.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.