fix(shader): flush v_div_fixup_f16 src1 and src2 by the f16 denormal field #7030
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7030"
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-17T06:23:38Z.
What
v_div_fixup_f16ignored theFLOAT_MODEf16 denormal field. On the GPU, f16 denormal mode 0 or 2 (bit 6 ofFLOAT_MODEclear) 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 splitv_div_fixup_f32has with the f32 field. Sov_div_fixup_f16 0, 0, 0x0001(0x0001 / 0) is the default NaN 0xfe00 there, wheremainwrites +infinity 0x7c00; a denormal numerator over a normal denominator gives a signed zero instead of the quotient. src1 and src2 now go throughflushF16Inputafter their modifiers. Modes 1 and 3, and shaders without a known float mode, are translated as before.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, over the 6859 triples of 19 halves (±0, ±0x0001, ±0x03ff, 0x0200, ±0x0400, ±0.5, ±1, 0x7bff, ±inf, 0x7e00, 0x7d00, 0xfd00), at IEEE 0 and 1:mainvs GPUWith this change every mode also matches with
FP16_OVFL=1, with-src0, -src1, |src2|, withop_sel:[1,1,1,0]and withop_sel:[0,1,0,1]into a register holding another value (0 mismatches each, IEEE 0 and 1). A model that flushes src1 and src2 only matches the GPU in all of these modes; flushing src0 as well gives 245 mismatches per flushing mode, so src0 is kept.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_div_fixup_f16_denormal_modes: the 1000 triples of 10 of those halves (±0, 0x0001, 0x83ff, 0x0200, 0x0400, 1, -inf, 0x7e00, 0x7d00) in f16 denormal modes 0 to 3 at IEEE 0 and 1 and without a known float mode, against the fixup rule above, which matched the GPU on the full 19-value set. Onmainit fails:v_div_fixup_f16 f16 denormal mode 0, IEEE mode on of 0x00000000, 0x00000000, 0x00000001 is 0x00007c00, expected 0x0000fe00. With this change it passes.ctest --parallel 4 --timeout 120onmain6a32550fdwith 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).agc_driver_div_fixup_f16,agc_driver_fp16_overflowandagc_driver_divisionpass.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-17T06:42:03Z.
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.
core/shader/recompiler/Translation/src/FloatInstructions.cppcore/shader/recompiler/Translation/src/FloatInstructions.cppdocs/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.md