fix(shader): flush v_rcp_f64, v_rsq_f64 and v_sqrt_f64 denormals by the f64 field #22384
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22384"
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 NWProgramming00 on 2026-11-17T13:39:06Z.
What
The technical debt lists
v_rcp_f64,v_rsq_f64andv_sqrt_f64among the f64 instructions that do not model theFLOAT_MODEf16/f64 denormal field. On RDNA2 they follow it like the other f64 ops:v_rcp_f64(0x0008000000000000)is+infon the hardware; the translation gave0x7fe0000000000000.v_rcp_f64(2^1023)is+0on the hardware; the translation gave0x0008000000000000.This holds at IEEE=0 and IEEE=1.
float64Unarynow runs the three opcodes through the sameflushF64Bitsinput flush (bit 0) asv_floor_f64andv_fract_f64, and the same result flush (bit 1) asv_fract_f64. Without a known float mode,flushF64Bitskeeps everything, as before.RoundingUseOfnow lists the three opcodes as readers of both f16/f64 denormal bits, as it lists the other f64 ops that flush. A MODE value that differs between paths, or comes from an SGPR, now throws for them instead of being read from a stale field.Measurement: hardware oracle on an AMD Radeon Graphics iGPU (Ryzen 7 9700X, gfx1036), AMD Windows driver 32.0.21042.62, HIP runtime, against
agc_oracle_runner(lavapipe). The PS5's gfx1013 is not measured. Inputs: 27 values covering normals, ±0, ±inf, quiet and signaling NaNs, positive and negative denormals, 2^-1022, values above 2^1022 and ±DBL_MAX. Modes: all four f16/f64 denormal fields, at IEEE 0 and 1.Before the change, every mode has rows where the hardware and the translation differ in class: zero against denormal, or inf against finite. Examples in mode 0:
0x7fe0000000000000(2^1023)v_rcp_f640x00000000000000000x00080000000000000xffe0000000000000v_rcp_f640x80000000000000000x80080000000000000x0008000000000000v_rcp_f640x7ff00000000000000x7fe00000000000000x000fffffffffffffv_rsq_f640x7ff00000000000000x5fe0000000000001After the change, no row differs in sign or class, or by more than 2^-20 relative, in any mode or IEEE setting.
The hardware results of all three instructions are approximations, often only about 30 bits exact. For example,
v_sqrt_f64(1.0)is0x3ff0000004000000andv_rsq_f64(2.0)is0x3fe6a09e60000000. The translation keeps the driver's correctly rounded result there. This change does not try to reproduce the approximation.The new execution test
Float64TranscendentalDenormalsrunsv_rcp_f64,v_rsq_f64andv_sqrt_f64over 29 measured inputs in FLOAT_MODE 0x30, 0x70, 0xb0 and 0xf0, with IEEE off.Approximate, not compared.2^1022) or the overflow threshold (2^-1024) are dropped, since a device within that bound can land on either side.F64RoundingDenormalModes, on a device withoutfloat64DenormPreserveit skips the cells whose kept input or expected result is a denormal. lavapipe reports nofloat64DenormPreserve, so it runs the test with 28 cells skipped.Debt:
libSceAgcDriverfloat-mode entry, the three instructions move out of the "do not model these denormal controls" list. That entry was already over the 1000-character limit, socheck_conventionsreports adebt-lengthwarning for this change (0 errors).Tested
Linux (WSL2 Ubuntu 24.04), GCC, Release, lavapipe, on
main9c0d96916c:agc_driver_float64_transcendental_denormalswithout the fix:v_rcp_f64 of 0x7fe0000000000000 with FLOAT_MODE 0x30 is 0x0008000000000000, expected the RDNA 2 value 0x0000000000000000. With the fix: passes, also withAPS5_SPIRV_OPT=fullandnone.ctest -j 14: 5999 of 6008 pass. All 9 failures also fail with the fix reverted on the same base:agc_driver_image_table_packed_guardsfails onmain(#21255).agc_hook_clear_access,agc_hook_clear_access_offandagc_driver_recorderfail onmainon lavapipe (#21627).patched_self_imports,guest_libressl3_ec_parametersandguest_libressl3_asn1fail on thismainin this environment.guest_audio_in_status_reroute_shared_boundsandguest_audio_out_system_state_output_time_boundsare intermittent here.python3 tools/pr_overlap.py --branch fix/shader-f64-transcendental-denormals: no overlap with open pull requests.python3 tools/check_conventions.py --base origin/main: 0 errors, 1debt-lengthwarning as above.python3 tools/debt_fold.py --check: the only error istest-libc-wcstombs.mdandfix-libc-wcstombs-zero-capacity.mdchanging the same libc entry, whichmainreports without this change.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 MarcZX10 on 2026-11-22T22:17:25Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the implementation applies the described f64 denormal input and result flushing, and the included execution test checks measured cases within its stated tolerance.
What I ran
Reviewed head
50d5e600ab95b53176ba83d56728d9abd30c5a76. Read the prepared description, commits, manifest, full diff, all four included changed files, the relevant execution-test registration incore/libs/prx/libSceAgcDriver/CMakeLists.txt, andF64RoundingDenormalModes.cppfor comparison. No build or test commands were run; author-reported test results are not independently verified.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The hardware oracle measurements, reported lavapipe runs, and physical-console behavior were not independently confirmed. The excluded-file list was not available through the reader; the manifest shows all four changed files as included, and those files were read.
To get this to a good state
Nothing is required.