fix(shader): flush v_cvt_pkrtz_f16_f32 and v_pack_b32_f16 f16 denormals #7031
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7031"
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:28:36Z.
What
v_cvt_pkrtz_f16_f32andv_pack_b32_f16ignored theFLOAT_MODEf16 denormal field. On the GPU:v_cvt_pkrtz_f16_f32flushes each half result that is denormal after the conversion to its signed zero when bit 7 ofFLOAT_MODEis clear (f16 denormal modes 0 and 1).v_cvt_pkrtz_f16_f32 0, 0x33800000(2^-24) gives0x00000000there;mainwrites0x00010000.v_pack_b32_f16flushes each denormal half input to its signed zero when bit 6 is clear (modes 0 and 2).v_pack_b32_f16 0x8000, 0x0001gives0x00008000there;mainwrites0x00018000.vCvtPkrtzF16F32now passes both result halves throughflushF16Resultin the modes that flush them, andvPackB32F16passes each half throughflushF16Inputafter its modifiers. Modes that keep them, and shaders without a known float mode, are translated as before.Measured
The same instructions were 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 256 pairs of 16 f32 values around the f16 denormal range (±0, ±2^-24, 1.5 * 2^-24, 2^-25, ±0x387fc000, 0x387fffff, ±2^-14, 0x37730edf, 1, 65520, ±inf) forv_cvt_pkrtz_f16_f32and the 256 pairs of 16 halves (±0, ±0x0001, ±0x03ff, 0x0200, ±0x0400, ±1, 0x7bff, ±inf, 0x7e00, 0x7d00) forv_pack_b32_f16, at IEEE 0 and 1:v_cvt_pkrtz_f16_f32,mainvs GPUv_pack_b32_f16,mainvs GPUWith this change every mode also matches for
v_cvt_pkrtz_f16_f32_e64 v10, -v4, |v5|,v_pack_b32_f16 v10, -v4, |v5|andv_pack_b32_f16 v10, v4, v5 op_sel:[1,1,0](0 mismatches each, IEEE 0 and 1).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_f16_pack_denormal_modes: both instructions over the pairs above in f16 denormal modes 0 to 3 at IEEE 0 and 1 and without a known float mode. The round-toward-zero halves of the 16 f32 values are the GPU's; the flush and the IEEE=1 quieting of0x7d00follow the rule above, which matched the GPU on every pair. Onmainit fails:v_cvt_pkrtz_f16_f32 f16 denormal mode 0, IEEE mode on of 0x00000000 and 0x33800000 is 0x00010000, expected 0x00000000. 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_f16_pack_toward_zeroand the other f16 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