Shaders: lower ds_inc_u32, ds_inc_rtn_u32, ds_dec_u32, and ds_dec_rtn_u32 in pure 32-bit DXIL #2113
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!2113
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2113"
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:13 UTC · original
geiyiliyabumo:feat/shader-ds-inc-dec→main· +183 −5 · 2 files · 1 commits · openSummary
ds_inc_u32,ds_inc_rtn_u32,ds_dec_u32, andds_dec_rtn_u32incrates/victory-shader/src/emit/lower.rs(fn ds) using anEXEC-guarded pure 32-bitcmpxchgretry loop without enablingInt64/WIDE_OPS.incwrapsold >= limitto0(elseold + 1),decwrapsold == 0 || old > limittolimit(elseold - 1), and_rtnreturns the previous LDS value while inactive lanes preservevdst.crates/victory-shader/src/emit/semantics_tests.rscovering wrap sequences, unsigned edge cases (old > limit), non-returning updates,EXEC-masked destination preservation, and 32-/31-lane concurrent LDS contention, assertingInt64is not set.Verification
cargo xtask policy: passedcargo clippy -p victory-shader --tests -- -D warnings: passedcargo test -p victory-shader --lib lds_wrap_atomics -- --test-threads=1with Microsoftdxil.dll: passed on AMD Radeon RX 9060 XT (RDNA4) and Microsoft Basic Render Driver (WARP) (0 hardware/WARP mismatches, multi-lane LDS contention passed on both)@upipibi on GitHub · 2026-11-25 05:19 UTC · original
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
9c8b9a2.victory-shader: 247 passed, 3 failed, 3 ignored. The newlds_wrap_atomics_update_and_return_under_exec,lds_wrap_atomics_serialize_contending_lanesandlds_wrap_atomics_validate_as_32_bit_dxilpass. The 3 failures are #1744's NVIDIA failures onmain. Same asmainon this hardware.I also read the lowering.
incstoresold >= data ? 0 : old + 1anddecstoresold == 0 || old > data ? data : old - 1, both returningoldthrough a compare-exchange retry. That matchesds_inc_u32/ds_dec_u32.Overlap, from reading: #1606 (open, conflicting with
main) also lowersinc_u32anddec_u32among the other LDS atomics.AI-assisted (Claude Code).
@fiestorra on GitHub · 2026-11-25 06:09 UTC · original
Read the semantics (they look right), measured the three-way collision, and one question about the spin
I checked the arithmetic against the rule this instruction family has, and it matches what I understand of the ISA:
ds_inc_u32:value >= limit → 0, elsevalue + 1;ds_dec_u32:value == 0 || value > limit → limit, elsevalue - 1.which is exactly the shape of the
IUGE/is_zero | IUGTcomparisons in the patch, with the_rtnvariants returning the observed value and theEXECguard keeping inactive lanes out.cargo test -p victory-shader --locked --libon this branch: 250 passed, 3 ignored, 33 of themds_*.One thing I would like to see in the tests, because it is where a wrong reading survives everything else: the boundary pairs.
incatvalue == limitandincatlimit - 1, and the same fordecatlimit,limit + 1and0.>=versus>is one character in the code and the difference is invisible in any test that stays away from the boundary.The question I have is about the retry loop. The patch loops on
cmpxchguntil it succeeds:unbounded. On the console this is one LDS atomic instruction, and the host's version is a compare-exchange spin. Under contention that is normal GPU practice and it terminates — but "normal practice" and "bounded" are not the same thing, and the failure mode when it does not is a TDR and a removed device, which is much harder to diagnose than a wrong value: the log says the device was removed and nothing about which shader was spinning. I am not asking for a bound for its own sake; I am asking for the decision to be written down, either as a comment ("the loop terminates because the address is not contended across the wave" if that is the argument) or as a bounded retry with a defined fallback.
A merge-order thing, measured: this pull request and #2116 and #2119 are three changes to the same
fn dsand to the same test file, and they conflict with each other:Each is clean against
main, so nothing is broken — but whoever merges two of them will spend the time resolving, and the three are the same family from the same author in the same week. If it were mine I would land them as one pull request (they share all their reasoning), or state an order here so the next one is rebased onto the previous instead of being discovered at merge time.No game data is involved: instruction names and test counts.
Written with an AI assistant.
@sinan-cmyk on GitHub · 2026-11-25 08:46 UTC · original
Offline measurement on a retail dump
Result: no count change against
main.I merged head
9c8b9a2bontomain940d32f(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).
@Marvisak on GitHub · 2026-11-25 10:42 UTC · original · edited 2026-11-25 22:21 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/lower.rsandcrates/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.