Recompiler: v_fma_mix* in FLOAT_MODE 0xcc (f16 rounding toward zero) is not implemented; ps5-opengl (PPSA99005) stops at its first draw #2631

Closed
opened 2026-10-10 08:51:55 +00:00 by LeandroLP23 · 6 comments
LeandroLP23 commented 2026-10-10 08:51:55 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-10T08:51:55Z.


ps5-opengl (PPSA99005 v1.0.1, blackbearreloaded/ps5-opengl) stops at its first draw in the shader recompiler:

terminate called after throwing an instance of 'std::runtime_error'
  what():  ShaderRecompiler::Recompile: v_fma_mixlo/mixhi_f16 at pc 884 in FLOAT_MODE 204 (f16 denormals not kept or rounding not to nearest even) is not implemented

FLOAT_MODE 204 is 0xcc: f32 rounds to nearest even with denormals flushed, and f16/f64 keep denormals but round toward zero (FP_ROUND_16_64 = 3). So it is the f16 rounding mode that is missing here, not the denormal handling: FloatInstructions.cpp:221 accepts v_fma_mix* only when FLOAT_MODE & 0xcc is 0xc0 (round to nearest even, denormals kept). Packed f16 instructions have the same check at line 14. Related to #981 (float mode is per shader).

How it gets there: on main 42542127 the title stops at the _umtx_op import. With the three PRs still open on its path on top, #1482 (_umtx_op), #2106 rebased (pthread_sigmask) and #1872 (pthread_set_name_np), plus #2627 (compute headers without specials, merged since), it loads, Mesa reports ready GL=4.6 (Core Profile) Mesa 26.2.0 GLSL=4.60 size=3840x2160, and the first draw stops here (2 of 2 runs).

Radeon 860M (RDNA 3.5), Windows 11 (26300), WinLibs GCC 15.2.0 r7, Release. The title's own log (download0/ps5-opengl.log) also prints the shader that fails, base64-encoded, right after the error.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5789728197 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2631). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-10T08:51:55Z. --- ps5-opengl (PPSA99005 v1.0.1, [blackbearreloaded/ps5-opengl](https://github.com/blackbearreloaded/ps5-opengl)) stops at its first draw in the shader recompiler: ``` terminate called after throwing an instance of 'std::runtime_error' what(): ShaderRecompiler::Recompile: v_fma_mixlo/mixhi_f16 at pc 884 in FLOAT_MODE 204 (f16 denormals not kept or rounding not to nearest even) is not implemented ``` `FLOAT_MODE` 204 is `0xcc`: f32 rounds to nearest even with denormals flushed, and f16/f64 keep denormals but round **toward zero** (`FP_ROUND_16_64` = 3). So it is the f16 rounding mode that is missing here, not the denormal handling: `FloatInstructions.cpp:221` accepts `v_fma_mix*` only when `FLOAT_MODE & 0xcc` is `0xc0` (round to nearest even, denormals kept). Packed f16 instructions have the same check at line 14. Related to #981 (float mode is per shader). How it gets there: on `main` 42542127 the title stops at the `_umtx_op` import. With the three PRs still open on its path on top, #1482 (`_umtx_op`), #2106 rebased (`pthread_sigmask`) and #1872 (`pthread_set_name_np`), plus #2627 (compute headers without specials, merged since), it loads, Mesa reports `ready GL=4.6 (Core Profile) Mesa 26.2.0 GLSL=4.60 size=3840x2160`, and the first draw stops here (2 of 2 runs). Radeon 860M (RDNA 3.5), Windows 11 (26300), WinLibs GCC 15.2.0 r7, Release. The title's own log (`download0/ps5-opengl.log`) also prints the shader that fails, base64-encoded, right after the error. AI-assisted: yes (Claude Code).
AlxcBTW commented 2026-10-10 11:00:45 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-10T11:00:45Z.


Fix: AlxcBTW/AnyPS5#19 (afba6fe4, on main be403084). v_fma_mixlo_f16 and v_fma_mixhi_f16 now round the exact product-sum once in the mode's f16 direction. The sum is already computed in f64 with round to odd; it is scaled by the f16 step, truncated, floored or ceiled, and scaled back. With f16 denormals flushed they still throw. Packed f16 is unchanged.

TechnicalDebt records one directed row measured on gfx1036: -1.5 * 2^-24 + 2^-126 gives 0x8002 with f16 rounding toward -infinity. This change gives 0x8002 too. Round toward zero, the mode ps5-opengl uses, and toward +infinity follow the same rule but are not measured. Full CI passed, merged onto main 507f49fb. I can't open it as a PR while intake is limited, so it's here if a collaborator wants to cherry-pick it.

Tested on Windows 11 with an RTX 5070 Laptop and a Radeon 880M:

  • agc_driver_mix_precision gains ten rows, each run in all four rounding modes. Their expected values are the exact product-sum rounded with Python fractions.
  • vector_fused_multiply_add now expects the directed modes to be translated and checks the rounding field in the mode operand.
  • The 48 agc_driver float tests pass on both GPUs.
  • With the change, PPSA99005 gets past pc 884 and creates its next pipelines. It then ends at its own 2 s wait for a submission to retire, while the driver compiles a large pixel shader.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6096804041 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2631#issuecomment-6096804041). Originally posted by [AlxcBTW](https://github.com/AlxcBTW) on 2026-10-10T11:00:45Z. --- Fix: [AlxcBTW/AnyPS5#19](https://github.com/AlxcBTW/AnyPS5/pull/19) (`afba6fe4`, on `main` be403084). `v_fma_mixlo_f16` and `v_fma_mixhi_f16` now round the exact product-sum once in the mode's f16 direction. The sum is already computed in f64 with round to odd; it is scaled by the f16 step, truncated, floored or ceiled, and scaled back. With f16 denormals flushed they still throw. Packed f16 is unchanged. TechnicalDebt records one directed row measured on gfx1036: `-1.5 * 2^-24 + 2^-126` gives `0x8002` with f16 rounding toward -infinity. This change gives `0x8002` too. Round toward zero, the mode ps5-opengl uses, and toward +infinity follow the same rule but are not measured. [Full CI](https://github.com/AlxcBTW/AnyPS5/actions/runs/38045851809) passed, merged onto `main` 507f49fb. I can't open it as a PR while intake is limited, so it's here if a collaborator wants to cherry-pick it. Tested on Windows 11 with an RTX 5070 Laptop and a Radeon 880M: - `agc_driver_mix_precision` gains ten rows, each run in all four rounding modes. Their expected values are the exact product-sum rounded with Python `fractions`. - `vector_fused_multiply_add` now expects the directed modes to be translated and checks the rounding field in the mode operand. - The 48 `agc_driver` float tests pass on both GPUs. - With the change, PPSA99005 gets past pc 884 and creates its next pipelines. It then ends at its own 2 s wait for a submission to retire, while the driver compiles a large pixel shader. AI-assisted: yes (Claude Code).
SleglJan commented 2026-10-10 12:21:01 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-10T12:21:01Z.


Measured on RDNA2 hardware (gfx1036, Ryzen 7950X3D iGPU, tools/hw-oracle) and compared with main 197ffac9 and with AlxcBTW/AnyPS5#19 (afba6fe4, cherry-picked onto it). Both ran through KernelReplay, on the same iGPU through RADV (Mesa 26.2.4) and on an RTX 3080 (NVIDIA 615.71.09). Linux (CachyOS, kernel 7.2.9, GCC 16.2.1), Release with ANYPS5_ENABLE_SPIRV_TOOLS=ON.

With #19, rounding toward zero (0xcc, the mode ps5-opengl uses) and toward +∞, which #19 lists as not measured, match the hardware on all 2,233 rows on both hosts. The TechnicalDebt row (-1.5 * 2^-24 + 2^-126) gives 0x8002 toward −∞ and 0x8001 in the other three directions, on the hardware and with #19.

Rows:

  • 1,200 f32 values 0 to 7 eighths of an f16 ulp away from an f16 value (304 in the f16 subnormal range, both signs), times 1.0, plus +0 or −0.
  • 1,000 products of random f32 factors, with a random addend or one that partly cancels the product.
  • 33 edge rows: 65504 to 70000 and −65520, values from 2^-26 to 2^-14 − 2^-25 (including the ties 2^-25, −2^-25, 1.5 × 2^-24 and 2^-14 − 2^-25), infinities, ∞ − ∞, NaN, an f32 denormal, exact cancellations and the TechnicalDebt row.

Each row runs through four forms: v_fma_mixlo_f16 and v_fma_mixhi_f16 with three f32 sources, v_fma_mixlo_f16 with f16 lo × f16 hi + f32, and v_fma_mixlo_f16 with f32 × f16 lo + f16 hi. The f16 sources are a random normal f16 pair from [−4, 4] in every row, so those two forms gave no zero or subnormal result. The mode keeps f16 denormals and flushes f32 denormals (0xc0 | round16 << 2), at IEEE=0.

Rows that differ from the hardware (of 2,233) to nearest even toward +∞ toward −∞ toward zero (0xcc)
main 0 not implemented not implemented not implemented
with #19 0 0 2 0

The counts are the same on both hosts. With #19, round to nearest even and toward zero also give 0 at IEEE=1, and toward zero gives 0 with f32 denormals kept.

  • The two rows toward −∞ are exact cancellations with f32 sources: 1.0 * 1.0 + -1.0 and 2.0 * 1.0 + -2.0. The hardware gives −0 (0x8000 in the low half for mixlo, 0x8000 in the high half for mixhi), as IEEE 754 does for an exact zero sum rounded toward −∞; #19 gives +0.
  • With f16 denormals flushed, #19 still stops with v_fma_mixlo/mixhi_f16 at pc 84 in FLOAT_MODE 12 (f16 denormals not kept) is not implemented, as its description says.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6097429058 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2631#issuecomment-6097429058). Originally posted by [SleglJan](https://github.com/SleglJan) on 2026-10-10T12:21:01Z. --- Measured on RDNA2 hardware (gfx1036, Ryzen 7950X3D iGPU, `tools/hw-oracle`) and compared with `main` 197ffac9 and with AlxcBTW/AnyPS5#19 (afba6fe4, cherry-picked onto it). Both ran through [`KernelReplay`](https://github.com/SleglJan/AnyPS5/blob/audit/oracle-2026-10-08/oracle-audit/KernelReplay.cpp), on the same iGPU through RADV (Mesa 26.2.4) and on an RTX 3080 (NVIDIA 615.71.09). Linux (CachyOS, kernel 7.2.9, GCC 16.2.1), Release with `ANYPS5_ENABLE_SPIRV_TOOLS=ON`. With #19, rounding toward zero (0xcc, the mode ps5-opengl uses) and toward +∞, which #19 lists as not measured, match the hardware on all 2,233 rows on both hosts. The TechnicalDebt row (`-1.5 * 2^-24 + 2^-126`) gives 0x8002 toward −∞ and 0x8001 in the other three directions, on the hardware and with #19. Rows: - 1,200 f32 values 0 to 7 eighths of an f16 ulp away from an f16 value (304 in the f16 subnormal range, both signs), times 1.0, plus +0 or −0. - 1,000 products of random f32 factors, with a random addend or one that partly cancels the product. - 33 edge rows: 65504 to 70000 and −65520, values from 2^-26 to 2^-14 − 2^-25 (including the ties 2^-25, −2^-25, 1.5 × 2^-24 and 2^-14 − 2^-25), infinities, ∞ − ∞, NaN, an f32 denormal, exact cancellations and the TechnicalDebt row. Each row runs through four forms: `v_fma_mixlo_f16` and `v_fma_mixhi_f16` with three f32 sources, `v_fma_mixlo_f16` with f16 lo × f16 hi + f32, and `v_fma_mixlo_f16` with f32 × f16 lo + f16 hi. The f16 sources are a random normal f16 pair from [−4, 4] in every row, so those two forms gave no zero or subnormal result. The mode keeps f16 denormals and flushes f32 denormals (`0xc0 | round16 << 2`), at IEEE=0. | Rows that differ from the hardware (of 2,233) | to nearest even | toward +∞ | toward −∞ | toward zero (0xcc) | |---|---|---|---|---| | `main` | 0 | not implemented | not implemented | not implemented | | with #19 | 0 | 0 | 2 | 0 | The counts are the same on both hosts. With #19, round to nearest even and toward zero also give 0 at IEEE=1, and toward zero gives 0 with f32 denormals kept. - The two rows toward −∞ are exact cancellations with f32 sources: `1.0 * 1.0 + -1.0` and `2.0 * 1.0 + -2.0`. The hardware gives −0 (0x8000 in the low half for `mixlo`, 0x8000 in the high half for `mixhi`), as IEEE 754 does for an exact zero sum rounded toward −∞; #19 gives +0. - With f16 denormals flushed, #19 still stops with `v_fma_mixlo/mixhi_f16 at pc 84 in FLOAT_MODE 12 (f16 denormals not kept) is not implemented`, as its description says. AI-assisted: yes (Claude Code)
AlxcBTW commented 2026-10-10 12:55:01 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-10T12:55:01Z.


@SleglJan thank you for the measurement. I fixed the two rows toward −∞ in AlxcBTW/AnyPS5#19 (a83dadf9, on top of afba6fe4; full CI passed). The f64 sum is computed to nearest, so an exact cancellation like 1.0 * 1.0 + -1.0 came out +0. In that mode an exact zero sum now gives −0 unless both the product and the addend are +0, as IEEE 754 does for rounding toward −infinity. A nonzero sum that rounds to zero keeps its sign, so a tiny positive sum still gives +0.

agc_driver_mix_precision gains six rows for this: both of your cancellations, +0 + −0, −0 + −0, and ±2^-26 (a tiny positive gives +0 toward −∞ and a tiny negative gives 0x8001). They pass on an RTX 5070 Laptop and a Radeon 880M.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6097718348 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2631#issuecomment-6097718348). Originally posted by [AlxcBTW](https://github.com/AlxcBTW) on 2026-10-10T12:55:01Z. --- @SleglJan thank you for the measurement. I fixed the two rows toward −∞ in AlxcBTW/AnyPS5#19 (`a83dadf9`, on top of `afba6fe4`; [full CI](https://github.com/AlxcBTW/AnyPS5/actions/runs/38052154731) passed). The f64 sum is computed to nearest, so an exact cancellation like `1.0 * 1.0 + -1.0` came out +0. In that mode an exact zero sum now gives −0 unless both the product and the addend are +0, as IEEE 754 does for rounding toward −infinity. A nonzero sum that rounds to zero keeps its sign, so a tiny positive sum still gives +0. `agc_driver_mix_precision` gains six rows for this: both of your cancellations, `+0 + −0`, `−0 + −0`, and ±2^-26 (a tiny positive gives +0 toward −∞ and a tiny negative gives 0x8001). They pass on an RTX 5070 Laptop and a Radeon 880M. AI-assisted: yes (Claude Code).
AlxcBTW commented 2026-10-10 13:15:31 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-10T13:15:31Z.


A second title stops here: PokeMMO Prospero (PPSA98001) on Windows. With its imports added (#1482, #2106, #1872 and siglongjmp from AlxcBTW/AnyPS5#23), it stops after about 6 s at v_fma_mixlo/mixhi_f16 at pc 116 in FLOAT_MODE 204 … is not implemented. With AlxcBTW/AnyPS5#19 (a83dadf9) on top, it stays up for the full 40 s and draws its start screen at about 54 FPS on an RTX 5070 Laptop.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6097885704 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2631#issuecomment-6097885704). Originally posted by [AlxcBTW](https://github.com/AlxcBTW) on 2026-10-10T13:15:31Z. --- A second title stops here: PokeMMO Prospero (PPSA98001) on Windows. With its imports added (#1482, #2106, #1872 and `siglongjmp` from AlxcBTW/AnyPS5#23), it stops after about 6 s at `v_fma_mixlo/mixhi_f16 at pc 116 in FLOAT_MODE 204 … is not implemented`. With AlxcBTW/AnyPS5#19 (`a83dadf9`) on top, it stays up for the full 40 s and draws its start screen at about 54 FPS on an RTX 5070 Laptop. AI-assisted: yes (Claude Code).
SleglJan commented 2026-10-10 14:35:15 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-10T14:35:15Z.


Rerun of the same sweep at a83dadf9 (both commits of AlxcBTW/AnyPS5#19 cherry-picked onto main 197ffac9). Same hosts and setup as above.

  • 0 of the 2,233 rows differ from the hardware in any of the four f16 rounding modes, for all four forms, on RADV and on the RTX 3080. That includes the two exact cancellations toward −∞.
  • It is also 0 at IEEE=1 (to nearest even and toward zero) and with f32 denormals kept (toward zero).
  • With f16 denormals flushed (FLOAT_MODE 12), it still stops with the same not-implemented message, as the description says.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6098596549 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2631#issuecomment-6098596549). Originally posted by [SleglJan](https://github.com/SleglJan) on 2026-10-10T14:35:15Z. --- Rerun of the same sweep at a83dadf9 (both commits of AlxcBTW/AnyPS5#19 cherry-picked onto `main` 197ffac9). Same hosts and setup as above. - 0 of the 2,233 rows differ from the hardware in any of the four f16 rounding modes, for all four forms, on RADV and on the RTX 3080. That includes the two exact cancellations toward −∞. - It is also 0 at IEEE=1 (to nearest even and toward zero) and with f32 denormals kept (toward zero). - With f16 denormals flushed (FLOAT_MODE 12), it still stops with the same not-implemented message, as the description says. AI-assisted: yes (Claude Code)
AlxcBTW commented 2026-10-10 16:51:44 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-10T16:51:44Z.


Thanks @SleglJan. Your rerun shows #19 at a83dadf9 matching the hardware in all four f16 rounding modes, for all four forms, on RADV and on the RTX 3080: 0 of 2,233 rows differ, including the two exact cancellations toward −∞. FLOAT_MODE 12 (f16 denormals flushed) still stops with the not-implemented message, as intended.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6099900950 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2631#issuecomment-6099900950). Originally posted by [AlxcBTW](https://github.com/AlxcBTW) on 2026-10-10T16:51:44Z. --- Thanks @SleglJan. Your rerun shows #19 at `a83dadf9` matching the hardware in all four f16 rounding modes, for all four forms, on RADV and on the RTX 3080: 0 of 2,233 rows differ, including the two exact cancellations toward −∞. FLOAT_MODE 12 (f16 denormals flushed) still stops with the not-implemented message, as intended. AI-assisted: yes
Sign in to join this conversation.
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#2631
No description provided.