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

Merged
CouchRiv merged 1 commit from upstream-pr/2045 into main 2026-10-10 06:12:42 +00:00
CouchRiv commented 2026-10-09 05:45:47 +00:00 (Migrated from github.com)

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_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 (#2046) extends the same test kernel; whichever lands second needs a small rebase.
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4796521650 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2045). Originally posted by [CouchRiv](https://github.com/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_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 <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none. The `v_mullit_f32` flush PR (#2046) extends the same test kernel; whichever lands second needs a small rebase. - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
popcoder565 commented 2026-10-09 15:24:20 +00:00 (Migrated from github.com)

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

  • This PR's tests pass: agc_driver_f32_denormal_flush. None of them reported skipping a case.
  • Full ctest in that build: 514 of 515. The one failure is #2257's new test, which is registered without the Windows PATH setup.

No title was run.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6083905070 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2045#issuecomment-6083905070). Originally posted by [popcoder565](https://github.com/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 onto `main` d70b8998 in one build with 33 other AGC/shader PRs that had no Windows run. - This PR's tests pass: `agc_driver_f32_denormal_flush`. None of them reported skipping a case. - Full ctest in that build: 514 of 515. The one failure is #2257's new test, which is registered without the Windows `PATH` setup. No title was run. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
github-actions[bot] commented 2026-10-09 20:50:01 +00:00 (Migrated from github.com)

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.

Pull request Conflicting files (lines on main) Same exports Same new files
#2312 docs/dev/TechnicalDebt.md L334
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6089025799 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2045#issuecomment-6089025799). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T20:50:01Z. --- <!-- pr-overlap --> 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](https://github.com/boykopovar/AnyPS5/blob/56bfc4d1c90fb1787f16cf39b5bcdfeb21455037/docs/dev/TechnicalDebt.md#L334) | | |
adriadam10 commented 2026-10-10 06:12:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:12:38Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094537021 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2045#issuecomment-6094537021). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T06:12:38Z. --- 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!2045
No description provided.