shaders(emit): rewrite LDS atomic subtracts for NVIDIA compiler #62
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: launcher
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
run report
security: hold
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs gpu test
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/Androtim--MiniVI!62
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/62/head"
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?
@Androtim on GitHub · 2026-11-28 18:17 UTC · original
Androtim:feat/iter76-nvidia-lds-atomic-sub→main· +215 −0 · 4 files · 1 commits · merged 2026-11-29 04:46 UTCSummary
Rewrites group-shared (LDS) atomic subtracts in
victory-shader(crates/victory-shader/src/emit/lower.rsandbitcode.rs) so NVIDIA drivers accept pipelines such asweatherParticle:CS_BeginUpdate:Module::negatedincrates/victory-shader/src/emit/bitcode.rsto detect integer negations (sub 0, x).Lower::ds_atomic, rewrites bothRmw::SubandRmw::Addof a negated operand viaLower::lds_subtract, emittingx * waveReadLaneFirst.i32(-1)(flags::WAVE_OPS) andatomicrmw addinstead of an atomic subtract that NVIDIA's driver (621.x) rejects withE_OUTOFMEMORY.emit::lds_sub_tests::lds_subtracts_make_pipelines_and_give_the_console_old_values(crates/victory-shader/src/emit/lds_sub_tests.rs, wired inemit/mod.rs).Upstream reference:
Hasusmogus/cool_fox@5b8e20c(#129).Rig Specs Tested On
Run Settings & Profile
release&diagnostics@50b4481series-s—quality(0.6666667, 540p internal / 960x540 captured frames)offDLSS quality(Streamline 2.14.16)offVICTORY_*Overrides:verify-world.ps1(WorldSeconds=75,AutoNudgeMenu,VICTORY_CACHE_DIR=D:\victory-data\cache-minivi)first_world_frame=8664, 75s in-world / 15 windows, up to11503draws/frame)Measurements & Verification
11.4 fpsmedian (9.95 fpsmean,0.9 fpsmin,87.5 msmedian frame time;+2.50 fpsvs8.9 fpsbaseline)framegen=false)5775 MBpeak (5743.5 MBmedian) /6820 MBmin budget (0 MBover budget;-89 MBvs5864 MBbaseline)43980uploaded,1719final waiting (-5402vs7121baseline);258median pipeline drops (261.0baseline);mapped()rate33.17 ms/s(longest15.2 ms); visually verified19/24lit frames (luma=105.86,edge_energy=7.01,0.0%near-black/magenta; note run 1 hit transient285pipeline drops vs261.0baseline with 0OUTOFMEMORYerrors, rerunr2passed11/11gates cleanly).0(no_host_texture_errors=0,untranslated_shaders=2)cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy(298 files ok)cargo +1.98.1-x86_64-pc-windows-gnu test -p xtask --locked(6 passed; 0 failed)cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --locked -- -D warningscargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics --locked -- -D warningscargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib lds_sub_tests --locked -- --nocapture --test-threads=1(1 passed; 0 failedon RTX 4060 Ti 32-lane hardware)cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib wave64_tests --locked -- --test-threads=1(12 passed; 0 failed)cargo +1.98.1-x86_64-pc-windows-gnu build --release -p victory --bin victory --locked+objdump -p(Windows system DLLs only)@Androtim on GitHub · 2026-11-28 18:35 UTC · original
Automated triage for the maintainers (not an approval).
Verdict:
needs-gpu-test· CI (check):passingReview Summary
Logic, DXIL emission, and test coverage look clean, and CI is passing. Because this PR modifies shader codegen (
victory-shader) to work around an NVIDIA driver compiler failure on group-shared atomic subtracts, it should get a local real-GPU verification pass before merging.Code Review Notes
crates/victory-shader/src/emit/bitcode.rs(Module::negated): Cleanly matchesOp::Bin(Bin::Sub, zero, x)whereself.int_value(zero) == Some(0)and returnsSome(x).crates/victory-shader/src/emit/lower.rs(Lower::ds_atomic,Lower::lds_subtract):Some(Rmw::Sub)(ds_sub_u32/ds_sub_rtn_u32) andSome(Rmw::Add)with a negated operand (self.s.m.negated(v0)), routing them tolds_subtract.waveReadLaneFirst.i32(-1)(opcode118,Attr::NoUnwind), setsflags::WAVE_OPS, multipliesx * -1(exact modular negation in 32-bit two's complement), and executesatomicrmw add. Sincelds_subtractruns insidebegin_guarded(guard), all active lanes participating in the atomic see-1.crates/victory-shader/src/emit/lds_sub_tests.rs&emit/mod.rs:#[cfg(all(test, windows))]hardware + DXIL validation test covering bothds_sub_rtn_u32andds_add_rtn_u32of0 - (t + 1), verifying pipeline creation, final LDS value (START - total), and that returned old values form an exact chain.Verification Needed
lds_sub_teststest and a local GPU smoke test (especially on NVIDIA 621.x+ drivers whereweatherParticle:CS_BeginUpdatepreviously failed withE_OUTOFMEMORY, and sanity-check on non-NVIDIA GPUs if available).Generated with Antigravity CLI (
agy).@Androtim on GitHub · 2026-11-29 04:46 UTC · original
Automated RTX 4060 Ti 8 GB A/B hardware verification passed (
playtest/wave2vsorigin/main1ab5d84):cargo test(RTX 4060 Ti):victory-shaderlds_sub(1/1),emit::wave64_tests(14/14),victory-gpu(505/505) — 520 passed, 0 failed.scripts/verify-world.ps1, DLSS Quality + golden autosave):77.25 ms) vs 3.20 fps (308.8 ms) baseline (+10.25 fps / 4.2x faster)max_draws=3122vs29940crashes /0DRED6174 / 6903 MB(-25 MBvs baseline,0 MBover budget)final_waiting=7638vs12258(-4620)frame-7969.png,frame-8409.png), no regressions vsorigin/main.