Shaders: v_mad/v_mac stay unfused and v_fract stays below 1.0 on NVIDIA #12
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ThatRecompDev--five-star-recomp!12
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/12/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?
@marquezinii on GitHub · 2026-11-24 21:00 UTC · original
marquezinii:shaders/nvidia-fma-rounding→main· +37 −12 · 6 files · 1 commits · merged 2026-11-24 21:44 UTCThe FMA/rounding pair from #9.
fma_mac.v_mad_f32/v_mac_f32(andv_madak/v_madmk) are unfused on AMD: the product is rounded before the add. The translator emitted them asa * b + c. dxc marks that fast and the NVIDIA driver contracts it into one fused operation, so v22/v23 read -2^-46 instead of 0 on the 5070. They now go throughmad_unfusedin the prelude, apreciseproduct and sum. That fixes them without-Gisfor the whole program. The DXIL backend already left them unfused, since it emits no fast flags.v_fma_f32/v_fmac_f32staymad(). NVIDIA fuses that, which is the console result; WARP doesn't. So the case now takes either value for v20/v21 (newExpected.Either) and keeps the strict unfused expectation for v22/v23. That test is the one that fails on the 5070 without the change.round_ldexp.v_fract_f32wasfrac(). On NVIDIA, x - floor(x) of a small negative x rounds to 1.0, where AMD clamps the result to 0x3F7FFFFF.fract_f32adds that clamp, and a NaN stays NaN.I didn't touch cross-instruction contraction: a
v_mul_f32followed by a separatev_add_f32can still be fused by the driver once dxc marks both fast. Doing that everywhere is-Gisorpreciseon every float op, which costs every program, so I left that call to you.Checked:
dotnet test518 passed, 0 failed, no build warnings.FIVESTAR_TEST_ADAPTER=hardware:fma_macandround_ldexppass with dxc and the DXIL backend. The shader cases now fail only insin_large_arg(both backends) andmsfb_ngg_strips_rootdesc, the two items of #9 still open.@ThatRecompDev on GitHub · 2026-11-24 21:44 UTC · original
Merged, thanks! Checked it on our 4090 as well:
fma_macandround_ldexppass there too, and the only cases left failing aresin_large_argandmsfb_ngg_strips_rootdesc, same as on your 5070. Nice that it stays exact without going to-Gisfor everything.