Shaders: atomic subtractions on group memory are loops on NVIDIA #402

Closed
github-bot wants to merge 0 commits from github-bot/gh-402 into main AGit
Owner

@⁠AVD-appezhax on GitHub · 2026-12-01 22:30 UTC · original
AVD-appezhax:fix/atomic-sub-loop-nvidia → main · +250 −0 · 6 files · 72 commits · closed without merging

What it fixes: weather particles never made on NVIDIA

weatherParticle:CS_BeginUpdate (7f61193d2c0e5f22) was refused with E_OUTOFMEMORY in every run, even with the card nearly empty. That is NVIDIA's compiler rejecting an atomic subtraction on group-shared memory. On NVIDIA these subtractions are now emitted as compare-exchange loops.

Port of trustno1-coder/VIctory-NVIDIA#1939 (itself Marvisak/VIctory#3619). One change from upstream: the vendor is read from the adapter the host device is made on (hardware_adapter), not EnumAdapters1(0), which can be an integrated GPU.

Switch: VICTORY_ATOMIC_SUB_LOOP=0/1 overrides the vendor choice. The setting is part of the shader cache key.

How it was measured

RTX 5070 12 GB, release logs.

  • Before: 7f61193d2c0e5f22 refused (E_OUTOFMEMORY) in every run.
  • After: made at the first try (host pipeline shaders=[compute 7f61193d2c0e5f22]).
  • Independently, Aniseto ran the victory-gpu and victory-shader suites at 10d0d7c on a Blackwell 16 GB card (see #335).

Split out of #335 at the maintainers' request; one change per pull request, independent of the others (applies alone on main 94c3c5f).

Checks (this branch alone, on main)

  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean.
  • cargo test -p victory-gpu -p victory-shader --lib --locked: all pass.

🤖 Generated with Claude Code

**@⁠AVD-appezhax** on GitHub · 2026-12-01 22:30 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/402) `AVD-appezhax:fix/atomic-sub-loop-nvidia` → `main` · +250 −0 · 6 files · 72 commits · closed without merging ## What it fixes: weather particles never made on NVIDIA `weatherParticle:CS_BeginUpdate` (`7f61193d2c0e5f22`) was refused with E_OUTOFMEMORY in every run, even with the card nearly empty. That is NVIDIA's compiler rejecting an atomic subtraction on group-shared memory. On NVIDIA these subtractions are now emitted as compare-exchange loops. Port of trustno1-coder/VIctory-NVIDIA#1939 (itself Marvisak/VIctory#3619). One change from upstream: the vendor is read from the adapter the host device is made on (`hardware_adapter`), not `EnumAdapters1(0)`, which can be an integrated GPU. **Switch:** `VICTORY_ATOMIC_SUB_LOOP=0/1` overrides the vendor choice. The setting is part of the shader cache key. ## How it was measured RTX 5070 12 GB, release logs. - Before: `7f61193d2c0e5f22` refused (E_OUTOFMEMORY) in every run. - After: made at the first try (`host pipeline shaders=[compute 7f61193d2c0e5f22]`). - Independently, Aniseto ran the victory-gpu and victory-shader suites at 10d0d7c on a Blackwell 16 GB card (see #335). Split out of #335 at the maintainers' request; one change per pull request, independent of the others (applies alone on `main` 94c3c5f). ## Checks (this branch alone, on main) - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean. - `cargo test -p victory-gpu -p victory-shader --lib --locked`: all pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
weatherParticle:CS_BeginUpdate (compute 7f61193d2c0e5f22) was refused
by the driver with E_OUTOFMEMORY in every run on an RTX 5070, with the
card nearly empty: its dispatch was dropped for the whole session.
NVIDIA's compiler refuses an atomic subtraction on group-shared memory
(atomicrmw sub, or atomicrmw add of a negated value) that way; it is not
memory.

Module::atomic_subtracts rewrites such atomics as a compare-exchange
loop with the same result, in Shader::finish, on an NVIDIA host only
(VICTORY_ATOMIC_SUB_LOOP=1 or =0 overrides). The setting is part of the
shader cache key. The vendor is that of the adapter the host device is
made on (hardware_adapter: the card with the most memory of its own),
not Windows' first adapter, which on a PC with a processor's graphics
may be that one.

Port of trustno1-coder/VIctory-NVIDIA#1939 (itself Marvisak/VIctory#3619
by notquiteog), with the shader cache key adapted to this tree.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 250e7f487f96db03e01e3aa3b1cab751f927521a)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 22:32:53 +00:00
github-bot closed this pull request 2026-12-02 07:54:30 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.