fix(shader): quiet f64 signaling NaNs only in IEEE mode #2035
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2035"
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 CouchRiv on 2026-10-09T05:35:16Z.
What
Part of #981, follow-up to #1867. The f64 unary instructions always set the quiet bit on a signaling NaN input:
The SPIR-V lowering quiets every f64 NaN, but the hardware does that only with
IEEE_MODE=1, the same rule #1867 measured for f32 and f16. Translation now followsGuestContext::floatMode.ieeeModethrough a third helper,quietNan64, next toquietNan32andquietNan16.v_sqrt/rcp/rsq/fract/floor/ceil/trunc/rndne/frexp_mant_f64,v_ldexp_f64,v_div_fixup_f64andv_cvt_f64_f32return a signaling NaN unchanged with IEEE=0 and quieted with IEEE=1. A shader without a known float mode follows IEEE=0.v_add/mul/fma_f64follow the same rule on hardware, but their NaN bits stay with the driver, as for f16 (#2083 now chooses them for f32).v_cvt_f32_f64always quiets, likev_cvt_f16_f32, and the code already does that.TechnicalDebt: the "Signaling NaN inputs" line now names the f64 forms and the two conversions.
Which title needs it
No single title. This applies #1867's measured rule to the f64 forms of the same instructions. Most titles run with IEEE=0, where the f64 forms were still quieting.
Measured on RDNA2 (gfx1036, Radeon 610M) with the HW oracle. #1867 was measured on gfx1035, which is the same family. Settings: f32 denormals flushed, f16/f64 denormals kept, round to nearest even, DX10 clamp on.
v_floor_f64 0xfff00000_123456780xfff00000_123456780xfff80000_12345678v_ldexp_f64 0x7ff40000_00000000, 00x7ff40000_000000000x7ffc0000_00000000v_rcp_f64 0x7ff00000_000000010x7ff00000_000000010x7ff80000_00000001v_div_fixup_f64 1.0, 0x7ff00000_00000001, 1.00x7ff00000_000000010x7ff80000_00000001v_cvt_f64_f32 0xff8123450xfff02468_a00000000xfff82468_a0000000v_cvt_f32_f64 0x7ff00000_000000010x7fc000000x7fc00000Tested
CachyOS Linux, GCC 16.2, RTX 4070 Ti (NVIDIA 615.71) and Radeon 610M (RADV, Mesa 26.2.4).
agc_driver_nan_quietingruns two more kernels, 13 f64 instructions × 8 rows captured on hardware, with no mode, IEEE=0 and IEEE=1, bit for bit. Forv_rcp/rsq/sqrt_f64only the NaN cells are compared, because their finite results are approximations. The f64 part runs only when the device has Float64, like the other f64 tests; otherwise it prints that it was skipped and the f32/f16 checks still run. Checked with a copy of the test that removes Float64 from the target: it skips the f64 part and passes on both drivers.agc_driver_f64_arithmetic,_conversions,_division,_division_modifiers,_nan_conversionsand_transcendentalexpected quieted NaNs. Their tables predate the oracle's explicit modes, so they now pinFLOAT_MODE0xf0, IEEE=1, as #1867 did for its tests. The tables are unchanged.check_conventions.pyandgit diff --checkpass.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T06:00:00Z.
I reviewed the full diff and the hardware evidence in the PR description. The current Build, Conventions, and Progress workflows for this head are all marked action_required, so those upstream checks have not run. CONTRIBUTING says a maintainer must approve held fork workflows; please have that done before merge. I am holding approval until the required checks are visible.
Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:24:07Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
3b3f77bb, merged ontomaind70b8998in one build with 33 other AGC/shader PRs that had no Windows run.agc_driver_f64_arithmetic,agc_driver_f64_conversions,agc_driver_f64_division,agc_driver_f64_division_modifiers,agc_driver_f64_nan_conversions,agc_driver_f64_transcendental,agc_driver_nan_quieting. None of them reported skipping a case.PATHsetup.No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:56:54Z.
The red linux/windows jobs were not caused by this PR: both stop building
agc_shader_fusion_testsonspirv/unified1/spirv.hpp: No such file or directory(viaVulkanTestDevice.hpp), a break onmainat the time that37bc6f2e7fixed.The PR also conflicted with
mainafter #2083, inTranslationContext.hpp(nanResultF32) and in theSignaling NaN inputsTechnicalDebt line. I rebased it: keptmain's declaration plusquietNan64, and merged the f64 forms,v_cvt_f64_f32andv_cvt_f32_f64intomain's version of that line.After the rebase the 7 tests of this PR,
agc_driver_f64_roundingandvector_fma_nan_resultpass on RADV. The HW-oracle comparison from the earlier review is unchanged (the rebase touches only a declaration and docs). Merging once CI is green.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:18:35Z.
mainmoved again and theSignaling NaN inputsTechnicalDebt line conflicted a second time (v_pack_b32_f16was added to it). I rebased:main's line plus the f64 forms,v_cvt_f64_f32andv_cvt_f32_f64clauses from this PR. The code had no conflict.After the rebase the scoped ctest (327 tests, including the 7 of this PR) passes on RADV. The HW-oracle comparison from the earlier review is unchanged (the rebase only touches that docs line). Merging once CI is green.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:32:18Z.
mainmoved again: a change onmainaddedinvalidProductF32next tonanResultF32inTranslationContext.hpp, which conflicted with thequietNan64declaration. I rebased, keepingmain's lines plusquietNan64. No other change.After the rebase the scoped ctest (324 tests, including the 7 of this PR) passes on RADV. The HW-oracle comparison from the earlier review is unchanged. Merging once CI is green.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:44:13Z.
mainmoved again (#2521 plus earlier changes), and this time the conflicts were real:mainaddednonIeeeMinMaxF64next tofloat64Operationand madeF64Arithmetic.cpprun in both IEEE modes. I rebased:TranslationContext.hpp/Float64Instructions.cpp: keptmain'snonIeeeMinMaxF64plusfloat64Unary,vCvtF64F32andquietNan64.F64Arithmetic.cpp: keptmain'sIeeeswitch instead of pinning IEEE=1, and in the IEEE=0 passldexpof the signaling NaN in lane 13 now expects the input unchanged (0xfff7c837), per the hardware rows in the description.TechnicalDebt.md:main'sSignaling NaN inputsline plus the f64 forms,v_cvt_f64_f32andv_cvt_f32_f64clauses.After the rebase the scoped ctest (328 tests, including the 7 of this PR and
agc_driver_f16_min_max_nan) passes on RADV. Merging once CI is green.