Repository navigation
fix(shader): honor f64 min and max input denormal mode - #6760
Conversation
|
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.
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.
|
|
AMD / Windows run of this PR at 5356078: Radeon 780M (RDNA 3, 0x15bf), AMD driver 25.10.20.01 (32.0.21020.1007), Windows 11 Home 10.0.26100, WinLibs GCC 15.2.0 r7, Release.
AI-assisted: yes (runs made on the device above). |
|
Tested on Linux (Arch), This PR breaks the existing test The failing check is the Suggested fix, tried on the merge: skip a mismatch in a keeping mode when the device cannot preserve f64 denormals, the same rule placed in front of the AI-assisted: yes |
|
Thanks @nicolasfalesy for the reproducer and tested suggestion. I pushed the test fix; current head The fixture skips only mismatching kept-denormal words when On Windows / RTX 4070 Ti SUPER (617.42), the full app/libs build, 17 targeted CTest groups and five extra arithmetic-test runs passed, with no min/max words skipped. The original shader negative control still fails in mode 0; injected-result controls confirmed the gate also keeps modes 0/2 strict. I did not run lavapipe locally. Could you rerun AI-assisted: yes (Codex). |
|
Reran on Linux (Arch),
Skipped words, the same 12 lines in both runs (192 words in all). They are only in mode -1 and mode 3. Mode 1 skips nothing here, and modes 0 and 2 skip nothing, as intended: AI-assisted: yes |
|
Native data for the split modes and the sign-preserving flush, which the description says weren't measured: RX 6700 XT (gfx1031, RDNA 2),
The same in IEEE 0 and 1. So the inputs are flushed to signed zero exactly when bit 0 of the field is clear, split modes included, and a denormal result is not flushed in mode 1 (it matches the kept result there). That is the rule this PR implements. Desktop RDNA 2, not gfx1013. |
|
Checked the diff against the f64 min/max translation: inputs are flushed to signed zero before the compare and NaN selection when bit 0 of the f16/f64 denormal field is clear (modes 0 and 2), the IEEE path keeps its previous result, and modes 1/3 and unknown modes are unchanged. The new fixture covers 32 input pairs x 4 source-modifier combinations x modes -1/0/2/3 x IEEE 0/1, and fails on mode 0 without the change. The split modes and sign-preserving flush match the native RDNA2 data from @thuanquang and the earlier gfx1036 measurement (#2036); AMD/Windows (@keravyn-ops) and lavapipe (@nicolasfalesy) runs pass. Merged. |
What
v_min_f64andv_max_f64now flush subnormal inputs to signed zero whenFLOAT_DENORM16_64disables input preservation (modes 0 and 2), before comparison and NaN selection. For example,v_max_f64(0x0000000000000001, +0)returns+0in mode 0. Both instructions share the translation path; the existing IEEE/NaN policy and result modifiers remain in use. Input-preserving and unknown modes retain their existing lowering.The fully flushed/preserved f64 behavior was measured on gfx1036 in #2036. Split modes and sign-preserving flushing follow LLVM's AMDGPU denormal-mode documentation. I did not perform a new AMD or PS5 hardware measurement. The debt entry records the corrected scope; other f64 arithmetic's denormal controls remain outside this change.
The regression checks 32 input pairs, four source-modifier combinations, unknown mode and modes 0/2/3, with IEEE off/on for known modes. Following the lavapipe report, a mismatching word in an input-preserving mode is explicitly counted as skipped only when the target lacks f64
DenormPreserve, using the same capability rule as #7036. Passing words are still checked. Modes 0 and 2 always fail on a mismatch, regardless of that capability.#7036 covers different instructions and is independent. #7042 has a text conflict at the min/max function boundary; its add/mul change is not duplicated here and will need conflict resolution when combined with this PR.
Tested
Base
f1af6c591588b257437f51e5ac1740fb788b231d, head01b1664eb47b90a6d5dc568a9d4f1671fb003063. Test capability fix:397f43d042d210f090f9748f4d66ed9b472c6d56. Current main is merged into the original branch without rewriting its history.Windows (native host): AMD Ryzen 9 7900X, 32 GB RAM, NVIDIA GeForce RTX 4070 Ti SUPER / driver 617.42; Windows 11 Pro 10.0.26300, supported WinLibs GCC 15.2.0 r7, Release.
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_GPU=NVIDIA GeForce RTX 4070 Ti SUPER,ANYPS5_NO_SHADER_CACHE=1. The selected physical GPU was verified in every GPU process; driver caches were not controlled.BUILD_TESTING=ONpassed. The supported execution-fixture selection builds the f64 fixtures,VopcCompareF64andF16MinMaxNan; other execution fixtures use selection stubs and were not tested.agc_driver_f64_arithmeticruns passed. No min/max result words were skipped on this NVIDIA device, which reports no f64DenormPreservebut satisfies these checks.The original shader regression remains detectable with the final fixture and the three production shader files temporarily replaced by their exact base blobs, then restored:
agc_driver_f64_arithmetic, same native NVIDIA host and inputs0x00000001, expected zeroAdditional temporary fault-injection controls reproduced the reported unknown-mode mismatch in the old fixture. The fixed fixture explicitly skipped 12 injected words across unknown/mode-3 configurations without preservation support; the same mismatch failed when preservation was required. Injected mismatches in modes 0 and 2 also failed. All injections and base-source substitutions were removed before the final build and test runs. These controls simulate results and are not a lavapipe run.
Final commands included
cmake --build build --parallel 8,ctest --test-dir build -V -j1 --timeout 30with the targeted group filter,ctest --test-dir build -R '^agc_driver_f64_arithmetic$' --repeat until-fail:5 -V --timeout 30, andpython tools/check_conventions.py --base origin/main.Linux (VirtualBox) was intentionally not run for this update. Native Linux/lavapipe and other GPUs were not rerun locally; the reported lavapipe failure needs a retest of this head. No title, performance measurement or full CTest-suite run is claimed.
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)