fix(shader): flush f16 compare inputs by the FLOAT_MODE f16 denormal field #7021
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7021"
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:11:52Z.
What
v_cmp_X_f16andv_cmpx_X_f16ignored theFLOAT_MODEf16 denormal field: they compared denormal halves as their exact values in every mode. On the GPU, f16 denormal mode 0 or 2 (bit 6 ofFLOAT_MODEclear) flushes both compare inputs to a zero of the same sign first, sov_cmp_eq_f16 0x0000, 0x0001is true there andv_cmp_lt_f16 0x0000, 0x0001is false. The half branch ofemitFloatComparenow passes both inputs throughflushF16InputValue, which the f16 unary ops andv_cvt_f32_f16already use for the same field. Modes 1 and 3, and shaders without a known float mode, are translated as before.The f64 compares have the same gap and are handled separately by #6850; this PR does not touch them.
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 halves (±0, ±0x0001, ±0x03ff, ±0x0400, ±1, ±inf, 0x7e00, 0x7c01, 0xfe00, 0x7bff), all twelve conditions (eq, ge, gt, le, lg, lt, neq, nge, ngt, nle, nlg, nlt) in VOPC and VOPCX form, at IEEE 0 and 1 with f16 denormal modes 0 to 3:mainvs GPU(each cell is the same for IEEE 0 and 1 and for both forms)
v_cmp_class_f16reports a denormal input as denormal in every mode on the GPU and is left as it is: 200 value and class-bit pairs, f16 denormal modes 0 to 3 at IEEE 0 and 1, 0 mismatches before and after this change.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_vcmp_f16_denormal_modes: both forms, the 256 pairs and twelve conditions above, f16 denormal modes 0 to 3 at IEEE 0 and 1; the expected bits are the GPU's. Onmainit fails:v_cmp_eq_f16 f16 denormal mode 0, IEEE mode on of 0x0000 and 0x0001 is 0x0000, expected 1. With this change it passes. It is laid out likeagc_driver_vcmp_f32_denormal_modes; the expected tables come out identical to that test's because the 16 values have the same order of classes.ctest --parallel 4 --timeout 120onmain6a32550fdwith this change: 1368 tests, 3 fail, all failing onmainon this PC too:agc_driver_lds_mixed_width_atomics(#5271),agc_driver_layered_volume_vertex_no_gpl(#4768) andconventions_function_bodies_shard_4, which times out here because Python takes about 0.4 s to start on this PC.agc_driver_vopc_compare,agc_driver_vopc_compare_table,agc_driver_vop3_compare_modifiers,agc_driver_vcmp_eq_f16_clampandagc_driver_f16_denormal_flushpass.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:41:53Z.
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.md