fix(shader): flush v_div_fixup_f32 src1 and src2 denormals #2045
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2045"
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 boykopovar/AnyPS5. Originally posted by CouchRiv on 2026-10-09T05:45:47Z.
fix(shader): flush v_div_fixup_f32 src1 and src2 denormals
What
Part of #981 (FLOAT_MODE family), a follow-up to #1850. With f32 denormals flushed,
v_div_fixup_f32gave other bits than the hardware whenever its divisor (src1) or dividend (src2) was a denormal:main0,0,0x000000010xffc000000x7f8000000,0x00000001,0x3f8000000x7f8000000x000000000x3f800000,0x00012345,0x800000010xffc000000xbf800000#1850 left the division steps out of its classification, and TechnicalDebt already noted that on hardware
v_div_fixup_f32flushes only src1 and src2. The recompiler read all three sources unchanged.v_div_fixup_f32is now in the "only inputs flushed" group off32DenormalFlushFor, and reads src1 and src2 throughflushF32Denormal. src0 (the quotient) is read as raw bits, so a denormal quotient and the result are kept, as on hardware:(0x80400000, 1.0, 2^-126)still gives0x00400000. With f32 denormals kept nothing changes.Measured on RDNA2 (gfx1036, the same family as the gfx1035 used for #1850) with the HW oracle, all float controls set: 6859 rows (19 values per operand, 5 of them denormals) with f32 denormals flushed and kept, at IEEE=0 and IEEE=1. Flushing src1 and src2 matches every row. Flushing src0 too, or also the result, misses 300 rows in each flushing mode.
Which title needs it
Titles run their shaders with f32 denormals flushed: TechnicalDebt's float mode entry records it for Astro's Playroom's 0xc0, and a shader without a known float mode is translated the same way. This changes the result of
v_div_fixup_f32in that mode, the last step of the precise f32 division sequence (v_div_scale,v_div_fmas,v_div_fixup). No specific title run was done: we have no title copy to run.Tested
CachyOS Linux, GCC 16.2, RTX 4070 Ti (NVIDIA 615.71.09) and Radeon 610M (RADV, Mesa 26.2.4).
agc_driver_f32_denormal_flushgets a 17th result,v_div_fixup_f32 v26, v4, v5, v6, on the test's 32 rows, captured on hardware with f32 denormals flushed. 16 of the 32 lanes differ from the hardware's result with denormals kept. Onmainit fails on both drivers (lane 2 no float mode v_div_fixup_f32 v26, v4, v5, v6 is 0xbf800000, expected a NaN); with the change it passes, in under a second.agc_driver_division(denormals kept) andagc_driver_nan_quieting(0xc0) pass unchanged.main, none now, on NVIDIA and RADV.check_conventions.pyandgit diff --checkpass.Not tested: a title run; f32 denormal modes 1 and 2 still throw, as before.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)v_mullit_f32flush PR (#2046) extends the same test kernel; whichever lands second needs a small rebase.🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:24:20Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
254f354e, merged ontomaind70b8998in one build with 33 other AGC/shader PRs that had no Windows run.agc_driver_f32_denormal_flush. None of them reported skipping a case.PATHsetup.No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T20:50:01Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/TechnicalDebt.mdL334Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:12:38Z.
Checked
v_div_fixup_f32on the HW oracle (gfx1035): 13824 operand triples (zeros, ±1, denormals of both signs, min/max normals, inf, quiet and signaling NaNs) at IEEE=0/1 with f32 denormals flushed and kept, plain and with-v4, -|v5|, |v6|: all match this PR's translation bit for bit. Scoped build + ctest green on RADV, the new column fails without the change, and the test passes on CI's lavapipe. Merging.