fix(shader): round v_fma_mixlo_f16 and v_fma_mixhi_f16 in every f16 rounding mode #3512
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3512"
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 LeandroLP23 on 2026-10-11T12:05:32Z.
Carrying @AlxcBTW's fix for #2631 (AlxcBTW/AnyPS5#19,
afba6fe4anda83dadf9; they can't open PRs yet). The change is theirs, cherry-picked onto currentmainwithout conflicts, authorship kept.What
v_fma_mixlo_f16andv_fma_mixhi_f16threw "not implemented" in any FLOAT_MODE whose f16 rounding isn't to nearest even. They now round the exact product-sum once in the mode's f16 direction: the sum is already computed in f64 with round to odd, then scaled by the f16 step, truncated, floored or ceiled, and scaled back; an exact zero sum gives -0 toward -infinity unless both product and addend are +0. With f16 denormals flushed they still throw, and packed f16 is unchanged. Details in AlxcBTW's comment on #2631.The PS5 OpenGL Showcase (PPSA99005) and PokeMMO Prospero (PPSA98001) stop on it at their first draw (FLOAT_MODE 0xcc, f16 rounding toward zero).
Tested
tools/hw-oracle: 0 of 2,233 rows differ in any of the four f16 rounding modes, for all four instruction forms, on RADV and on an RTX 3080 (comment).agc_driver_mix_precisionandvector_fused_multiply_addpass 3/3 and fail withmain'sSpirvAluEmitterFloat64.cppandFloatInstructions.cpp(the "not implemented" throw);ctest -R agc_372/373 andctest -E agc_459/460, the two failures (agc_driver_f32_compare_constant,windows_exceptions) failing the same way on plainmain. The OpenGL Showcase gets past the shader that stopped it, compiles its pipelines and then ends at its own[ps5-agc] submission retirement failed.Fork CI: https://github.com/LeandroLP23/AnyPS5/actions/runs/38136074002 (Windows fails only
windows_exceptionsand Linux onlyagc_driver_image_address_dimension,agc_driver_image_plane_address_on_line_implicit_lod,guest_kernel_stack_protectand the intermittentagc_driver_depth_fast_clear_submitsegfault, as onmain)Fixes #2631
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)Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-11T12:06:11Z.
@LeandroLP23 thanks for carrying it, and for the RDNA 3.5 run. Both commits match AlxcBTW/AnyPS5#19. If review questions about the rounding come up, I can answer them here.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T12:13:19Z.
Review: COMMENTED
One TechnicalDebt consistency point: the new entry says the f16 round-toward-
+∞and round-toward-zero cases are “not measured,” while the linked #2631 sweep reports zero differences in all four f16 rounding modes across 2,233 rows. Could you clarify whether “not measured” means not measured on PS5 hardware, or adjust that sentence to match the RDNA2 measurement? That would keep the limitation precise.Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-11T12:15:40Z.
@MarcZX100 you're right, that sentence is stale. I wrote it before SleglJan's sweep on #2631, and it never got updated. The sweep was on RDNA2 (gfx1036, through
tools/hw-oracle), not on the PS5's gfx1013.@LeandroLP23 a replacement for the end of the entry, if you want to take it:
The sentences after it (beyond 65504, flushed denormals, packed f16,
FP16_OVFL) stay as they are.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T12:35:42Z.
Thanks, that clarifies the distinction I was asking about: the four rounding modes were measured in the RDNA2 sweep, while gfx1013/PS5 behavior remains unmeasured. The proposed wording captures that accurately.
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-11T12:47:29Z.
Thanks @MarcZX100 and @AlxcBTW. Took AlxcBTW's wording as is in 3f4db6eab: the four modes are recorded as matching RDNA2 (gfx1036) on the #2631 sweep, and gfx1013 as not measured. The sentences after it are unchanged.
Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-11T13:16:22Z.
A third title stops here on
main, on desktop NVIDIA: ProsperoStore (PPSA99000, catalog 1.000.050, sha256 checked,eboot.binandsce_module/libc.prxunwrapped), relinked with--windowsonmaina11c8f7f; Windows 11, RTX 4080 (driver 616.56), WinLibs GCC 15.2.0 r7, Release. Only this PR's three non-test files (23dad485) differ between the runs.main: the store UI starts ([HUI] gl 4.6 ... Mesa 26.2.0, its GL programs build,[STORE] interactive width=3840 height=2160), then after 19 s it aborts withShaderRecompiler::Recompile: v_fma_mixlo/mixhi_f16 at pc 348 in FLOAT_MODE 204 (f16 denormals not kept or rounding not to nearest even) is not implemented[videoout] presentation failed: AGC graphics: last provoking vertex with explicit per-vertex flat interpolation is unsupported(Pipeline.cpp:104), the stop ProsperoTV (#3521) and Stremio Plus (#3493) reach once their imports are in.AI-assisted: yes (Claude Code Opus 5.5 xhigh)
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:36:12Z.
Checked on RDNA2 (gfx1035, IEEE=0) with the HW oracle: 1792 rows (incl. the 16 directed test rows) × the 7 mix forms of
RoundingCode× FLOAT_MODE 0xc0/0xc4/0xc8/0xcc/0xcf/0xf9, bit for bit against the PR's recompiled shader: 0 differences on RADV and on CI's lavapipe. The tests fail withmain's lowering, and dropping the -0 rule, the overflow limit or swapping toward-zero for toward -infinity each failsagc_driver_mix_precision. Merging.