Shaders: an atomic subtraction on group memory is a compare-exchange loop on NVIDIA (port of Marvisak/VIctory#3619) #1939
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1939"
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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by futurepro62 on 2026-11-29T03:35:42Z.
Port of Marvisak/VIctory#3619 by @notquiteog (commit
47bdeca, author kept) onto this fork'smain.Problem
On NVIDIA cards one of the title's compute pipelines is never made:
weatherParticle:CS_BeginUpdate(compute7f61193d2c0e5f22). The driver refuses it withE_OUTOFMEMORYin every run:So its dispatches are dropped. Upstream found the cause: NVIDIA's compiler rejects an atomic subtraction on group-shared memory (
atomicrmw sub, oratomicrmw addof a negated value). It isn't really memory.Change (as upstream, adapted)
Module::atomic_subtracts(emit/bitcode.rs) rewrites those atomics as a compare-exchange loop with the same result. It runs inShader::finishbefore the flags are read (emit/shader.rs).0x10DE,host::default_adapter_vendor).VICTORY_ATOMIC_SUB_LOOP=1or=0overrides it. Other hosts get exactly today's code.shader_cache.rsdiffers from upstream's.host_settings()is added next toKEYED, and the switch goes intobuild()'s key bytes (atomic_sub_loops=), so translations made with and without it are never mixed.victory translatesets it only withVICTORY_ATOMIC_SUB_LOOP=1, because that tool doesn't linkvictory-gpuhere.Testing
On this branch (
main568c5e5+ this commit):cargo build --release --locked -p victory: ok (the warnings are all in files this doesn't touch).cargo test --release --locked -p victory-gpu --lib shader_cache: 4 passed, 0 failed (includes the keyed-switch tests).cargo test --release --locked -p victory-shader --lib atomic: 8 passed, 0 failed.VICTORY_HOST_WAVE=32 VICTORY_VIEW_LIMIT=1000000 [VICTORY_ATOMIC_SUB_LOOP=1] victory translate <game>/shaders.rpf --validate --list. Both give 25,616 validated and 0 validator errors. Exactly one program changes output,weatherParticle:CS_BeginUpdate(7f61193d2c0e5f22), and none is lost.In game, on a local build that is not this branch. Fork
main9300875(2026-11-28 morning) + #339 + #348 (with the fallback-order fix posted there) + this port (1f10565, the same change). Currentmainwasn't played. Earlier today it dropped 75 compute programs on this card (#1435), which made it a poor place to judge a weather effect; that count is down to 2 on568c5e5.victory warm --these <the pipeline>with the port:made ... 1. Without it, every attempt was refused.victory warm, about 76 minutes of play: nopipeline refusedline, no device removal. Frame-time median 71.4 ms (the frame-generation pacing on this setup), mean 71.9 ms, as without the port.Upstream report from the same tests: Marvisak/VIctory#3619 (comment of 2026-11-29).
🤖 Generated with Claude Code
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tupacfan04 on 2026-11-29T06:57:11Z.
Tested on an RTX 5070 12 GB (driver 621.40, Windows 11): this cures the refusal here.
Cherry-picked onto main
e1f2eb6(author kept), freshvictory preload, then four 6-minute Series X runs (1440p, DLSS Quality, no frame generation, 30 cap, ray tracing on).host pipeline refused ... (0x8007000E) shaders=[compute 7f61193d2c0e5f22]e1f2eb6Tests on the cherry-pick: GPU 628 passed, shader 399 passed (8 ignored,
atomic_subtractions_become_loopsamong those passing), loader 50 passed.Three notes from reading the diff, none blocking:
VICTORY_ATOMIC_SUB_LOOP=1is set.atomic_sub_loops=joins the cache key, so everyone on NVIDIA needs a new preload after this lands. Worth a line in the release notes.I could not judge the weather particles by eye (unattended runs), only that the pipeline is now made.
🤖 Generated with Claude Code
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by nick0451 on 2026-11-29T12:57:05Z.
Heads-up for merging: merged onto current main
829188e9, this branch (b6ce5d7e) no longer builds:So
Rmw::Subisn't in main'sbitcode::Rmwany more (or never was on this base). It needs a rebase onto main, or the variant added with it. (Seen while building a batch of shader PRs on main + one local fix; GitHub shows no conflict, because the break is semantic, not textual.)🤖 Generated with Claude Code
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tyr0nsur on 2026-11-30T20:26:28Z.
This PR shows as merged (merge commit
d62c7d55, 2026-11-30 14:12), but that commit is not in the currentmainhistory (e1251c31), andatomic_subtracts/VICTORY_ATOMIC_SUB_LOOPare not in the tree.mainhasLower::lds_subfords_sub_u32instead, andRmw::Subis gone, so a cherry-pick ofb6ce5d7eno longer builds. Meanwhile every RTX 50 log I could find from the v2026.11.30 builds still refuses7f61193d2c0e5f22withE_OUTOFMEMORY, while the one RTX 4060 run that asked for it made it. Details and the per-log table are in #4449.AI-assisted with Claude Code.