Skip to content

fix(shader): flush v_div_fixup_f32 src1 and src2 denormals - #2045

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
CouchRiv:fix-shader-div-fixup-flush
Oct 10, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
CouchRiv:fix-shader-div-fixup-flush

Conversation

@CouchRiv

@CouchRiv CouchRiv commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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_f32 gave other bits than the hardware whenever its divisor (src1) or dividend (src2) was a denormal:

src0, src1, src2 hardware main
0, 0, 0x00000001 0xffc00000 0x7f800000
0, 0x00000001, 0x3f800000 0x7f800000 0x00000000
0x3f800000, 0x00012345, 0x80000001 0xffc00000 0xbf800000

#1850 left the division steps out of its classification, and TechnicalDebt already noted that on hardware v_div_fixup_f32 flushes only src1 and src2. The recompiler read all three sources unchanged.

v_div_fixup_f32 is now in the "only inputs flushed" group of f32DenormalFlushFor, and reads src1 and src2 through flushF32Denormal. 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 gives 0x00400000. 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_f32 in 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_flush gets 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. On main it 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.
  • Full Release ctest: 497/497 on NVIDIA and on RADV. agc_driver_division (denormals kept) and agc_driver_nan_quieting (0xc0) pass unchanged.
  • A local differential run of 2744 rows against the hardware, in the four combinations of IEEE and f32 denormals: 212 rows differed in each flushing mode on main, none now, on NVIDIA and RADV.
  • check_conventions.py and git diff --check pass.

Not tested: a title run; f32 denormal modes 1 and 2 still throw, as before.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none. The v_mullit_f32 flush PR (fix(shader): flush v_mullit_f32 denormals in the float modes that flush them #2046) extends the same test kernel; whichever lands second needs a small rebase.
  • AI-assisted: yes

🤖 Generated with Claude Code

With f32 denormals flushed, as in the 0xc0 float mode titles use, the
hardware flushes the denominator and numerator of v_div_fixup_f32 but
keeps a denormal quotient and result. The recompiler kept all three,
so a denormal divisor gave the quotient back instead of an infinity.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@popcoder565

Copy link
Copy Markdown
Contributor

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 onto main d70b899 in one build with 33 other AGC/shader PRs that had no Windows run.

No title was run.

🤖 Addressed by Claude Code

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
#2312 docs/dev/TechnicalDebt.md L334

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked v_div_fixup_f32 on 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.

@adriadam10
adriadam10 merged commit 9bb5619 into boykopovar:main Oct 10, 2026
6 of 7 checks passed
SleglJan pushed a commit to SleglJan/AnyPS5 that referenced this pull request Oct 10, 2026
…-flush

fix(shader): flush v_div_fixup_f32 src1 and src2 denormals
@CouchRiv
CouchRiv deleted the fix-shader-div-fixup-flush branch October 29, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants