Shaders: lower a negated group atomic add to compare-exchange #4595

Open
tyr0nsur wants to merge 1 commit from upstream-pr/4595 into main
tyr0nsur commented 2026-11-30 23:34:02 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tyr0nsur on 2026-11-30T23:34:02Z.


Refs #4449.

What it changes

The driver refuses compute pipeline 7f61193d2c0e5f22 with E_OUTOFMEMORY on affected RTX 50 runs. Inspection on the RTX 5060 Ti found a group-shared atomicrmw add whose operand was a negated value. This adapts the add-of-negation part of #1939 to current main, retaining the old atomic value and repairing the affected control-flow edges. Credits to notquiteog for the original rewrite and Claude Opus 5.5 for the adaptation.

How it was tested

  • In game on RTX 5060 Ti 16 GB, Windows 11. adelmosabba built 913335f0 and repeated the same beach save/load at 1440p, Series X, DLSS Quality and frame generation off. On v2026.11.30.03 that load reported E_OUTOFMEMORY for 7f61193d2c0e5f22. The patched build recorded the host creating that pipeline. Hardware report
  • Rebased head dd7e00a2 on 7d93ee07. The two files changed by the patch are byte-identical to 913335f0. The game result belongs to 913335f0 and measures pipeline creation.
  • Local checks on dd7e00a2, Windows and RTX 4060. cargo test --locked -p victory-shader --lib atomic_adds_of_a_negation_become_loops and cargo test --locked -p victory-shader --lib an_lds_subtraction_takes_the_data_off_and_runs_on_the_card each passed. The full cargo run --locked -q -p xtask -- policy scan passed for 464 files.

Windows CI on dd7e00a2. The check job reached the GPU unit tests and returned TimedOut instead of Done in watch::ask_holds::wait_open_done_covers_immediate_fast_spin_yield_cleared_and_timeout. This timing-sensitive test was also reported on main in #4379. #4629 includes a controlled-clock check and a reproduction of the timeout with a simulated scheduling delay.

Checked for overlap

Related: #1939 and #4449. #1939 was written against the older lowering. This carries the applicable part of its workaround on current main.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5575741791 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4595). Originally posted by [tyr0nsur](https://github.com/tyr0nsur) on 2026-11-30T23:34:02Z. --- Refs #4449. ## What it changes The driver refuses compute pipeline `7f61193d2c0e5f22` with `E_OUTOFMEMORY` on affected RTX 50 runs. Inspection on the RTX 5060 Ti found a group-shared `atomicrmw add` whose operand was a negated value. This adapts the add-of-negation part of #1939 to current main, retaining the old atomic value and repairing the affected control-flow edges. Credits to notquiteog for the original rewrite and Claude Opus 5.5 for the adaptation. ## How it was tested - **In game on RTX 5060 Ti 16 GB, Windows 11.** adelmosabba built `913335f0` and repeated the same beach save/load at 1440p, Series X, DLSS Quality and frame generation off. On v2026.11.30.03 that load reported `E_OUTOFMEMORY` for `7f61193d2c0e5f22`. The patched build recorded the host creating that pipeline. [Hardware report](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4449#issuecomment-7295647932) - **Rebased head `dd7e00a2` on `7d93ee07`.** The two files changed by the patch are byte-identical to `913335f0`. The game result belongs to `913335f0` and measures pipeline creation. - **Local checks on `dd7e00a2`, Windows and RTX 4060.** `cargo test --locked -p victory-shader --lib atomic_adds_of_a_negation_become_loops` and `cargo test --locked -p victory-shader --lib an_lds_subtraction_takes_the_data_off_and_runs_on_the_card` each passed. The full `cargo run --locked -q -p xtask -- policy` scan passed for 464 files. **Windows CI on `dd7e00a2`.** The [check job](https://github.com/trustno1-coder/VIctory-NVIDIA/actions/runs/46540895872/job/142278961513) reached the GPU unit tests and returned `TimedOut` instead of `Done` in `watch::ask_holds::wait_open_done_covers_immediate_fast_spin_yield_cleared_and_timeout`. This timing-sensitive test was also reported on main in #4379. #4629 includes a controlled-clock check and a reproduction of the timeout with a simulated scheduling delay. ## Checked for overlap Related: #1939 and #4449. #1939 was written against the older lowering. This carries the applicable part of its workaround on current main.
tyr0nsur commented 2026-12-01 00:10:33 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tyr0nsur on 2026-12-01T00:10:33Z.


More evidence for this change (on 913335f0, which the rebased head keeps byte-identical in the two files):

  • Whole archive, before and after. victory translate shaders.rpf --validate --list over all 26,084 programs (VICTORY_HOST_WAVE=32) with main (e1251c31) and with the patch: exactly one program's output changes, 7f61193d2c0e5f22 (d3d51ed6b64543d6 → e2266fb29a574b64). 25,622 validated in both, with no validator error. No other program has an add of a negation on group memory.
  • --pipelines on an RTX 4060 (driver 621.14) for that program: created before and after. The RTX 40 card takes both forms, so the change costs nothing there.
  • Whole victory-shader lib suite on the RTX 4060: 536 passed, 1 failed, split_lds_wave32_read_after_read_barrier_coalescing_and_parity. That test already fails on main (#4296, #4320) and failed the same way on another branch here.
  • Across all 793 merged PRs, #1939 is the only one whose change is neither in main nor reverted on purpose (#4449). So this brings back the one missing piece.

AI-assisted with Claude Code.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7296019900 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4595#issuecomment-7296019900). Originally posted by [tyr0nsur](https://github.com/tyr0nsur) on 2026-12-01T00:10:33Z. --- More evidence for this change (on `913335f0`, which the rebased head keeps byte-identical in the two files): - **Whole archive, before and after.** `victory translate shaders.rpf --validate --list` over all 26,084 programs (`VICTORY_HOST_WAVE=32`) with `main` (e1251c31) and with the patch: **exactly one program's output changes**, `7f61193d2c0e5f22` (`d3d51ed6b64543d6` → `e2266fb29a574b64`). 25,622 validated in both, with no validator error. No other program has an add of a negation on group memory. - **`--pipelines` on an RTX 4060** (driver 621.14) for that program: created before and after. The RTX 40 card takes both forms, so the change costs nothing there. - **Whole `victory-shader` lib suite on the RTX 4060**: 536 passed, 1 failed, `split_lds_wave32_read_after_read_barrier_coalescing_and_parity`. That test already fails on `main` (#4296, #4320) and failed the same way on another branch here. - Across all 793 merged PRs, #1939 is the only one whose change is neither in `main` nor reverted on purpose (#4449). So this brings back the one missing piece. AI-assisted with Claude Code.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/4595:upstream-pr/4595'
git switch 'upstream-pr/4595'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/4595'
git switch 'upstream-pr/4595'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/4595'
git switch 'upstream-pr/4595'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/4595'
git switch 'main'
git merge --squash 'upstream-pr/4595'
git switch 'main'
git merge --ff-only 'upstream-pr/4595'
git switch 'main'
git merge 'upstream-pr/4595'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
trustno1-coder/VIctory-NVIDIA!4595
No description provided.