fix(shader): flush v_div_fixup_f64 src1 and src2 by the f64 denormal field #7041

Merged
thuanquang merged 1 commit from upstream-pr/7041 into main 2026-10-17 08:21:50 +00:00
thuanquang commented 2026-10-17 07:15:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-17T07:15:56Z.


What

v_div_fixup_f64 ignored the FLOAT_MODE f16/f64 denormal field. On the GPU, f16/f64 denormal mode 0 or 2 (bit 6 clear) flushes src1 (the denominator) and src2 (the numerator) to a zero of the same sign before the fixup, and keeps a denormal src0 and result in every mode, the same split v_div_fixup_f32 has with the f32 field and #7030 measures for v_div_fixup_f16. So v_div_fixup_f64 0, 2^-1074, 0 is the default NaN 0xfff8000000000000 there where main gives +0, and v_div_fixup_f64 0, 0, 2^-1074 is the default NaN where main gives +inf. vDivFixupF64 now flushes src1 and src2 in those modes, before its zero, infinity and exponent-difference checks. Modes 1 and 3, and shaders without a known float mode, are translated as before.

The flush is a local lambda: #7036 adds a shared flushF64Bits helper, and this PR stays independent of it; whichever lands second can switch to the helper.

Measured

The same instruction was run directly on the GPU with the tools/hw-oracle template, launched through the driver's HIP runtime, at IEEE 0 and 1 over the 1728 triples of 12 f64 values (±0, 2^-1074, -0x000fffffffffffff, 0x0008000000000000, 2^-1022, ±1, 0x7fefffffffffffff, +inf, a quiet and a signaling NaN), and compared with the fixup rule applied to unflushed, src1/src2-flushed and all-flushed sources:

f64 denormal mode no flush src1 and src2 flushed all three flushed
0 450 / 1728 0 / 1728 45 / 1728
1 0 0 0
2 450 / 1728 0 / 1728 45 / 1728
3 0 0 0

Against the recompiler: on main 597 of 1584 rows of a second operand set differ in modes 0 and 2 (0 in modes 1 and 3); with this change 0 in every mode, also for -src0, |src1|, -src2 over the 1728 triples.

Tested

Windows 11 26200, AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.5002, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, ANYPS5_REQUIRE_VULKAN=1:

  • New agc_driver_div_fixup_f64_denormal_modes: the 1000 triples of 10 of those values in f64 denormal modes 0 to 3 at IEEE 0 and 1 and without a known float mode, against the src1/src2-flushed rule above. On main it fails: v_div_fixup_f64 f64 denormal mode 0, IEEE mode on of 0x0000000000000000, 0x0000000000000000, 0x0000000000000001 is 0x7ff0000000000000, expected 0xfff8000000000000. With this change it passes.
  • Full ctest --parallel 4 --timeout 120 on main f8b22edfb with this change: 1368 tests, 2 fail, both failing on main on this GPU too: agc_driver_lds_mixed_width_atomics (#5271) and agc_driver_layered_volume_vertex_no_gpl (#4768). agc_driver_f64_division, agc_driver_f64_division_modifiers and agc_driver_division pass.
  • python tools/check_conventions.py --base origin/main with this title and body passes.
  • Not tested: the PS5's gfx1013, other AMD drivers, NVIDIA, Intel, and titles.

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 under Silent stubs in their library's technical debt file
  • 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
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.5002, Windows 11 26200
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4898191494 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7041). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-17T07:15:56Z. --- ### What `v_div_fixup_f64` ignored the `FLOAT_MODE` f16/f64 denormal field. On the GPU, f16/f64 denormal mode 0 or 2 (bit 6 clear) flushes src1 (the denominator) and src2 (the numerator) to a zero of the same sign before the fixup, and keeps a denormal src0 and result in every mode, the same split `v_div_fixup_f32` has with the f32 field and #7030 measures for `v_div_fixup_f16`. So `v_div_fixup_f64 0, 2^-1074, 0` is the default NaN `0xfff8000000000000` there where `main` gives `+0`, and `v_div_fixup_f64 0, 0, 2^-1074` is the default NaN where `main` gives `+inf`. `vDivFixupF64` now flushes src1 and src2 in those modes, before its zero, infinity and exponent-difference checks. Modes 1 and 3, and shaders without a known float mode, are translated as before. The flush is a local lambda: #7036 adds a shared `flushF64Bits` helper, and this PR stays independent of it; whichever lands second can switch to the helper. ### Measured The same instruction was run directly on the GPU with the `tools/hw-oracle` template, launched through the driver's HIP runtime, at IEEE 0 and 1 over the 1728 triples of 12 f64 values (±0, 2^-1074, -0x000fffffffffffff, 0x0008000000000000, 2^-1022, ±1, 0x7fefffffffffffff, +inf, a quiet and a signaling NaN), and compared with the fixup rule applied to unflushed, src1/src2-flushed and all-flushed sources: | f64 denormal mode | no flush | src1 and src2 flushed | all three flushed | |---|---|---|---| | 0 | 450 / 1728 | 0 / 1728 | 45 / 1728 | | 1 | 0 | 0 | 0 | | 2 | 450 / 1728 | 0 / 1728 | 45 / 1728 | | 3 | 0 | 0 | 0 | Against the recompiler: on `main` 597 of 1584 rows of a second operand set differ in modes 0 and 2 (0 in modes 1 and 3); with this change 0 in every mode, also for `-src0, |src1|, -src2` over the 1728 triples. ### Tested Windows 11 26200, AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.5002, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, `ANYPS5_REQUIRE_VULKAN=1`: - New `agc_driver_div_fixup_f64_denormal_modes`: the 1000 triples of 10 of those values in f64 denormal modes 0 to 3 at IEEE 0 and 1 and without a known float mode, against the src1/src2-flushed rule above. On `main` it fails: `v_div_fixup_f64 f64 denormal mode 0, IEEE mode on of 0x0000000000000000, 0x0000000000000000, 0x0000000000000001 is 0x7ff0000000000000, expected 0xfff8000000000000`. With this change it passes. - Full `ctest --parallel 4 --timeout 120` on `main` `f8b22edfb` with this change: 1368 tests, 2 fail, both failing on `main` on this GPU too: `agc_driver_lds_mixed_width_atomics` (#5271) and `agc_driver_layered_volume_vertex_no_gpl` (#4768). `agc_driver_f64_division`, `agc_driver_f64_division_modifiers` and `agc_driver_division` pass. - `python tools/check_conventions.py --base origin/main` with this title and body passes. - Not tested: the PS5's gfx1013, other AMD drivers, NVIDIA, Intel, and titles. ### Checklist - [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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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 - [x] Unblocks: none - [x] GPUs tested: AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.5002, Windows 11 26200 - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-17 07:30:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T07:30:33Z.


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
PR 5941 docs/dev/debt/shader.md L91-92

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 docs/dev/debt/shader.md
PR 5371 docs/dev/debt/shader.md
PR 5426 docs/dev/debt/shader.md
PR 5500 docs/dev/debt/shader.md
PR 5782 docs/dev/debt/shader.md
PR 6222 docs/dev/debt/shader.md
PR 6235 docs/dev/debt/shader.md
PR 6412 docs/dev/debt/shader.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6231231483 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7041#issuecomment-6231231483). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-17T07:30:33Z. --- <!-- 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 | |---|---|---|---| | [PR 5941](https://www.github.com/boykopovar/AnyPS5/pull/5941) | `docs/dev/debt/shader.md` [L91-92](https://github.com/boykopovar/AnyPS5/blob/52798f71d55ad7104647b5a01558a321c59cbd6c/docs/dev/debt/shader.md#L91-L92) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `docs/dev/debt/shader.md` | | [PR 5371](https://www.github.com/boykopovar/AnyPS5/pull/5371) | `docs/dev/debt/shader.md` | | [PR 5426](https://www.github.com/boykopovar/AnyPS5/pull/5426) | `docs/dev/debt/shader.md` | | [PR 5500](https://www.github.com/boykopovar/AnyPS5/pull/5500) | `docs/dev/debt/shader.md` | | [PR 5782](https://www.github.com/boykopovar/AnyPS5/pull/5782) | `docs/dev/debt/shader.md` | | [PR 6222](https://www.github.com/boykopovar/AnyPS5/pull/6222) | `docs/dev/debt/shader.md` | | [PR 6235](https://www.github.com/boykopovar/AnyPS5/pull/6235) | `docs/dev/debt/shader.md` | | [PR 6412](https://www.github.com/boykopovar/AnyPS5/pull/6412) | `docs/dev/debt/shader.md` |
LeandroLP23 commented 2026-10-17 08:09:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-17T08:09:03Z.


Another AMD driver, since the description lists other AMD drivers as untested.

Windows 11 (26300), Radeon 860M (RDNA 3.5, 1002:1114), driver 32.0.13058.8001, WinLibs GCC 15.2.0, Release, ANYPS5_REQUIRE_VULKAN=1. Tree: main 17cfb1f4c with #7018, #7034, #7036, #7038, #7040, #7041 and #7042 merged together (only docs/dev/debt/shader.md conflicted, for #7040); "main" is the same tree with the six recompiler files reverted to main and the tests kept.

  • agc_driver_div_fixup_f64_denormal_modes: fails on main, passes 3 of 3 with this change.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6231565274 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7041#issuecomment-6231565274). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-17T08:09:03Z. --- Another AMD driver, since the description lists other AMD drivers as untested. Windows 11 (26300), Radeon 860M (RDNA 3.5, `1002:1114`), driver 32.0.13058.8001, WinLibs GCC 15.2.0, Release, `ANYPS5_REQUIRE_VULKAN=1`. Tree: `main` `17cfb1f4c` with #7018, #7034, #7036, #7038, #7040, #7041 and #7042 merged together (only `docs/dev/debt/shader.md` conflicted, for #7040); "`main`" is the same tree with the six recompiler files reverted to `main` and the tests kept. - `agc_driver_div_fixup_f64_denormal_modes`: fails on `main`, passes 3 of 3 with this change. AI-assisted: yes (Claude Code).
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!7041
No description provided.