fix(shader): round v_ldexp_f64 in the directed FLOAT_MODE rounding modes #26096

Merged
DannyOppenheimer merged 2 commits from upstream-pr/26096 into main 2026-11-27 20:50:37 +00:00
DannyOppenheimer commented 2026-11-23 08:36:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DannyOppenheimer on 2026-11-23T08:36:43Z.


What

v_ldexp_f64 was lowered to a host Ldexp that rounds to nearest even, so in the directed FLOAT_MODE f16/f64 round modes (round field 1 to 3, declared or set by s_round_mode) an overflow gave an infinity where the hardware gives the largest finite value (when the mode rounds toward zero for that sign), and a denormal result was rounded to nearest instead of in the mode. Scaling by a power of two is exact otherwise, so those are the only differences.

  • In the directed modes, ldexpF64 builds the result from the (flushed) source's significand and exponent bits with integer operations only, with no FPLdexp64 or other f64 float operation. In the normal range the result is exact and only the exponent changes. A subnormal result is the normalized significand shifted right, plus one unit when bits were shifted out and the mode rounds away from zero for that sign (which can carry into the minimum normal). An overflow gives an infinity, or the largest finite value when the mode rounds toward zero for that sign. Zeros, infinities and NaNs pass through, and the NaN and f64 output flush handling keeps running after it, as before. Round to nearest keeps the previous FPLdexp64 lowering.
  • Because nothing in the directed path is a float operation, its result does not depend on the device keeping f64 subnormals. A device without shaderDenormPreserveFloat64 gets no DenormPreserve 64, and Vulkan then lets it flush subnormal OpFMul results. The first version of this PR (02b18ec684) scaled the result back with FPLdexp64 to detect the rounding direction, which such a device could break (mihiii1337's review: 0x1 by 52 would step the exact minimum normal up by one unit).
  • RoundingMode.cpp classifies VLdexpF64 as Directed16, so a mode set by s_round_mode is modelled instead of rejected.
  • The debt entry of v_ldexp_f64 records the measurement.

Found by a differential sweep of VOP1/VOP2/VOP3 opcodes through tools/hw-oracle on an RX 5700 XT (gfx1010, RDNA1, the PS5's gfx10.1 generation) against the same bodies through agc_oracle_runner, in the directed FLOAT_MODE round modes.

Tested

Windows 11, Radeon RX 5700 XT (gfx1010), AMD driver 32.0.21045.5002.

  • Hardware model: over 1838 inputs (random values, exponents chosen to land the result around the overflow and denormal boundaries, and edge values) in all four round modes, all four f16/f64 denormal modes and IEEE 0 and 1, the hardware matches "round src0 * 2^n once in the mode; flush per the denormal field as before" exactly, except that a signaling NaN is returned unquieted at IEEE=0, which main already does. main differs from it on 129 to 571 of the 1838 rows per directed configuration, and on none at round to nearest.
  • With the first version of this PR (02b18ec684), agc_oracle_runner matched the model on all 32 configurations (0 mismatches), and the hardware on 11028 rows with s_round_mode 4, 8 and 12 at f16/f64 denormal modes 0 and 3. That sweep was not rerun on 811cc76112; the integer path is covered by the test and the exact-model check below.
  • New agc_driver_f64_ldexp_directed_rounding, with two tables of 32 inputs each and the hardware's results for round modes 1 to 3 in f16/f64 denormal modes 3 and 0:
    • Table 1: overflow, denormal results of both signs, flushed inputs and exact values.
    • Table 2, boundary rows: both review witnesses (0x1 by 52, 0x0010000000000000 by -1), results exactly at and just below the minimum normal, a round-up carrying into it, half-unit and 1.5-unit subnormals, exact overflow at 2^1024, and exponents of ±2^31. On the RX 5700 XT hardware oracle, all 384 results match (3 round modes × 2 denormal modes × IEEE 0 and 1 × 32 rows), and IEEE does not change any of them.
    • Each table runs with FLOAT_MODE 0xc0 and 0x00 at IEEE 0 and 1, declared and set by s_round_mode: 48 of 48 runs pass. On a device that offers shaderDenormPreserveFloat64, every run is repeated with DenormPreserve 64 turned off. The RX 5700 XT has no shaderDenormPreserveFloat64, so all its runs were already without it.
    • Before using the GPU, the test recompiles every directed mode, declared and via s_round_mode, for a target without DenormPreserve 64 and checks that the SPIR-V computes no f64 value. Round to nearest is checked to compute one, so the scan can detect them. This part needs no device. With 02b18ec684's lowering it fails: v_ldexp_f64 FLOAT_MODE 0xc4 computes an f64 value, which a device without DenormPreserve 64 may flush.
  • A Python copy of the new integer path matches an exact rational model on 835,344 cases (69,612 inputs × round modes 1 to 3 × all four denormal modes), concentrated at the subnormal, minimum normal and overflow boundaries and at extreme exponents. It also reproduces all 192 entries of the hardware table 1.
  • Validation: ctest --test-dir build -R "agc_driver_.*(directed_rounding|legacy|div_fmas|division|f64_fma|f64_ldexp|ldexp_f32|vop3_cube|nan_quieting|f64_arithmetic|f32_output_modifier|cubema)|agc_shader_mode_register" -V with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, Khronos validation layer 1.4.369, main at 28f493e6d1 and this branch at 811cc76112, each run after its test targets were relinked: main 21 of 21 passed, this branch 22 of 22 passed in 2 of 2 runs (with the new agc_driver_f64_ldexp_directed_rounding). Insert instance layer "VK_LAYER_KHRONOS_validation" appears 20 times on main and 21 times in each branch run, once per GPU test (agc_shader_mode_register creates no Vulkan instance). was not found but was requested appears 0 times in every log, and so does VUID-.
  • tools/check_conventions.py --base origin/main passes with one debt-length warning (the changed debt entry was already long) and tools/debt_fold.py --check passes.

tools/pr_overlap.py --branch reports one-line conflicts in the Unmodelled f16/f64 list of RoundingUseOf in RoundingMode.cpp: #22034 and #22446 (and #26101, stacked on #22446) remove the opcodes on the lines just above VLdexpF64, and #26047 removes the one just below; none of them changes v_ldexp_f64, and whichever lands second resolves the adjacent lines. ldexpF64 is called in the result expression and declared next to quietNan64 to stay clear of #22384 and #22446 in the same files. #20187 could not be compared automatically; its TranslationContext.hpp hunks add two unrelated members.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 5700 XT (gfx1010, RDNA1), AMD Windows driver 32.0.21045.5002, Windows 11 Home 10.0.26200
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5449802527 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26096). Originally posted by [DannyOppenheimer](https://github.com/DannyOppenheimer) on 2026-11-23T08:36:43Z. --- ### What `v_ldexp_f64` was lowered to a host `Ldexp` that rounds to nearest even, so in the directed `FLOAT_MODE` f16/f64 round modes (round field 1 to 3, declared or set by `s_round_mode`) an overflow gave an infinity where the hardware gives the largest finite value (when the mode rounds toward zero for that sign), and a denormal result was rounded to nearest instead of in the mode. Scaling by a power of two is exact otherwise, so those are the only differences. - In the directed modes, `ldexpF64` builds the result from the (flushed) source's significand and exponent bits with integer operations only, with no `FPLdexp64` or other f64 float operation. In the normal range the result is exact and only the exponent changes. A subnormal result is the normalized significand shifted right, plus one unit when bits were shifted out and the mode rounds away from zero for that sign (which can carry into the minimum normal). An overflow gives an infinity, or the largest finite value when the mode rounds toward zero for that sign. Zeros, infinities and NaNs pass through, and the NaN and f64 output flush handling keeps running after it, as before. Round to nearest keeps the previous `FPLdexp64` lowering. - Because nothing in the directed path is a float operation, its result does not depend on the device keeping f64 subnormals. A device without `shaderDenormPreserveFloat64` gets no `DenormPreserve 64`, and Vulkan then lets it flush subnormal `OpFMul` results. The first version of this PR (02b18ec684) scaled the result back with `FPLdexp64` to detect the rounding direction, which such a device could break (mihiii1337's review: `0x1` by 52 would step the exact minimum normal up by one unit). - `RoundingMode.cpp` classifies `VLdexpF64` as `Directed16`, so a mode set by `s_round_mode` is modelled instead of rejected. - The debt entry of `v_ldexp_f64` records the measurement. Found by a differential sweep of VOP1/VOP2/VOP3 opcodes through `tools/hw-oracle` on an RX 5700 XT (gfx1010, RDNA1, the PS5's gfx10.1 generation) against the same bodies through `agc_oracle_runner`, in the directed `FLOAT_MODE` round modes. ### Tested Windows 11, Radeon RX 5700 XT (gfx1010), AMD driver 32.0.21045.5002. - Hardware model: over 1838 inputs (random values, exponents chosen to land the result around the overflow and denormal boundaries, and edge values) in all four round modes, all four f16/f64 denormal modes and IEEE 0 and 1, the hardware matches "round `src0 * 2^n` once in the mode; flush per the denormal field as before" exactly, except that a signaling NaN is returned unquieted at IEEE=0, which `main` already does. `main` differs from it on 129 to 571 of the 1838 rows per directed configuration, and on none at round to nearest. - With the first version of this PR (02b18ec684), `agc_oracle_runner` matched the model on all 32 configurations (0 mismatches), and the hardware on 11028 rows with `s_round_mode` 4, 8 and 12 at f16/f64 denormal modes 0 and 3. That sweep was not rerun on 811cc76112; the integer path is covered by the test and the exact-model check below. - New `agc_driver_f64_ldexp_directed_rounding`, with two tables of 32 inputs each and the hardware's results for round modes 1 to 3 in f16/f64 denormal modes 3 and 0: - Table 1: overflow, denormal results of both signs, flushed inputs and exact values. - Table 2, boundary rows: both review witnesses (`0x1` by 52, `0x0010000000000000` by -1), results exactly at and just below the minimum normal, a round-up carrying into it, half-unit and 1.5-unit subnormals, exact overflow at 2^1024, and exponents of ±2^31. On the RX 5700 XT hardware oracle, all 384 results match (3 round modes × 2 denormal modes × IEEE 0 and 1 × 32 rows), and IEEE does not change any of them. - Each table runs with FLOAT_MODE 0xc0 and 0x00 at IEEE 0 and 1, declared and set by `s_round_mode`: 48 of 48 runs pass. On a device that offers `shaderDenormPreserveFloat64`, every run is repeated with `DenormPreserve 64` turned off. The RX 5700 XT has no `shaderDenormPreserveFloat64`, so all its runs were already without it. - Before using the GPU, the test recompiles every directed mode, declared and via `s_round_mode`, for a target without `DenormPreserve 64` and checks that the SPIR-V computes no f64 value. Round to nearest is checked to compute one, so the scan can detect them. This part needs no device. With 02b18ec684's lowering it fails: `v_ldexp_f64 FLOAT_MODE 0xc4 computes an f64 value, which a device without DenormPreserve 64 may flush`. - A Python copy of the new integer path matches an exact rational model on 835,344 cases (69,612 inputs × round modes 1 to 3 × all four denormal modes), concentrated at the subnormal, minimum normal and overflow boundaries and at extreme exponents. It also reproduces all 192 entries of the hardware table 1. - Validation: `ctest --test-dir build -R "agc_driver_.*(directed_rounding|legacy|div_fmas|division|f64_fma|f64_ldexp|ldexp_f32|vop3_cube|nan_quieting|f64_arithmetic|f32_output_modifier|cubema)|agc_shader_mode_register" -V` with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer`, Khronos validation layer 1.4.369, `main` at 28f493e6d1 and this branch at 811cc76112, each run after its test targets were relinked: `main` 21 of 21 passed, this branch 22 of 22 passed in 2 of 2 runs (with the new `agc_driver_f64_ldexp_directed_rounding`). `Insert instance layer "VK_LAYER_KHRONOS_validation"` appears 20 times on `main` and 21 times in each branch run, once per GPU test (`agc_shader_mode_register` creates no Vulkan instance). `was not found but was requested` appears 0 times in every log, and so does `VUID-`. - `tools/check_conventions.py --base origin/main` passes with one `debt-length` warning (the changed debt entry was already long) and `tools/debt_fold.py --check` passes. `tools/pr_overlap.py --branch` reports one-line conflicts in the `Unmodelled` f16/f64 list of `RoundingUseOf` in `RoundingMode.cpp`: #22034 and #22446 (and #26101, stacked on #22446) remove the opcodes on the lines just above `VLdexpF64`, and #26047 removes the one just below; none of them changes `v_ldexp_f64`, and whichever lands second resolves the adjacent lines. `ldexpF64` is called in the `result` expression and declared next to `quietNan64` to stay clear of #22384 and #22446 in the same files. #20187 could not be compared automatically; its `TranslationContext.hpp` hunks add two unrelated members. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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) and the licence notice of code adapted from upstream (see AGENTS.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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: AMD Radeon RX 5700 XT (gfx1010, RDNA1), AMD Windows driver 32.0.21045.5002, Windows 11 Home 10.0.26200 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-23 09:09:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T09:09:01Z.

Review: COMMENTED


Reviewed — comments

The directed-rounding correction is supported by the inspected implementation and test cases; I did not run the reported validation, so this review does not justify approval.

What I ran

Reviewed head 02b18ec68402d278856865591c542de65afe57cc using the prepared diff and repo_read.py. No tests or build commands were run.

Results

Check Result Note
Diff and changed source passed All five changed files read
Tests and build not run Results in the description are author-reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

No tests or build were run. The hardware measurements and reported validation results were not independently verified. The prepared bundle excluded no changed files; all five changed files were read.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6018963211 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26096#pullrequestreview-6018963211). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-23T09:09:01Z. **Review:** COMMENTED --- # Reviewed — comments The directed-rounding correction is supported by the inspected implementation and test cases; I did not run the reported validation, so this review does not justify approval. ## What I ran Reviewed head `02b18ec68402d278856865591c542de65afe57cc` using the prepared diff and `repo_read.py`. No tests or build commands were run. ## Results | Check | Result | Note | |---|---|---| | Diff and changed source | passed | All five changed files read | | Tests and build | not run | Results in the description are author-reported | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No tests or build were run. The hardware measurements and reported validation results were not independently verified. The prepared bundle excluded no changed files; all five changed files were read. ## To get this to a good state Nothing is required.
mihiii1337 commented 2026-11-23 09:42:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-23T09:42:57Z.

Review: CHANGES_REQUESTED


The directed-rounding correction works when f64 subnormals are preserved, but it can mis-step an already exact result on a Vulkan device where shaderDenormPreserveFloat64 is unavailable. The backend emits DenormPreserve 64 only when that property is supported; otherwise Vulkan permits denormal inputs or results of OpFMul to be flushed to zero by default.

A concrete source-path witness is positive min-subnormal (0x0000000000000001) with exponent 52, rounding toward +infinity, and guest f64 denorm mode 1 or 3. The forward FPLdexp64 result is exactly min-normal (0x0010000000000000). On an allowed host model which preserves the source operand but flushes the subnormal result of the inverse scaling at line 137, back becomes zero. The new comparison then classifies the exact forward result as too small and returns 0x0010000000000001. A second witness, min-normal with exponent -1 in mode 3, becomes 0x1 instead of 0x0008000000000000 under the same model.

Please make the inexact-direction test independent of host denormal handling, for example by comparing exponent/significand information in integer form, or provide a correct fallback when DenormPreserve 64 cannot be enabled. Add a regression that models the result-FTZ path.

The CPU oracle matched all 192/192 checked-in rows and 108,096/108,096 additional exact-Fraction cases under RNE with gradual underflow; removing the correction differed in 49 checked-in rows. It also reproduced both result-FTZ witnesses above. This is an allowed Vulkan behavior model, not a measured physical-driver failure. The exact Windows job passed 227 other tests but its whitelist did not execute the new fixture; Linux was skipped. Merge, diff, conventions (zero errors, one existing debt-length warning), and debt folding passed. No shader or GPU test was run in this review.

Vulkan default denormal rule: https://docs.vulkan.org/spec/latest/appendices/spirvenv.html#spirvenv-precision-operation

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6019372627 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26096#pullrequestreview-6019372627). Originally posted by [mihiii1337](https://github.com/mihiii1337) on 2026-11-23T09:42:57Z. **Review:** CHANGES_REQUESTED --- The directed-rounding correction works when f64 subnormals are preserved, but it can mis-step an already exact result on a Vulkan device where `shaderDenormPreserveFloat64` is unavailable. The backend emits `DenormPreserve 64` only when that property is supported; otherwise Vulkan permits denormal inputs or results of `OpFMul` to be flushed to zero by default. A concrete source-path witness is positive min-subnormal (`0x0000000000000001`) with exponent `52`, rounding toward +infinity, and guest f64 denorm mode 1 or 3. The forward `FPLdexp64` result is exactly min-normal (`0x0010000000000000`). On an allowed host model which preserves the source operand but flushes the subnormal result of the inverse scaling at line 137, `back` becomes zero. The new comparison then classifies the exact forward result as too small and returns `0x0010000000000001`. A second witness, min-normal with exponent `-1` in mode 3, becomes `0x1` instead of `0x0008000000000000` under the same model. Please make the inexact-direction test independent of host denormal handling, for example by comparing exponent/significand information in integer form, or provide a correct fallback when `DenormPreserve 64` cannot be enabled. Add a regression that models the result-FTZ path. The CPU oracle matched all 192/192 checked-in rows and 108,096/108,096 additional exact-Fraction cases under RNE with gradual underflow; removing the correction differed in 49 checked-in rows. It also reproduced both result-FTZ witnesses above. This is an allowed Vulkan behavior model, not a measured physical-driver failure. The exact Windows job passed 227 other tests but its whitelist did not execute the new fixture; Linux was skipped. Merge, diff, conventions (zero errors, one existing debt-length warning), and debt folding passed. No shader or GPU test was run in this review. Vulkan default denormal rule: https://docs.vulkan.org/spec/latest/appendices/spirvenv.html#spirvenv-precision-operation AI-assisted: yes.
Superseabas commented 2026-11-23 12:38:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-23T12:38:08Z.

Review: COMMENTED


Windows check of head 02b18ec684 on an NVIDIA GPU that lacks shaderDenormPreserveFloat64, the kind of device mihiii1337's change request is about, with an AMD GPU that has it as the control. Merged onto main 071799dc88 (clean merge). I also ran mihiii1337's witness through the PR's test.

Setup: Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (x86_64-ucrt-posix-seh, r3), Release full build, run from PowerShell with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. GPUs, each picked with ANYPS5_GPU:

  • NVIDIA GeForce RTX 5070 Ti (621.01): vulkaninfo reports shaderDenormPreserveFloat64 = false and shaderDenormFlushToZeroFloat64 = false, so the backend emits no DenormPreserve 64.
  • The Ryzen 7 7700X's integrated AMD Radeon (1002:164e, Adrenalin 26.10.2): shaderDenormPreserveFloat64 = true.

This was built together with #26174, #26178 and #26179, which touch other files.

  • agc_driver_f64_ldexp_directed_rounding, agc_driver_f64_ldexp_denormal_modes, agc_driver_f64_arithmetic, agc_driver_div_fixup_directed_rounding and the f16/f32/SDWA/VOP3 ldexp tests: main 8 of 8, and with this PR 9 of 9 in 2 of 2 runs, on both GPUs. No VUID- lines.
  • mihiii1337's witness: I swapped lane 5 of F64LdexpDirectedRounding.cpp (0, exponent 1023) for source 0x0000000000000001, exponent 52. The exact result is min-normal 0x0010000000000000 with f64 denormals kept (FLOAT_MODE 0xc_), and 0 with them flushed (0x0_). The test's three directed round modes pass on both GPUs, with both denormal modes and both IEEE settings, declared and through s_round_mode. So on this NVIDIA device the inverse scale at line 137 keeps the subnormal, and the forward result is not stepped.
  • Red check: with roundLdexpF64 returning the round-to-nearest result, agc_driver_f64_ldexp_directed_rounding fails with v_ldexp_f64 FLOAT_MODE 0xc4, IEEE=0 of 0x37bdf5f56940975e by -917 is 0x3bebead, expected 0x3bebeae.

This doesn't settle the change request. Vulkan still lets a device without shaderDenormPreserveFloat64 flush that OpFMul; this one happens not to. It does show the PR works on a real device without the guarantee. If the comparison is made independent of the preserved subnormal, the witness row above would be a cheap regression case to keep.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6021822814 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26096#pullrequestreview-6021822814). Originally posted by [Superseabas](https://github.com/Superseabas) on 2026-11-23T12:38:08Z. **Review:** COMMENTED --- Windows check of head `02b18ec684` on an NVIDIA GPU that lacks `shaderDenormPreserveFloat64`, the kind of device mihiii1337's change request is about, with an AMD GPU that has it as the control. Merged onto `main` `071799dc88` (clean merge). I also ran mihiii1337's witness through the PR's test. **Setup:** Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (`x86_64-ucrt-posix-seh`, r3), Release full build, run from PowerShell with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`. GPUs, each picked with `ANYPS5_GPU`: - NVIDIA GeForce RTX 5070 Ti (621.01): `vulkaninfo` reports `shaderDenormPreserveFloat64 = false` and `shaderDenormFlushToZeroFloat64 = false`, so the backend emits no `DenormPreserve 64`. - The Ryzen 7 7700X's integrated AMD Radeon (`1002:164e`, Adrenalin 26.10.2): `shaderDenormPreserveFloat64 = true`. This was built together with #26174, #26178 and #26179, which touch other files. - `agc_driver_f64_ldexp_directed_rounding`, `agc_driver_f64_ldexp_denormal_modes`, `agc_driver_f64_arithmetic`, `agc_driver_div_fixup_directed_rounding` and the f16/f32/SDWA/VOP3 ldexp tests: `main` 8 of 8, and with this PR 9 of 9 in 2 of 2 runs, on both GPUs. No `VUID-` lines. - **mihiii1337's witness:** I swapped lane 5 of `F64LdexpDirectedRounding.cpp` (`0`, exponent 1023) for source `0x0000000000000001`, exponent 52. The exact result is min-normal `0x0010000000000000` with f64 denormals kept (`FLOAT_MODE` 0xc_), and `0` with them flushed (0x0_). The test's three directed round modes pass on both GPUs, with both denormal modes and both IEEE settings, declared and through `s_round_mode`. So on this NVIDIA device the inverse scale at line 137 keeps the subnormal, and the forward result is not stepped. - **Red check:** with `roundLdexpF64` returning the round-to-nearest result, `agc_driver_f64_ldexp_directed_rounding` fails with `v_ldexp_f64 FLOAT_MODE 0xc4, IEEE=0 of 0x37bdf5f56940975e by -917 is 0x3bebead, expected 0x3bebeae`. This doesn't settle the change request. Vulkan still lets a device without `shaderDenormPreserveFloat64` flush that `OpFMul`; this one happens not to. It does show the PR works on a real device without the guarantee. If the comparison is made independent of the preserved subnormal, the witness row above would be a cheap regression case to keep. AI-assisted: yes (Claude Code)
mihiii1337 commented 2026-11-24 13:23:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-24T13:23:02Z.

Review: APPROVED


Rechecked exact head 811cc7611244ffd82721d3d1ec2cdae5d2bf6ebc. The no-shaderDenormPreserveFloat64 case from my previous review is fixed.

The new path handles the directed adjustment through an integer significand/exponent representation and pins both exact-result witnesses. Its SPIR-V scan runs before Vulkan execution; the emitted shift width is masked to 63, so the unused branch does not introduce an oversized SPIR-V shift.

The exact Hosted Windows selection passes 227/227, although it does not execute the new Vulkan case. Contributor-reported hardware evidence does: on a Quadro P3200 that exposes Float64 without Float64 denormal preserve, the new test fails on main and passes here; RTX 4070 and RTX 3070 runs also pass with validation enabled and no VUIDs. I did not run a GPU test on my machine for this review.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6039947563 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26096#pullrequestreview-6039947563). Originally posted by [mihiii1337](https://github.com/mihiii1337) on 2026-11-24T13:23:02Z. **Review:** APPROVED --- Rechecked exact head `811cc7611244ffd82721d3d1ec2cdae5d2bf6ebc`. The no-`shaderDenormPreserveFloat64` case from my previous review is fixed. The new path handles the directed adjustment through an integer significand/exponent representation and pins both exact-result witnesses. Its SPIR-V scan runs before Vulkan execution; the emitted shift width is masked to 63, so the unused branch does not introduce an oversized SPIR-V shift. The exact Hosted Windows selection passes 227/227, although it does not execute the new Vulkan case. Contributor-reported hardware evidence does: on a Quadro P3200 that exposes Float64 without Float64 denormal preserve, the new test fails on main and passes here; RTX 4070 and RTX 3070 runs also pass with validation enabled and no VUIDs. I did not run a GPU test on my machine for this review. AI-assisted: yes.
Superseabas commented 2026-11-24 17:09:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-24T17:09:04Z.

Review: APPROVED


Re-review on Windows of head 811cc76112, on the same RTX 5070 Ti as my earlier comment (shaderDenormPreserveFloat64 = false), with the Radeon iGPU (which has it) as the control.

Setup: Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (x86_64-ucrt-posix-seh, r3), Release full build, run from PowerShell with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. GPUs, each picked with ANYPS5_GPU: NVIDIA GeForce RTX 5070 Ti (621.01) and the Ryzen 7 7700X's integrated AMD Radeon (1002:164e, Adrenalin 26.10.2). Merged onto main 45fc4e23bb (clean merge), built together with #26098 and #19532, which touch other files.

  • agc_driver_f64_ldexp_directed_rounding, agc_driver_f64_ldexp_denormal_modes, agc_driver_f64_arithmetic, agc_driver_div_fixup_directed_rounding, the f16/f32/SDWA/VOP3 ldexp tests and agc_shader_mode_register: main 9 of 9, and with this PR 10 of 10 in 2 of 2 runs, on both GPUs. No VUID- lines.
  • Red check: with overflow always giving the largest finite value, agc_driver_f64_ldexp_directed_rounding fails on the RTX with v_ldexp_f64 FLOAT_MODE 0xc4, IEEE=0 of 0xf7cf1df9ed6ce by 2048 is 0x7fefffffffffffff, expected 0x7ff0000000000000.

The code: the directed path no longer computes any f64 value, which settles the question my earlier comment left open; that comment's probe only showed this device happens to keep the subnormal. The integer version reads right to me:

  • The significand is normalised with FindUMsb64, so a subnormal source works.
  • A result below the normal range is shifted with a sticky test and stepped once only when inexact and the mode rounds away. A carry out of the shift lands on the min-normal encoding, as it should.
  • Overflow gives infinity or the largest finite value from the mode and the sign.
  • NaN, infinity and zero pass through unchanged.

Round to nearest keeps FPLdexp64.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6043887762 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26096#pullrequestreview-6043887762). Originally posted by [Superseabas](https://github.com/Superseabas) on 2026-11-24T17:09:04Z. **Review:** APPROVED --- Re-review on Windows of head `811cc76112`, on the same RTX 5070 Ti as my earlier comment (`shaderDenormPreserveFloat64 = false`), with the Radeon iGPU (which has it) as the control. **Setup:** Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (`x86_64-ucrt-posix-seh`, r3), Release full build, run from PowerShell with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`. GPUs, each picked with `ANYPS5_GPU`: NVIDIA GeForce RTX 5070 Ti (621.01) and the Ryzen 7 7700X's integrated AMD Radeon (`1002:164e`, Adrenalin 26.10.2). Merged onto `main` `45fc4e23bb` (clean merge), built together with #26098 and #19532, which touch other files. - `agc_driver_f64_ldexp_directed_rounding`, `agc_driver_f64_ldexp_denormal_modes`, `agc_driver_f64_arithmetic`, `agc_driver_div_fixup_directed_rounding`, the f16/f32/SDWA/VOP3 ldexp tests and `agc_shader_mode_register`: `main` 9 of 9, and with this PR 10 of 10 in 2 of 2 runs, on both GPUs. No `VUID-` lines. - **Red check:** with overflow always giving the largest finite value, `agc_driver_f64_ldexp_directed_rounding` fails on the RTX with `v_ldexp_f64 FLOAT_MODE 0xc4, IEEE=0 of 0xf7cf1df9ed6ce by 2048 is 0x7fefffffffffffff, expected 0x7ff0000000000000`. **The code:** the directed path no longer computes any f64 value, which settles the question my earlier comment left open; that comment's probe only showed this device happens to keep the subnormal. The integer version reads right to me: - The significand is normalised with `FindUMsb64`, so a subnormal source works. - A result below the normal range is shifted with a sticky test and stepped once only when inexact and the mode rounds away. A carry out of the shift lands on the min-normal encoding, as it should. - Overflow gives infinity or the largest finite value from the mode and the sign. - NaN, infinity and zero pass through unchanged. Round to nearest keeps `FPLdexp64`. AI-assisted: yes (Claude Code)
MarcZX10 commented 2026-11-24 23:33:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-24T23:33:06Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change; the reported measurements are author-supplied and the review did not run the test suite.

What I ran

Reviewed head 811cc7611244ffd82721d3d1ec2cdae5d2bf6ebc. No commands or tests were run. Read the prepared description, commits, diff, manifest and all five changed files; there were no exclusions listed in the manifest. The repository reader script and its search interface were not available through the provided tools, so I could not inspect additional callers or test registration.

Results

Check Result Note
Diff and changed code passed Inspected all five changed files
Test suite not run No execution interface available
Additional callers and test registration not run Repository search unavailable

Findings

Blocking

None.

Non-blocking

None.

Not verified

The test harness's discovery or registration of the new execution test, additional callers, build results, hardware behavior, and the reported sweeps and CI checks were not independently verified. The changed files read were core/libs/prx/libSceAgcDriver/tests/execution/F64LdexpDirectedRounding.cpp, core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp, core/shader/recompiler/Translation/src/Float64Instructions.cpp, core/shader/recompiler/Translation/src/RoundingMode.cpp, and docs/dev/debt/changes/ldexp-f64-directed-rounding.md.

To get this to a good state

Nothing is required. The optional next step is to confirm the new execution test is included in the project's test discovery and run the reported checks on this head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6049109473 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26096#pullrequestreview-6049109473). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-24T23:33:06Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change; the reported measurements are author-supplied and the review did not run the test suite. ## What I ran Reviewed head `811cc7611244ffd82721d3d1ec2cdae5d2bf6ebc`. No commands or tests were run. Read the prepared description, commits, diff, manifest and all five changed files; there were no exclusions listed in the manifest. The repository reader script and its search interface were not available through the provided tools, so I could not inspect additional callers or test registration. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code | passed | Inspected all five changed files | | Test suite | not run | No execution interface available | | Additional callers and test registration | not run | Repository search unavailable | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The test harness's discovery or registration of the new execution test, additional callers, build results, hardware behavior, and the reported sweeps and CI checks were not independently verified. The changed files read were `core/libs/prx/libSceAgcDriver/tests/execution/F64LdexpDirectedRounding.cpp`, `core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp`, `core/shader/recompiler/Translation/src/Float64Instructions.cpp`, `core/shader/recompiler/Translation/src/RoundingMode.cpp`, and `docs/dev/debt/changes/ldexp-f64-directed-rounding.md`. ## To get this to a good state Nothing is required. The optional next step is to confirm the new execution test is included in the project's test discovery and run the reported checks on this head.
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!26096
No description provided.