feat(shader): follow IEEE_MODE in f16 and f64 min and max #2036
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2036"
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:48Z.
What
The f16 and f64 min/max family ignored the shader's
IEEE_MODE, so a NaN operand gave a different result than on the console:#1826 and #1867 made the f32 forms and the unary instructions follow
IEEE_MODE; TechnicalDebt still listed "the f16 and f64 min/max/med3" as following a single mode. This PR covers those forms:v_min_f16,v_max_f16,v_min3_f16,v_max3_f16,v_med3_f16,v_min_f64andv_max_f64. RDNA2 has no f64 min3, max3 or med3.The f16 forms now choose the NaN result on the f16 bits, like the packed f16 forms already do. The f64 forms keep their current lowering at IEEE=1 (it already matched) and get the IEEE=0 rule. The f32 path and
ieeeMinMaxF32are unchanged. Shaders with no known float mode follow IEEE=0, as elsewhere.Measured with the hardware oracle on RDNA2. I used gfx1036 (Radeon 610M), not the gfx1035 of #1826; both are RDNA2. Every float control was set explicitly, at IEEE=0 and IEEE=1, with f32 denormals kept and flushed:
main)Measured rows (gfx1036):
mainv_min_f160x0000,0xfd230xff230x0000v_med3_f160x0000,0x0000,0xfd230xff230x0000v_min_f160x7c01,0xfe550x7c010x7e01RADV,0x7fffNVIDIAv_min_f640x7ff0000000000001,+0+00x7ff8000000000001v_max_f640x7ff0000000000001,0x7ff80000000000000x7ff00000000000010x7ff8000000000001The TechnicalDebt float mode line now lists these forms with their rule. It also records a separate gap: when f16/f64 denormals are flushed, the hardware flushes denormal inputs of these instructions (
v_min_f16(0x0001, 0x8001)gives0x8000), and this lowering does not, before or after this PR.Which title needs it
No title yet. This completes the
IEEE_MODEseries (#1826, #1867) for the f16 and f64 min/max forms that TechnicalDebt still listed as following a single mode. Most titles useFLOAT_MODE0xc0 with IEEE=0, wherev_min_f64/v_max_f64now return the non-NaN operand as the console does instead of a NaN, and f16 min/max keep src0's NaN bits when both operands are NaN. No title is known to hit either case.Tested
CachyOS Linux, RTX 4070 Ti (NVIDIA) and Radeon 610M (RADV), Release build.
agc_driver_f16_min_max_nan, laid out likeagc_driver_f32_min_max_nan: 128 rows of ±0, ±1, ±inf, quiet and signaling NaNs with payloads and denormals, with garbage in the high halves, through the five f16 ops and-/|x|modifiers. Each row runs with no float mode and with IEEE=1, against tables captured on the oracle. It passes on both GPUs. Onmainit fails atrow 94 v_min_f16 v10, v4, v5 is 0x00007e01, expected 0x00007c01.agc_driver_f64_arithmeticheld the IEEE=1 results (its table matches gfx1036 exactly at IEEE=1) but ran without a float mode. It now runs both ways, and its min/max columns at IEEE=0 come from the oracle.v_min/max_f16_sdwawith WORD_0/WORD_1 selects, clamp,mul:2and neg/abs, 400 rows each in two IEEE=1 modes (DX10 clamp on and off), match the hardware on both drivers with this branch (main: 64 of 400 differ).check_conventions.py,git diff --check.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)F64Arithmetic.cppand #2000 editsFloatInstructions.cpp; different functions, I'll rebase whichever lands second🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T06:00:01Z.
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:46:20Z.
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
b05a8048, merged ontomaind70b8998in one build with 38 other PRs that had no Windows run.mainwithout it.agc_driver_f16_min_max_nan,agc_driver_f64_arithmetic. None of them reported skipping a case.No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:19:39Z.
Rebased onto current
main(only conflict: the shader float mode line in TechnicalDebt, merged with the lines that landed since; no code changes).agc_driver_f16_min_max_nanandagc_driver_f64_arithmeticpass on the rebased tree, and fail without the change. The earlier redlinux/windowsjobs were theagc_shader_fusion_testsmissingspirv.hppbreak onmain, fixed by37bc6f2e7. Merging once CI is green on the new head.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T07:27:42Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/TechnicalDebt.mdL338