fix(shader): flush f64 floor, ceil, fract and frexp denormal inputs #7036

Merged
thuanquang merged 2 commits from upstream-pr/7036 into main 2026-10-19 20:22:37 +00:00
thuanquang commented 2026-10-17 06:54:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-17T06:54:58Z.


What

v_floor_f64, v_ceil_f64, v_fract_f64, v_frexp_mant_f64 and v_frexp_exp_i32_f64 ignored the FLOAT_MODE f16/f64 denormal field (bits 7:6). On the GPU:

  • with bit 6 clear (modes 0 and 2) a denormal input is flushed to a zero of its sign first, so v_ceil_f64 2^-1074 is 0 where main gives 1.0, v_floor_f64 -2^-1074 is -0 where main gives -1.0, v_fract_f64 -2^-1074 is 0 where main gives 0x3fefffffffffffff, and both frexp forms give 0;
  • with bit 7 clear (modes 0 and 1) v_fract_f64 flushes the denormal result it gives for a positive denormal input to +0.

float64Unary now flushes the source of those four opcodes, and the v_fract_f64 result, through a new flushF64Bits (the f64 counterpart of flushF16Bits, by the same keep bits); float64Operation flushes the source of v_frexp_exp_i32_f64. v_trunc_f64 and v_rndne_f64 give the same results with or without the flush and are unchanged. Modes that keep denormals, and shaders without a known float mode, are translated as before. The other f64 arithmetic still ignores the field; min/max and the compares are covered by #6760 and #6850, which this PR does not touch.

Measured

The same instructions were run directly on the GPU with the tools/hw-oracle template, launched through the driver's HIP runtime, and through the recompiler on Vulkan, at IEEE 0 and 1, over 23 f64 values (±0, ±2^-1074, ±0x000fffffffffffff, 0x0008000000000000, ±2^-1022, 0x0010000000000001, ±0.5, ±1, 0x3feffffffffffffe, 0x3ff0000000000001, 2^-52, 2^-1021, 0x7fefffffffffffff, ±inf, a quiet and a signaling NaN):

f64 denormal mode main vs GPU (floor / ceil / fract / frexp_mant / frexp_exp) this change vs GPU
0 2 / 3 / 5 / 5 / 5 of 23 0 each
1 0 / 0 / 3 / 0 / 0 of 23 0 each
2 2 / 3 / 5 / 5 / 5 of 23 0 each
3 0 each 0 each

With this change every mode also matches for -v[4:5] (floor, frexp_mant, frexp_exp), |v[4:5]| (ceil) and -|v[4:5]| (fract) over 16 of those values, and v_trunc_f64 and v_rndne_f64 match before and after.

Tested

Windows 11 26200, AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.5002, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, ANYPS5_REQUIRE_VULKAN=1:

  • New agc_driver_f64_rounding_denormal_modes: the five instructions over 18 finite values (zeros, denormals, minimum normals, 0.5, -1.5, 2.75, values next to ±1, ±0x7fefffffffffffff and 2^52 + 1) in f64 denormal modes 0 to 3 at IEEE 0 and 1 and without a known float mode, against std::floor, std::ceil, std::frexp and min(x - floor(x), 0x3fefffffffffffff) of the flushed input, with the fract result flushed when bit 7 is clear. That model matched the GPU on those 18 values in every mode. On main it fails: v_ceil_f64 f64 denormal mode 0, IEEE mode on of 0x0000000000000001 is 0x3ff0000000000000, expected 0x0000000000000000. With this change it passes.
  • Full ctest --parallel 4 --timeout 120 on main 6e7ba928a with this change: 1368 tests, 2 fail, both failing on main on this GPU too: agc_driver_lds_mixed_width_atomics (#5271) and agc_driver_layered_volume_vertex_no_gpl (#4768). agc_driver_f64_arithmetic, agc_driver_f64_conversions and the other f64 tests pass.
  • python tools/check_conventions.py --base origin/main with this title and body passes.
  • Not tested: the PS5's gfx1013, other AMD drivers, NVIDIA, Intel, and titles.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.5002, Windows 11 26200
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4898072344 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7036). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-17T06:54:58Z. --- ### What `v_floor_f64`, `v_ceil_f64`, `v_fract_f64`, `v_frexp_mant_f64` and `v_frexp_exp_i32_f64` ignored the `FLOAT_MODE` f16/f64 denormal field (bits 7:6). On the GPU: - with bit 6 clear (modes 0 and 2) a denormal input is flushed to a zero of its sign first, so `v_ceil_f64 2^-1074` is `0` where `main` gives `1.0`, `v_floor_f64 -2^-1074` is `-0` where `main` gives `-1.0`, `v_fract_f64 -2^-1074` is `0` where `main` gives `0x3fefffffffffffff`, and both frexp forms give 0; - with bit 7 clear (modes 0 and 1) `v_fract_f64` flushes the denormal result it gives for a positive denormal input to +0. `float64Unary` now flushes the source of those four opcodes, and the `v_fract_f64` result, through a new `flushF64Bits` (the f64 counterpart of `flushF16Bits`, by the same keep bits); `float64Operation` flushes the source of `v_frexp_exp_i32_f64`. `v_trunc_f64` and `v_rndne_f64` give the same results with or without the flush and are unchanged. Modes that keep denormals, and shaders without a known float mode, are translated as before. The other f64 arithmetic still ignores the field; min/max and the compares are covered by #6760 and #6850, which this PR does not touch. ### Measured The same instructions were run directly on the GPU with the `tools/hw-oracle` template, launched through the driver's HIP runtime, and through the recompiler on Vulkan, at IEEE 0 and 1, over 23 f64 values (±0, ±2^-1074, ±0x000fffffffffffff, 0x0008000000000000, ±2^-1022, 0x0010000000000001, ±0.5, ±1, 0x3feffffffffffffe, 0x3ff0000000000001, 2^-52, 2^-1021, 0x7fefffffffffffff, ±inf, a quiet and a signaling NaN): | f64 denormal mode | `main` vs GPU (floor / ceil / fract / frexp_mant / frexp_exp) | this change vs GPU | |---|---|---| | 0 | 2 / 3 / 5 / 5 / 5 of 23 | 0 each | | 1 | 0 / 0 / 3 / 0 / 0 of 23 | 0 each | | 2 | 2 / 3 / 5 / 5 / 5 of 23 | 0 each | | 3 | 0 each | 0 each | With this change every mode also matches for `-v[4:5]` (floor, frexp_mant, frexp_exp), `|v[4:5]|` (ceil) and `-|v[4:5]|` (fract) over 16 of those values, and `v_trunc_f64` and `v_rndne_f64` match before and after. ### Tested Windows 11 26200, AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.5002, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, `ANYPS5_REQUIRE_VULKAN=1`: - New `agc_driver_f64_rounding_denormal_modes`: the five instructions over 18 finite values (zeros, denormals, minimum normals, 0.5, -1.5, 2.75, values next to ±1, ±0x7fefffffffffffff and 2^52 + 1) in f64 denormal modes 0 to 3 at IEEE 0 and 1 and without a known float mode, against `std::floor`, `std::ceil`, `std::frexp` and `min(x - floor(x), 0x3fefffffffffffff)` of the flushed input, with the fract result flushed when bit 7 is clear. That model matched the GPU on those 18 values in every mode. On `main` it fails: `v_ceil_f64 f64 denormal mode 0, IEEE mode on of 0x0000000000000001 is 0x3ff0000000000000, expected 0x0000000000000000`. With this change it passes. - Full `ctest --parallel 4 --timeout 120` on `main` `6e7ba928a` with this change: 1368 tests, 2 fail, both failing on `main` on this GPU too: `agc_driver_lds_mixed_width_atomics` (#5271) and `agc_driver_layered_volume_vertex_no_gpl` (#4768). `agc_driver_f64_arithmetic`, `agc_driver_f64_conversions` and the other f64 tests pass. - `python tools/check_conventions.py --base origin/main` with this title and body passes. - Not tested: the PS5's gfx1013, other AMD drivers, NVIDIA, Intel, and titles. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.5002, Windows 11 26200 - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
oneandonlydean commented 2026-10-17 07:10:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T07:10:58Z.


Full CI on 5bc68b1cc (run 39012021072): Linux fails the test this PR adds, agc_driver_f64_rounding_denormal_modes (llvmpipe, LLVM 20.1.2):

AGC graphics: v_frexp_mant_f64 without a known float mode of 0x0000000000000001 is 0x3fe0000000000001, expected 0x3fe0000000000000

Windows shows success only because its runner has no Vulkan device, so the test is skipped there; Linux is the only CI job that runs it. Could you look at the frexp path when the float mode isn't known?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6231058756 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7036#issuecomment-6231058756). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T07:10:58Z. --- Full CI on 5bc68b1cc (run 39012021072): Linux fails the test this PR adds, agc_driver_f64_rounding_denormal_modes (llvmpipe, LLVM 20.1.2): ``` AGC graphics: v_frexp_mant_f64 without a known float mode of 0x0000000000000001 is 0x3fe0000000000001, expected 0x3fe0000000000000 ``` Windows shows success only because its runner has no Vulkan device, so the test is skipped there; Linux is the only CI job that runs it. Could you look at the frexp path when the float mode isn't known?
github-actions[bot] commented 2026-10-17 07:30:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T07:30:26Z.


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.

Pull request Shared files not compared
PR 4072 core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp
PR 5021 docs/dev/debt/shader.md
PR 5371 docs/dev/debt/shader.md
PR 5426 docs/dev/debt/shader.md
PR 5500 docs/dev/debt/shader.md
PR 5941 docs/dev/debt/shader.md
PR 6009 docs/dev/debt/shader.md
PR 6235 docs/dev/debt/shader.md
PR 6280 docs/dev/debt/shader.md
PR 6412 docs/dev/debt/shader.md
PR 6488 docs/dev/debt/shader.md
PR 6604 docs/dev/debt/shader.md
PR 6924 docs/dev/debt/shader.md
PR 6977 docs/dev/debt/shader.md
PR 7223 docs/dev/debt/shader.md
PR 7332 docs/dev/debt/shader.md
PR 7392 docs/dev/debt/shader.md
PR 7395 docs/dev/debt/shader.md
PR 7484 docs/dev/debt/shader.md
PR 7684 docs/dev/debt/shader.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6231230525 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7036#issuecomment-6231230525). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-17T07:30:26Z. --- <!-- pr-overlap --> 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. | Pull request | Shared files not compared | |---|---| | [PR 4072](https://www.github.com/boykopovar/AnyPS5/pull/4072) | `core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `docs/dev/debt/shader.md` | | [PR 5371](https://www.github.com/boykopovar/AnyPS5/pull/5371) | `docs/dev/debt/shader.md` | | [PR 5426](https://www.github.com/boykopovar/AnyPS5/pull/5426) | `docs/dev/debt/shader.md` | | [PR 5500](https://www.github.com/boykopovar/AnyPS5/pull/5500) | `docs/dev/debt/shader.md` | | [PR 5941](https://www.github.com/boykopovar/AnyPS5/pull/5941) | `docs/dev/debt/shader.md` | | [PR 6009](https://www.github.com/boykopovar/AnyPS5/pull/6009) | `docs/dev/debt/shader.md` | | [PR 6235](https://www.github.com/boykopovar/AnyPS5/pull/6235) | `docs/dev/debt/shader.md` | | [PR 6280](https://www.github.com/boykopovar/AnyPS5/pull/6280) | `docs/dev/debt/shader.md` | | [PR 6412](https://www.github.com/boykopovar/AnyPS5/pull/6412) | `docs/dev/debt/shader.md` | | [PR 6488](https://www.github.com/boykopovar/AnyPS5/pull/6488) | `docs/dev/debt/shader.md` | | [PR 6604](https://www.github.com/boykopovar/AnyPS5/pull/6604) | `docs/dev/debt/shader.md` | | [PR 6924](https://www.github.com/boykopovar/AnyPS5/pull/6924) | `docs/dev/debt/shader.md` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `docs/dev/debt/shader.md` | | [PR 7223](https://www.github.com/boykopovar/AnyPS5/pull/7223) | `docs/dev/debt/shader.md` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `docs/dev/debt/shader.md` | | [PR 7392](https://www.github.com/boykopovar/AnyPS5/pull/7392) | `docs/dev/debt/shader.md` | | [PR 7395](https://www.github.com/boykopovar/AnyPS5/pull/7395) | `docs/dev/debt/shader.md` | | [PR 7484](https://www.github.com/boykopovar/AnyPS5/pull/7484) | `docs/dev/debt/shader.md` | | [PR 7684](https://www.github.com/boykopovar/AnyPS5/pull/7684) | `docs/dev/debt/shader.md` |
LeandroLP23 commented 2026-10-17 08:09:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-17T08:09:00Z.


Another AMD driver, since the description lists other AMD drivers as untested.

Windows 11 (26300), Radeon 860M (RDNA 3.5, 1002:1114), driver 32.0.13058.8001, WinLibs GCC 15.2.0, Release, ANYPS5_REQUIRE_VULKAN=1. Tree: main 17cfb1f4c with #7018, #7034, #7036, #7038, #7040, #7041 and #7042 merged together (only docs/dev/debt/shader.md conflicted, for #7040); "main" is the same tree with the six recompiler files reverted to main and the tests kept.

  • agc_driver_f64_rounding_denormal_modes: fails on main, passes 3 of 3 with this change (and with #7042, which extends it).

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6231564747 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7036#issuecomment-6231564747). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-17T08:09:00Z. --- Another AMD driver, since the description lists other AMD drivers as untested. Windows 11 (26300), Radeon 860M (RDNA 3.5, `1002:1114`), driver 32.0.13058.8001, WinLibs GCC 15.2.0, Release, `ANYPS5_REQUIRE_VULKAN=1`. Tree: `main` `17cfb1f4c` with #7018, #7034, #7036, #7038, #7040, #7041 and #7042 merged together (only `docs/dev/debt/shader.md` conflicted, for #7040); "`main`" is the same tree with the six recompiler files reverted to `main` and the tests kept. - `agc_driver_f64_rounding_denormal_modes`: fails on `main`, passes 3 of 3 with this change (and with #7042, which extends it). AI-assisted: yes (Claude Code).
jotitadev commented 2026-10-17 13:35:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-17T13:35:37Z.

Review: COMMENTED


An NVIDIA run, and the full list of rows that fail on lavapipe, for the CI failure @oneandonlydean reported.

Machine: Ubuntu 26.04, i7-8700, GCC 15.2, Release, BUILD_TESTING=ON. NVIDIA GeForce RTX 3070 (driver 595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same host. PR merged onto main 12a71f3f5 (clean). ANYPS5_NO_SHADER_CACHE=1, -j1 --timeout 30.

Run RTX 3070 lavapipe
^agc_driver_f64 (10 tests) pass 3/3 9/10; agc_driver_f64_rounding_denormal_modes fails with the CI message: v_frexp_mant_f64 without a known float mode of 0x0000000000000001 is 0x3fe0000000000001, expected 0x3fe0000000000000
new test, Float64Instructions.cpp/SubwordPacking.cpp/TranslationContext.hpp from main fails: v_ceil_f64 f64 denormal mode 0, IEEE mode on of 0x0000000000000001 is 0x3ff0000000000000, expected 0x0000000000000000 fails

To see every failing row and not only the first one, I changed the test's Require locally to log and count instead of throwing:

  • RTX 3070: 0 mismatches in all 9 modes.
  • lavapipe: 40 mismatches. All are v_frexp_mant_f64 and v_frexp_exp_i32_f64 of a denormal input, in the modes that keep f64 denormals (1, 3 and no known float mode), 8 per mode. floor, ceil and fract match in every mode, and in modes 0 and 2 (input flushed first) frexp matches too. The rows for no known float mode:
input frexp_mant lavapipe / expected frexp_exp lavapipe / expected
0x0000000000000001 0x3fe0000000000001 / 0x3fe0000000000000 -1022 / -1073
0x000fffffffffffff 0x3fefffffffffffff / 0x3feffffffffffffe match
0x0008000000000000 0x3fe8000000000000 / 0x3fe0000000000000 match

(plus the negative inputs, same pattern). These rows translate as on main, so this is lavapipe's f64 frexp not normalizing a denormal input (it reads the mantissa bits as if the exponent were -1022), not this PR's flush.

One note on gating these rows on shaderDenormPreserveFloat64: the 3070 reports it false, the same as this lavapipe, and passes all of them. A gate on that feature would skip the kept-denormal rows on NVIDIA too, and the floor/ceil/fract rows that lavapipe gets right. On this lavapipe only the frexp rows with a denormal input need to be skipped.

Not run: Windows, AMD, any title.

GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3), Ubuntu 26.04

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5557979280 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7036#pullrequestreview-5557979280). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-17T13:35:37Z. **Review:** COMMENTED --- An NVIDIA run, and the full list of rows that fail on lavapipe, for the CI failure @oneandonlydean reported. **Machine:** Ubuntu 26.04, i7-8700, GCC 15.2, Release, `BUILD_TESTING=ON`. NVIDIA GeForce RTX 3070 (driver 595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same host. PR merged onto `main` `12a71f3f5` (clean). `ANYPS5_NO_SHADER_CACHE=1`, `-j1 --timeout 30`. | Run | RTX 3070 | lavapipe | |---|---|---| | `^agc_driver_f64` (10 tests) | pass 3/3 | 9/10; `agc_driver_f64_rounding_denormal_modes` fails with the CI message: `v_frexp_mant_f64 without a known float mode of 0x0000000000000001 is 0x3fe0000000000001, expected 0x3fe0000000000000` | | new test, `Float64Instructions.cpp`/`SubwordPacking.cpp`/`TranslationContext.hpp` from `main` | fails: `v_ceil_f64 f64 denormal mode 0, IEEE mode on of 0x0000000000000001 is 0x3ff0000000000000, expected 0x0000000000000000` | fails | To see every failing row and not only the first one, I changed the test's `Require` locally to log and count instead of throwing: - **RTX 3070:** 0 mismatches in all 9 modes. - **lavapipe:** 40 mismatches. All are `v_frexp_mant_f64` and `v_frexp_exp_i32_f64` of a denormal input, in the modes that keep f64 denormals (1, 3 and no known float mode), 8 per mode. `floor`, `ceil` and `fract` match in every mode, and in modes 0 and 2 (input flushed first) `frexp` matches too. The rows for no known float mode: | input | `frexp_mant` lavapipe / expected | `frexp_exp` lavapipe / expected | |---|---|---| | `0x0000000000000001` | `0x3fe0000000000001` / `0x3fe0000000000000` | -1022 / -1073 | | `0x000fffffffffffff` | `0x3fefffffffffffff` / `0x3feffffffffffffe` | match | | `0x0008000000000000` | `0x3fe8000000000000` / `0x3fe0000000000000` | match | (plus the negative inputs, same pattern). These rows translate as on `main`, so this is lavapipe's f64 `frexp` not normalizing a denormal input (it reads the mantissa bits as if the exponent were -1022), not this PR's flush. One note on gating these rows on `shaderDenormPreserveFloat64`: the 3070 reports it `false`, the same as this lavapipe, and passes all of them. A gate on that feature would skip the kept-denormal rows on NVIDIA too, and the `floor`/`ceil`/`fract` rows that lavapipe gets right. On this lavapipe only the `frexp` rows with a denormal input need to be skipped. Not run: Windows, AMD, any title. GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3), Ubuntu 26.04 Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Dextroid17 commented 2026-10-17 17:46:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-17T17:46:26Z.


@jotitadev's review found only the frexp rows failing on lavapipe with Mesa 26.0.3, and suggested skipping just those because the RTX 3070 reports shaderDenormPreserveFloat64 false and still passes every row. On a newer lavapipe that narrower skip is not enough.

Linux, lavapipe (Mesa 26.2.4, LLVM 23.1.1, GALLIUM_OVERRIDE_CPU_CAPS=avx as in CI), Release, PR head 5bc68b1cc. With the test's Require changed locally to log and count instead of throwing, there are 114 mismatches. All are in the modes that keep f64 denormals (no known float mode, 1 and 3), none in modes 0 and 2. Besides frexp, floor, ceil and fract of a denormal input fail here too, for example v_ceil_f64 without a known float mode of 0x0000000000000001 is 0x0000000000000000, expected 0x3ff0000000000000. With Float64Instructions.cpp, SubwordPacking.cpp and TranslationContext.hpp from main and the test kept, the same 114 kept-mode rows fail, row for row. So these rows depend on the device, not on this PR's change.

Lavapipe hard-codes shaderDenormPreserveFloat64 = false (lvp_device.c, line 1043 at mesa-25.2.8, CI's version, and line 1122 at mesa-26.2.4), so these shaders get no DenormPreserve 64, and Vulkan then allows the driver to flush f64 denormals. Which rows fail changes with the Mesa version, so a list of rows to skip would need to follow it.

This is the gate @oneandonlydean suggested on #7042, applied per mode with the same float64DenormPreserve check F64FmaSubnormals.cpp uses:

+        const bool canPreserveDenormals = device->Target().float64DenormPreserve;
         for (const Mode& mode : modes) {
+            const bool keepsDenormals = !mode.value.has_value() || ((mode.value->floatMode >> 6u) & 1u) != 0u;
+            if (keepsDenormals && !canPreserveDenormals) {
+                std::cout << "skipped " << mode.name << ", the device does not report f64 DenormPreserve\n";
+                continue;
+            }
             Run(*device, mode);

ctest -R '^agc_driver_f64_rounding_denormal_modes$', 3 runs each, lavapipe:

                         this PR + gate    the three files from main + gate
result                   3/3 pass          3/3 fail

The failure in the second column is v_frexp_mant_f64 f64 denormal mode 0, IEEE mode on of 0x0000000000000001 is 0x3fe0000000000001, expected 0x0000000000000000, so with the gate the test still fails without the fix, in modes 0 and 2.

The cost is the one @jotitadev named: on a device that reports the feature false but keeps denormals, like the RTX 3070, the kept-mode rows are skipped too. Keeping them there would need the recompiler to compute these results from the bits when DenormPreserve is not available, or the rows to report a mismatch as a skip instead of a failure on such devices. I have not tried either.

Not tested: Windows, NVIDIA, or any AMD GPU.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6237947183 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7036#issuecomment-6237947183). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-17T17:46:26Z. --- @jotitadev's review found only the `frexp` rows failing on lavapipe with Mesa 26.0.3, and suggested skipping just those because the RTX 3070 reports `shaderDenormPreserveFloat64` false and still passes every row. On a newer lavapipe that narrower skip is not enough. Linux, lavapipe (Mesa 26.2.4, LLVM 23.1.1, `GALLIUM_OVERRIDE_CPU_CAPS=avx` as in CI), Release, PR head `5bc68b1cc`. With the test's `Require` changed locally to log and count instead of throwing, there are 114 mismatches. All are in the modes that keep f64 denormals (no known float mode, 1 and 3), none in modes 0 and 2. Besides `frexp`, `floor`, `ceil` and `fract` of a denormal input fail here too, for example `v_ceil_f64 without a known float mode of 0x0000000000000001 is 0x0000000000000000, expected 0x3ff0000000000000`. With `Float64Instructions.cpp`, `SubwordPacking.cpp` and `TranslationContext.hpp` from `main` and the test kept, the same 114 kept-mode rows fail, row for row. So these rows depend on the device, not on this PR's change. Lavapipe hard-codes `shaderDenormPreserveFloat64 = false` (`lvp_device.c`, line 1043 at `mesa-25.2.8`, CI's version, and line 1122 at `mesa-26.2.4`), so these shaders get no `DenormPreserve 64`, and Vulkan then allows the driver to flush f64 denormals. Which rows fail changes with the Mesa version, so a list of rows to skip would need to follow it. This is the gate @oneandonlydean suggested on #7042, applied per mode with the same `float64DenormPreserve` check `F64FmaSubnormals.cpp` uses: ```diff + const bool canPreserveDenormals = device->Target().float64DenormPreserve; for (const Mode& mode : modes) { + const bool keepsDenormals = !mode.value.has_value() || ((mode.value->floatMode >> 6u) & 1u) != 0u; + if (keepsDenormals && !canPreserveDenormals) { + std::cout << "skipped " << mode.name << ", the device does not report f64 DenormPreserve\n"; + continue; + } Run(*device, mode); ``` `ctest -R '^agc_driver_f64_rounding_denormal_modes$'`, 3 runs each, lavapipe: ``` this PR + gate the three files from main + gate result 3/3 pass 3/3 fail ``` The failure in the second column is `v_frexp_mant_f64 f64 denormal mode 0, IEEE mode on of 0x0000000000000001 is 0x3fe0000000000001, expected 0x0000000000000000`, so with the gate the test still fails without the fix, in modes 0 and 2. The cost is the one @jotitadev named: on a device that reports the feature false but keeps denormals, like the RTX 3070, the kept-mode rows are skipped too. Keeping them there would need the recompiler to compute these results from the bits when `DenormPreserve` is not available, or the rows to report a mismatch as a skip instead of a failure on such devices. I have not tried either. Not tested: Windows, NVIDIA, or any AMD GPU. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
thuanquang commented 2026-10-17 19:00:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-17T19:00:23Z.


Thanks for the lavapipe runs. b55d41151 adds the gate, with the rule F64FmaSubnormals.cpp uses: on a device whose target reports no f64 DenormPreserve, a mismatch in a mode that keeps f64 denormals (1, 3 and no known float mode) is printed as skipped instead of failing; modes 0 and 2, the ones this change fixes, are checked on every device. Rows that pass are still checked, so a device like the RTX 3070 keeps covering the kept modes. The branch is rebased onto main f219248f0.

RX 6700 XT, Windows: the test passes with no skipped mode, and with core/shader/recompiler from main it still fails: v_ceil_f64 f64 denormal mode 0, IEEE mode on of 0x0000000000000001 is 0x3ff0000000000000, expected 0x0000000000000000. I have not run lavapipe here.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6239097813 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7036#issuecomment-6239097813). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-17T19:00:23Z. --- Thanks for the lavapipe runs. b55d41151 adds the gate, with the rule `F64FmaSubnormals.cpp` uses: on a device whose target reports no f64 `DenormPreserve`, a mismatch in a mode that keeps f64 denormals (1, 3 and no known float mode) is printed as skipped instead of failing; modes 0 and 2, the ones this change fixes, are checked on every device. Rows that pass are still checked, so a device like the RTX 3070 keeps covering the kept modes. The branch is rebased onto `main` `f219248f0`. RX 6700 XT, Windows: the test passes with no skipped mode, and with `core/shader/recompiler` from `main` it still fails: `v_ceil_f64 f64 denormal mode 0, IEEE mode on of 0x0000000000000001 is 0x3ff0000000000000, expected 0x0000000000000000`. I have not run lavapipe here.
jotitadev commented 2026-10-18 00:05:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-18T00:05:17Z.

Review: COMMENTED


A rerun of the gate in b55d41151 on the two devices from my earlier run. It does what the commit says on both: the RTX 3070 still checks every kept-denormal row, and lavapipe skips only the rows it gets wrong.

Machine: Ubuntu 26.04, i7-8700, GCC 15.2, Release, BUILD_TESTING=ON. NVIDIA GeForce RTX 3070 (driver 595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same host. #7042 at 3221feb5a, which carries this PR's head b55d41151, merged onto main 5de7a46e0 (clean). ANYPS5_NO_SHADER_CACHE=1, -j1 --timeout 30.

RTX 3070 lavapipe
^agc_driver_f64 (11 tests) 11/11, 3 runs 11/11, 2 runs
skipped lines in agc_driver_f64_rounding_denormal_modes none 5: no known float mode and modes 1 and 3 (IEEE on/off), all on v_frexp_mant_f64 of 0x0000000000000001
same, with Float64Instructions.cpp, SubwordPacking.cpp and TranslationContext.hpp from main fails: v_ceil_f64 f64 denormal mode 0, IEEE mode on of 0x0000000000000001 is 0x3ff0000000000000, expected 0x0000000000000000 fails with the same message, after the same skip for no known float mode

Both devices report shaderDenormPreserveFloat64 = false. On the 3070 none of the kept-mode rows mismatch, so nothing is reported as skipped and those rows are still checked there. That answers the point from my earlier comment. Modes 0 and 2 are checked on both devices and still catch the missing flush.

Not run: Windows, AMD, a newer Mesa.

GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3), Ubuntu 26.04

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5560728512 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7036#pullrequestreview-5560728512). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-18T00:05:17Z. **Review:** COMMENTED --- A rerun of the gate in `b55d41151` on the two devices from my earlier run. It does what the commit says on both: the RTX 3070 still checks every kept-denormal row, and lavapipe skips only the rows it gets wrong. **Machine:** Ubuntu 26.04, i7-8700, GCC 15.2, Release, `BUILD_TESTING=ON`. NVIDIA GeForce RTX 3070 (driver 595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same host. #7042 at `3221feb5a`, which carries this PR's head `b55d41151`, merged onto `main` `5de7a46e0` (clean). `ANYPS5_NO_SHADER_CACHE=1`, `-j1 --timeout 30`. | | RTX 3070 | lavapipe | |---|---|---| | `^agc_driver_f64` (11 tests) | 11/11, 3 runs | 11/11, 2 runs | | `skipped` lines in `agc_driver_f64_rounding_denormal_modes` | none | 5: no known float mode and modes 1 and 3 (IEEE on/off), all on `v_frexp_mant_f64` of `0x0000000000000001` | | same, with `Float64Instructions.cpp`, `SubwordPacking.cpp` and `TranslationContext.hpp` from `main` | fails: `v_ceil_f64 f64 denormal mode 0, IEEE mode on of 0x0000000000000001 is 0x3ff0000000000000, expected 0x0000000000000000` | fails with the same message, after the same skip for no known float mode | Both devices report `shaderDenormPreserveFloat64 = false`. On the 3070 none of the kept-mode rows mismatch, so nothing is reported as skipped and those rows are still checked there. That answers the point from my earlier comment. Modes 0 and 2 are checked on both devices and still catch the missing flush. Not run: Windows, AMD, a newer Mesa. GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3), Ubuntu 26.04 Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!7036
No description provided.