fix(shader): flush v_fma_mix_f32 f16 sources by the f16 denormal field #7040
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7040"
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 thuanquang on 2026-10-17T07:09:29Z.
What
v_fma_mix_f32used its f16 sources (op_sel_hiset) unflushed in every mode; the technical debt entry on f32 denormals says "f16 inputs retain their previous conversion and denormal handling". On the GPU, f16 denormal mode 0 or 2 (bit 6 ofFLOAT_MODEclear) flushes each f16 source to a zero of its sign before the fused multiply-add, whatever the f32 denormal field. Sov_fma_mix_f32 0, 0, 0x0001with all three sources f16 gives0x00000000there;maingives0x33800000(2^-24).readMixF32now passes an f16 source throughflushF16InputValue, asv_cvt_f32_f16already does. f32 sources, modes that keep f16 denormals, and shaders without a known float mode are translated as before.v_fma_mixlo/mixhi_f16sharereadMixF32but still throw in the modes that flush f16 denormals, so they are unchanged.Measured
The same instruction was run directly on the GPU with the
tools/hw-oracletemplate, launched through the driver's HIP runtime, and through the recompiler on Vulkan, at IEEE 0 and 1, with f32 denormal modes 0 and 3 and f16 denormal modes 0 to 3:mainvs GPU, f16 modes 0 and 2op_sel_hi:[1,1,1]), 14 halvesop_sel:[1,1,1])-src0, |src1|, -src2, three f16 sourcesop_sel_hi:[1,0,1]), f32 denormals flushedThe rows left in the last line are not about the f16 field: on
mainthe same form already gives 61 mismatches with f16 denormals kept, and every remaining row (plus 2 that differ only in NaN payload) has an f32 denormal source or an f32 denormal GPU result while f32 denormals are kept (the GPU keeps a result like -2^-140 andf16 inf * f32 0x807fffff= -inf, where the translation gives 0 and NaN). Flushing a denormal f16 addend makes more of those f32 results denormal, which is where the extra 38 rows come from.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:agc_driver_fma_mix_f16_denormal_modes: three f16 sources, and f16 * f32 + f16, over 16 rows (denormal f16 sources, products and sums at the f16 and f32 denormal boundaries, inf * denormal, signed zeros) in f32 denormal modes 0 and 3 with f16 denormal modes 0 to 3 at IEEE 0 and 1, against the GPU's results; none of the expected values is an f32 denormal. Onmainit fails:v_fma_mix_f32 of three f16 sources f32 denormals flushed, f16 denormal mode 0, IEEE mode off of 0x00010000, 0x00000000, 0x3f800000 is 0x33800000, expected 0x00000000. With this change it passes.ctest --parallel 4 --timeout 120onmainf8b22edfbwith this change: 1368 tests, 2 fail, both failing onmainon this GPU too:agc_driver_lds_mixed_width_atomics(#5271) andagc_driver_layered_volume_vertex_no_gpl(#4768). The f16, fma and interpolation tests pass.python tools/check_conventions.py --base origin/mainwith this title and body passes.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T07:30:32Z.
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.
docs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdImported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-17T08:09:02Z.
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:main17cfb1f4cwith #7018, #7034, #7036, #7038, #7040, #7041 and #7042 merged together (onlydocs/dev/debt/shader.mdconflicted, for #7040); "main" is the same tree with the six recompiler files reverted tomainand the tests kept.agc_driver_fma_mix_f16_denormal_modes: fails onmain, passes 3 of 3 with this change.AI-assisted: yes (Claude Code).