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

Open
github-bot wants to merge 1 commit from github-bot/gh-4595 into main AGit
Owner

@⁠tyr0nsur on GitHub · 2026-11-30 23:34 UTC · original
tyr0nsur:claude/atomic-add-of-negation-loop → main · +170 −0 · 2 files · 1 commits · open

Refs #4450.

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 #4380. #4630 includes a controlled-clock check and a reproduction of the timeout with a simulated scheduling delay.

Checked for overlap

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

**@⁠tyr0nsur** on GitHub · 2026-11-30 23:34 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4595) `tyr0nsur:claude/atomic-add-of-negation-loop` → `main` · +170 −0 · 2 files · 1 commits · open Refs #4450. ## 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://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/issues/4450) - **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 #4380. #4630 includes a controlled-clock check and a reproduction of the timeout with a simulated scheduling delay. ## Checked for overlap Related: #1939 and #4450. #1939 was written against the older lowering. This carries the applicable part of its workaround on current main.
weatherParticle:CS_BeginUpdate (7f61193d2c0e5f22) is refused with
E_OUTOFMEMORY at pipeline creation on every RTX 50 log from the
v2026.11.30 builds (#4449): NVIDIA's compiler takes an atomicrmw add of a
negated value on group-shared memory for the subtraction it is. #1939
(Marvisak/VIctory#3619 by notquiteog) rewrote that as a compare-exchange
loop; it shows as merged on 2026-11-30 but its commit is not in main, and
it no longer builds there (Rmw::Sub is gone). main's Lower::lds_sub covers
the console's ds_sub_u32 only.

Module::atomic_subtracts and is_negation come back from #1939 for the add
of a negation (0 - x, x * -1, ~x + 1); its atomicrmw sub case is gone with
Rmw::Sub. It runs on every host, as lds_sub does, before the module
clean-up reads the flags. The translator fingerprint covers the change, so
no cache key of its own is needed.

Co-Authored-By: notquiteog <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 23:35:53 +00:00
github-bot force-pushed github-bot/gh-4595 from 913335f012 to dd7e00a2c9 2026-12-01 00:05:34 +00:00 Compare
Author
Owner

@⁠tyr0nsur on GitHub · 2026-12-01 00:10 UTC · original

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 (#4297, #4321) 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 (#4450). So this brings back the one missing piece.

AI-assisted with Claude Code.

**@⁠tyr0nsur** on GitHub · 2026-12-01 00:10 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4595#issuecomment-7296019900) 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` (#4297, #4321) 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 (#4450). So this brings back the one missing piece. AI-assisted with Claude Code.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/4596/head:github-bot/gh-4595'
git switch 'github-bot/gh-4595'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4595'
git switch 'github-bot/gh-4595'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4595'
git switch 'github-bot/gh-4595'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4595'
git switch 'main'
git merge --squash 'github-bot/gh-4595'
git switch 'main'
git merge --ff-only 'github-bot/gh-4595'
git switch 'main'
git merge 'github-bot/gh-4595'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

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