Shaders: lower ds_rsub_u32 and ds_rsub_rtn_u32 in pure 32-bit DXIL #2116
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!2116
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2116"
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?
@geiyiliyabumo on GitHub · 2026-11-25 05:19 UTC · original
geiyiliyabumo:feat/shader-ds-rsub→main· +128 −1 · 2 files · 1 commits · openSummary
ds_rsub_u32(0x002) andds_rsub_rtn_u32(0x022) incrates/victory-shader/src/emit/lower.rs(fn ds) via anEXEC-guarded pure 32-bitcmpxchgretry loop (new = data0.wrapping_sub(old)) without enablingInt64/WIDE_OPS.vdston inactiveEXEClanes and returns the exchangedoldvalue fords_rsub_rtn_u32.crates/victory-shader/src/emit/semantics_tests.rscovering both opcodes, nonzero byte offsets, wraparound, zero/u32::MAX,EXECmasking, 64-lane concurrent contention, and verifyingInt64is not set.Verification
cargo xtask policy: passedcargo clippy -p victory-shader --tests -- -D warnings: passedcargo test -p victory-shader --lib lds_rsub -- --test-threads=1with Microsoftdxil.dll: 2/2 passed on AMD Radeon RX 9060 XT (RDNA4) and Microsoft Basic Render Driver (WARP)@upipibi on GitHub · 2026-11-25 05:26 UTC · original
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
6d5e03d.victory-shader: 246 passed, 3 failed, 3 ignored. The newlds_rsub_respects_exec_and_returns_the_old_dwordandlds_rsub_serializes_contending_lanespass. The 3 failures are #1744's NVIDIA failures onmain. Same asmainon this hardware.The lowering uses a compare-exchange retry, not an
atomicrmw subof a register. That matters on newer NVIDIA cards: xcl-dev/xcl#1919 found RTX 50 drivers (617 to 621) refusing compute pipelines with a groupshared atomic subtract of a register (E_OUTOFMEMORY), so this form avoids that.AI-assisted (Claude Code).
@fiestorra on GitHub · 2026-11-25 06:23 UTC · original
Checked the operand order, which is the whole risk here: it is
src − old, so the reversal is rightds_rsubis the one instruction in this family where getting the operands the wrong way round produces no error, no refusal and no crash — just a value that is wrong for every lane, forever. So that is what I checked first:new = src − old, and_rtnreturns the exchangedold. That is the reverse subtract the name says. A plainds_addwritten asold − srcwould compile and run too, and nothing in the corpus would notice, so it is worth saying out loud that this one is right.The loop is the standard shape (start
expectedat zero,cmpxchg, on failure retry with the value the exchange returned) and on successold == expected, so the returned value is the pre-exchange dword. Tests on this branch: 249 passed, 3 ignored, and the two that matter by name:The cases I would add, because they are where an unsigned subtract under test coverage goes quietly wrong:
src = 0withold = 0(result zero), andsrc < old(a wrap to a large value). Both are one line each in the same test, and both are the kind of result a reviewer looks at for two seconds and remembers.The same two things I raised on #2113 apply here, and I would rather repeat them once than have them lost between threads:
lower.rsandsemantics_tests.rs); each is clean againstmain, so nothing is broken, but the three of them from the same week are one family and merging two of them will cost a manual resolution. One pull request with the whole family, or a stated order, would be cheaper.No game data is involved: instruction names and test counts.
Written with an AI assistant.
@sinan-cmyk on GitHub · 2026-11-25 08:38 UTC · original
Offline measurement on a retail dump
Result: no count change against
main.I merged head
6d5e03dfontomain940d32f(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 23,918 onmain, 23,918 with this PR.No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.
No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
@steven-seagull27 on GitHub · 2026-11-25 09:18 UTC · original
Tested
6d5e03dfon an RTX 5080 with driver 621.40, following up on the question about RTX 50-series drivers and shared-memory atomic subtraction. The compute pipeline was created successfully and both reverse-subtract tests passed.lds_rsub_respects_exec_and_returns_the_old_dwordlds_rsub_serializes_contending_lanesI ran the PR's compare-exchange implementation on each adapter separately and verified the D3D12 device and completed dispatches. This covers masked execution, the returned old value, and contention on this Blackwell card. Windows 11 build 26300.10075, built-in WARP 10.0.26100.10068. Earlier driver discussion
@Marvisak on GitHub · 2026-11-25 10:44 UTC · original · edited 2026-11-25 22:20 UTC
Automated triage for the maintainers.
Needs rebase. This PR no longer merges cleanly into
main:mainhas moved since the last triage, and the branch now conflicts incrates/victory-shader/src/emit/semantics_tests.rs. It will be reviewed again once it is rebased onto currentmain.Previous verdict for this head: merge candidate.
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.