D3D12-SHADER-RDNA-LEGACY-MAD: restore RDNA LEGACY lowering path in legacy_mad #2624
No reviewers
Labels
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2624
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2624"
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?
@bobcatchris on GitHub · 2026-11-29 18:50 UTC · original
bobcatchris:fix/d3d12-shader-rdna-legacy-mad→main· +24 −2 · 1 files · 1 commits · merged 2026-11-30 15:58 UTCSummary
Restores the
host_rdna() & super::rdna::LEGACYlowering path inlegacy_mad(d3d12/crates/leonida-shader/src/emit/lower.rs), fixing the failingemit::valu_tests::rdna_forms_give_what_the_spelled_out_ones_give(mad_legacy: written alike) test on AMD RDNA hardware onmain(4755667f5).Root Cause
0cc6eee20replacedv_mad_legacy_f32/v_mac_legacy_f32lowering withlegacy_mad(subnormal flushing + fusedfmad+ zero-factor check), which unconditionally emitted the two-compareaz | bzpath and stopped consultinghost_rdna() & super::rdna::LEGACY. On AMD RDNA cards (rdna_card() == true),rdna_forms_give_what_the_spelled_out_ones_givecomparesTEST_RDNA = 0vsTEST_RDNA = rdna::ALLand panics onmad_legacybecause both emit identical DXIL.Fix
Mirror
legacy_mul'shost_rdna() & super::rdna::LEGACYpath insidelegacy_madafter flushing subnormals:orig_a == orig_b, both factors arebounded, or either factor is a finite normal constant.fmin(|a|, |b|) == 0compare (matchinglegacy_mul), preserving subnormal flushing and0 * (inf|NaN) + addend = +0 + addend.Verification
Windows 11
10.0.26200, Rust1.98, AMD Radeon RX 7900 XTX (gfx1100, driver32.0.32029.2010), no game files:main4755667f5:cargo test -p leonida-shader --lib rdna_forms_give_what_the_spelled_out_ones_give->FAILED(assertion left != right failed: mad_legacy: written alike).3f027c6bc:cargo test -p leonida-shader --lib rdna_forms_give_what_the_spelled_out_ones_give->PASS(17.03 s, all 14 RDNA forms across 100 float/Inf/NaN/zero cases on RX 7900 XTX).cargo test -p leonida-shader --lib mad_legacy_takes_a_subnormal_factor_as_a_zero->PASS(0.12 s).python -I scripts/check_no_game_data.py d3d12/crates/leonida-shader/src/emit/lower.rs-> clean.AI-assisted: Antigravity (Gemini 4 Neon).
@merzleckeier on GitHub · 2026-11-29 18:58 UTC · original
Independent AMD recheck of
3f027c6bonmain7c330c76(merge treeb1c422ff). Windows x64diagcross-build, CachyOS, Wine 11.22, VKD3D-Proton71cae091, AMD Raphael iGPU / RADV Mesa 26.3.1.rdna_forms_give_what_the_spelled_out_ones_giveran on hardware in both builds. Plainmainreached themad_legacy: written alikeassertion and failed. The PR passed.mad_legacy_takes_a_subnormal_factor_as_a_zeropassed on both trees.LEGACYpaths gave identical bits on RADV. Forcing the test-onlyLEGACYmask on an RTX 4070 SUPER (620.73.04) changed 10/50 outputs from+0to−0, all in the constant or bounded-factor cases. Production gates this path to AMD RDNA and the documentedLEGACYmode permits zero-sign differences.Synthetic shaders only. AI-assisted with OpenAI Codex.
3f027c6bccto74a2fb5a31@enlight3d on GitHub · 2026-11-30 10:47 UTC · original
RUN (independent run, #2624 head
74a2fb5a3on maine1fe82f63; merged locally withgit merge --no-ff, no conflicts; also no conflict with #2566 head70ea7d6ecpergit merge-tree --write-tree). Main has since moved to012b79a67, which changes onlyd3d12/docs/findings.mdandd3d12/scripts/play-nvidia.ps1, so the crates tested are the same. It still merges cleanly there. The head is the rebase of3f027c6bc, with the same change.Commands, in
d3d12/, target x86_64-pc-windows-msvc, toolchain 1.98.1, all with--locked:cargo test -p leonida-shader --no-fail-fast: green, 385 passed / 0 failed / 4 ignored, as on main. The PR adds no test.mad_legacy_takes_a_subnormal_factor_as_a_zeropasses (hardware and WARP).rdna_forms_give_what_the_spelled_out_ones_giveprints "no RDNA card; skipped" on this card and passes on main and on the merge alike, so the PR's own red does not show here.cargo clippy -p leonida-shader --all-targets(without-D warnings, which already fails on main in leonida-shader), on main and on the merge: no new warning inlower.rs(2 already on main, the same 2 on the merge).v_mad_legacy_f32with the RDNA forms off and on, as that test does, and makes the sameassert_ne!on the two outputs, without the hardware run. On main it fails with "mad_legacy: written alike" (both forms 2,224 bytes, identical). On the merge it passes: the RDNA form is now 2,304 bytes. So the code-generation half of the claim holds.Side effect worth a look: with the RDNA forms off, which is every other host and this NVIDIA card too, the output also changes. It is still 2,224 bytes, but its content differs between main and the merge (one run each). That matches the diff: the
+0 + addendadd now comes before the two compares instead of after them. The suite shows no change in results. Still, every program that usesv_mad_legacy_f32orv_mac_legacy_f32is now written differently on every host, so its translations and pipelines already in a cache are built again. Keeping theplainline inside each branch would leave the non-RDNA output identical to main's.Perf: no (outside RDNA hosts, the same operations in another order).
No runtime/ C++ or Python in this PR, so no link or import check applies.
Machine: Windows 11 Pro 26300, i9-13900K, 64 GB, RTX 3090 24 GB, NVIDIA 621.40.
74a2fb5a31to3c2bfd4294@MoonEyes on GitHub · 2026-11-30 15:58 UTC · original
Verified: independent AMD RDNA hardware check reproduced the main failure and passed with this change; CI and no-game-data checks pass. Ready for merge.