fix(shader): flush denormal v_trig_preop_f64 results in the f64 flush modes #22688
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22688"
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 MichonGoddijn231849 on 2026-11-18T02:37:17Z.
What
v_trig_preop_f64kept a denormal result in everyFLOAT_MODE. On hardware the result is flushed to zero when bit 1 of the f16/f64 denormal field is clear (modes 0 and 1). For ordinary inputs, segment 20 returns0x000000000000294awith denormals kept and0with them flushed. AnyPS5 returned0x294ain all four modes.Float64Instructions.cpp: theFPTrigPreop64result goes through the existingflushTinyF64Result(the non-product branch: a nonzero magnitude below 2^-1022 becomes its signed zero), asv_add_f64results already do. It is a no-op when bit 1 is set or the shader has no known float mode.F64TrigPreopDenormalModes.cpprunsv_trig_preop_f64on 20 lanes × 2 segment selectors in each of the four f16/f64 denormal modes and compares every dword with the hardware results. The 20 lanes cover zeros, the smallest denormal, the minimum normal, 1, 3, 0.5, 1e10, 2^100, 1e300, 2^1023, infinities, a quiet and a signaling NaN, segments 0 to 31, and a 0xffffffff selector.v_trig_preop_f64entry inshader.md(fragmentdocs/dev/debt/changes/fix-trig-preop-denormal-flush.md).Source of the semantics: measured on RDNA2 hardware (gfx1036, AMD Windows driver 32.0.21045.16010) with
tools/hw-oracle. The mismatch first showed in a differential run of the hardware oracle against AnyPS5'sagc_oracle_runneron both Vulkan devices: 21 inputs × 10 segment selectors, IEEE 0 and 1, f16/f64 denormal modes 0 to 3. Before this change, modes 0 and 1 differed on 10 of 210 rows, all denormal results; modes 2 and 3 matched. With this change all 8 mode combinations match on both devices (0 of 210 rows differ). The test's expected values are the hardware's output for its own rows.Tested
Windows 11 Pro 10.0.26200,
ctest --test-dir build -R 'f64_trig_preop|f64_transcendental' -VwithANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer, validation layer 1.4.363, once per GPU (ANYPS5_GPU):f64_transcendentalpasses; the new test fails:v_trig_preop_f64 f64 denormal mode 0: lane 0 word 0 is 0x0000294a, expected 0x00000000VUID-VUID-Each log shows
Insert instance layer "VK_LAYER_KHRONOS_validation"and none showswas not found but was requested by env var VK_INSTANCE_LAYERS.pr_overlap.py --branchreports #22034 and #22446 on the neighbouring line offloat64Operation. They roundv_add/mul/fma_f64in directed modes and add aroundingargument toflushTinyF64Result, so whichever merges second needs a one-line rebase. Neither changesv_trig_preop_f64.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-18T03:08:06Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
7623199a800c55cd894abe5bd428d35c55d9983d. I inspected the prepared diff and all three changed files; I did not run commands or tests. The description reports Windows/Vulkan runs on NVIDIA RTX 5080 and AMD RDNA2, which I did not independently verify.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not run the tests or independently confirm the reported hardware results. Repository files read:
core/libs/prx/libSceAgcDriver/tests/execution/F64TrigPreopDenormalModes.cpp,core/shader/recompiler/Translation/src/Float64Instructions.cpp, anddocs/dev/debt/changes/fix-trig-preop-denormal-flush.md. No changed files were excluded; all three files listed as reviewed were read.To get this to a good state
Nothing is required.