perf(shader): compute scalar f16 add, sub and mul with native f16 math #3557

Merged
karanvora2599 merged 3 commits from upstream-pr/3557 into main 2026-10-17 07:35:26 +00:00
karanvora2599 commented 2026-10-11 13:11:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by karanvora2599 on 2026-10-11T13:11:09Z.


What

v_add_f16, v_sub_f16, v_subrev_f16 and v_mul_f16 now use native f16 math. The conditions are those the packed instructions use: the device has native f16 with round to nearest even and kept denormals, and FLOAT_MODE keeps f16 denormals and rounds f16 to nearest even (or the shader has no FLOAT_MODE). Each instruction becomes one f16 add or mul on the source bits; sub adds the negated subtrahend. The FP16_OVFL and clamp rules then run on the result bits. Other f16 modes keep the f32 path, including the denormal flushes from #2987 and the directed rounding from #3012.

It uses the native f16 operations, the nativeFloat16 translation option and EmitNativeF16Modes from #3531, which has merged; the branch is rebased onto main.

Background. These instructions converted both sources to f32, computed in f32 and converted the result back to f16. NVIDIA (from Turing on), Intel and AMD GPUs execute f16 add and multiply directly.

v_fma_f16, v_fmac_f16, v_fmamk_f16 and v_fmaak_f16 keep their exact f32 path (#2000): Vulkan gives GLSL Fma only the precision of OpFMul followed by OpFAdd, so a native f16 Fma may round twice. OpFmaKHR (VK_KHR_shader_fma, shaderFmaFloat16) would allow it; none of the drivers I can test exposes it yet.

Before / after on an RTX 4060 Laptop (Ada, driver 591.86). SASS instructions per instruction come from APS5_PIPELINE_STATS binary size over a chain of 16 instructions, FLOAT_MODE 0xc0:

Instruction SASS before SASS after
v_add_f16 27.5 1.5
v_sub_f16 27.5 2.0
v_subrev_f16 27.5 2.5
v_mul_f16 27.5 1.5

All other opcodes in the sweep compile to the same size.

Runtime on the same GPU, one build: each instruction is compiled once for the device and once for the same target without Float16 (the f32 path main takes), as a dependent chain of 2048 instructions over 16384 groups of 32 threads, FLOAT_MODE 0xc0; median of 15 interleaved dispatches. A v_fma_f32 chain takes 6.7 ms.

Chain f32 path native
v_add_f16 16.6 ms 0.94 ms
v_mul_f16 15.4 ms 0.75 ms

Why results don't change.

  • For add, sub and mul, f32 has at least 2 × 11 + 2 significand bits, so rounding the exact result to f32 and then to f16 gives the correctly rounded f16 result.
  • Vulkan requires f16 OpFAdd and OpFMul to be correctly rounded; the module declares round to nearest even and preserved denormals for f16, and NoContraction keeps the driver from fusing them.
  • FP16_OVFL turns an infinite result from finite sources into ±0x7bff, as clampF16Overflow does in f32.
  • Clamp uses clampF16Bits, which matches applyF16ResultModifiers: clamping commutes with round to nearest because 0 and 1 are representable, and with DX10_CLAMP a NaN clamps to +0.
  • A NaN result keeps the payload the driver gives. docs/dev/TechnicalDebt.md already lists the NaN payloads of scalar f16 arithmetic as the driver's, not the hardware's input propagation, and this doesn't change that. The payload now comes from the driver's f16 arithmetic instead of its f32 arithmetic.

Where it matters. Shaders with scalar f16 math. Devices without native f16, and shaders whose FLOAT_MODE flushes f16 denormals or rounds f16 another way, are unchanged.

Tested

Windows 11, MinGW-w64 GCC 15.2.0, Release, rebased onto main at bab7b328 (with #4021's Socket.cpp fix applied locally, which main has since merged). RTX 4060 Laptop (driver 591.86), Intel UHD Graphics (Raptor Lake, driver 101.6790) and lavapipe from Mesa 25.2.8 (the version CI installs; Windows build, GALLIUM_OVERRIDE_CPU_CAPS=avx).

  • New agc_driver_float16_native:
    • It compiles one shader twice, with and without Float16, and compares every result.
    • The shader covers v_add_f16, v_sub_f16, v_subrev_f16 and v_mul_f16 (VOP2, and VOP3 with abs, neg and clamp), v_sub_f16 with an inline constant, and the fma forms (v_fma_f16 with op_sel, abs, neg and clamp, v_fmac_f16, v_fmamk_f16 with a literal, v_fmaak_f16 with a denormal literal), which must keep the f32 path.
    • It runs in ten float modes: no FLOAT_MODE, every combination of DX10_CLAMP, IEEE_MODE and FP16_OVFL at 0xc0, and 0x30 (f16 denormals flushed), where it checks that the f32 path is kept.
    • It checks that the native build uses f16 add and mul and no f16 Fma.
    • Results must be equal bit for bit, except that two NaN results may carry different payloads.
    • Results: 327,680 identical on the RTX 4060. On the Intel UHD all non-NaN results are identical and 604 NaN results have another payload. Skipped on lavapipe, which doesn't preserve f16 denormals.
    • The skip message reads f16 native: skipped, the device has no native f16 with RTE rounding and kept denormals, the form tools/check_skips.py accepts as a device limitation, as agc_driver_packed_float16_native has it.
    • The scanner that checks the emitted f16 math bounds its reads by each instruction's word count (fix by @jweidenh in review).
    • Two deliberate bugs make it fail: leaving out the FP16_OVFL fix (v_mul_f16 gives 0xfc00 where the f32 path gives 0xfbff), and leaving out the clamp (v_add_f16 ... clamp gives 0x81f4 where the f32 path gives 0).
  • The f16, packed f16, fp16_* and SDWA tests (18) pass on all three devices.
  • The shader tests (agc_driver_*, agc_shader_*, agc_spirv_*, vector_*, agc_masked_select, agc_validate_program, agc_denormal*, agc_float16_*; 338 tests). I left out the BDA tests that hang on driver 591.86 until #3291 lands.
    • RTX 4060: everything passes except agc_driver_prepared_shaders_registered_workgroup_sync (added by #2261), which fails the same way on a build without this change. agc_driver_graphics failed once during the suite and passes on its own.
    • Intel UHD: the same, plus agc_driver_ds_swizzle and agc_driver_f32_dot2_rounding (no Float64; it throws instead of skipping), which fail the same way with main's recompiler.
    • lavapipe 25.2.8: the same, plus the intermittent agc_driver_depth_fast_clear_submit segfault that also happens with main's recompiler.
  • Rebased onto main c7601b797, with the skip message reworded (see above):
    • The f16, packed f16, SDWA, VOPC compare table, interpolation and mix tests and agc_shader_memory/agc_shader_disk_cache (28) pass on all three devices or are skipped for a missing feature.
    • tools/check_skips.py on lavapipe's ctest JUnit file accepts all three skips, agc_driver_float16_native included. The old wording doesn't match its pattern, which is what failed the Linux job.
    • Shader tests (381): everything passes on the RTX 4060. On the Intel UHD only agc_driver_ds_swizzle fails, as with main's recompiler. On lavapipe 25.2.8 there are two segfaults: the intermittent agc_driver_depth_fast_clear_submit, and agc_driver_depth_storage_dispatch (new on main, 738ae9df0), which segfaults 4 of 5 times on its own and has no f16 code.

Limits.

  • AMD: @thuanquang ran it on an RX 6700 XT (RDNA2, Adrenalin 26.8.1, Windows 11). The native path is taken, agc_driver_float16_native passes 3 of 3, and every non-NaN result is identical; 15,592 NaN results carry another payload. The same four tests fail with and without this change on that machine.
  • The decoder still rejects op_sel on the VOP3 forms of v_add_f16, v_sub_f16, v_subrev_f16 and v_mul_f16, as before; abs, neg and clamp on them go through the native path.
  • The f16 fma forms, v_ldexp_f16 and the f16 transcendentals still compute in f32. v_min_f16 and v_max_f16 pick their result on the bits since #3590.

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: NVIDIA GeForce RTX 4060 Laptop GPU (Ada), driver 591.86, Windows 11; Intel UHD Graphics (Raptor Lake), driver 101.6790, Windows 11; lavapipe (Mesa 25.2.8), Windows 11
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4819294047 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3557). Originally posted by [karanvora2599](https://github.com/karanvora2599) on 2026-10-11T13:11:09Z. --- ### What `v_add_f16`, `v_sub_f16`, `v_subrev_f16` and `v_mul_f16` now use native f16 math. The conditions are those the packed instructions use: the device has native f16 with round to nearest even and kept denormals, and `FLOAT_MODE` keeps f16 denormals and rounds f16 to nearest even (or the shader has no `FLOAT_MODE`). Each instruction becomes one f16 add or mul on the source bits; sub adds the negated subtrahend. The `FP16_OVFL` and clamp rules then run on the result bits. Other f16 modes keep the f32 path, including the denormal flushes from #2987 and the directed rounding from #3012. It uses the native f16 operations, the `nativeFloat16` translation option and `EmitNativeF16Modes` from #3531, which has merged; the branch is rebased onto `main`. **Background.** These instructions converted both sources to f32, computed in f32 and converted the result back to f16. NVIDIA (from Turing on), Intel and AMD GPUs execute f16 add and multiply directly. `v_fma_f16`, `v_fmac_f16`, `v_fmamk_f16` and `v_fmaak_f16` keep their exact f32 path (#2000): Vulkan gives GLSL `Fma` only the precision of `OpFMul` followed by `OpFAdd`, so a native f16 `Fma` may round twice. `OpFmaKHR` (`VK_KHR_shader_fma`, `shaderFmaFloat16`) would allow it; none of the drivers I can test exposes it yet. **Before / after** on an RTX 4060 Laptop (Ada, driver 591.86). SASS instructions per instruction come from `APS5_PIPELINE_STATS` binary size over a chain of 16 instructions, `FLOAT_MODE` 0xc0: | Instruction | SASS before | SASS after | |---|---|---| | `v_add_f16` | 27.5 | 1.5 | | `v_sub_f16` | 27.5 | 2.0 | | `v_subrev_f16` | 27.5 | 2.5 | | `v_mul_f16` | 27.5 | 1.5 | All other opcodes in the sweep compile to the same size. Runtime on the same GPU, one build: each instruction is compiled once for the device and once for the same target without `Float16` (the f32 path `main` takes), as a dependent chain of 2048 instructions over 16384 groups of 32 threads, `FLOAT_MODE` 0xc0; median of 15 interleaved dispatches. A `v_fma_f32` chain takes 6.7 ms. | Chain | f32 path | native | |---|---|---| | `v_add_f16` | 16.6 ms | 0.94 ms | | `v_mul_f16` | 15.4 ms | 0.75 ms | **Why results don't change.** - For add, sub and mul, f32 has at least 2 × 11 + 2 significand bits, so rounding the exact result to f32 and then to f16 gives the correctly rounded f16 result. - Vulkan requires f16 `OpFAdd` and `OpFMul` to be correctly rounded; the module declares round to nearest even and preserved denormals for f16, and `NoContraction` keeps the driver from fusing them. - `FP16_OVFL` turns an infinite result from finite sources into ±`0x7bff`, as `clampF16Overflow` does in f32. - Clamp uses `clampF16Bits`, which matches `applyF16ResultModifiers`: clamping commutes with round to nearest because 0 and 1 are representable, and with `DX10_CLAMP` a NaN clamps to +0. - A NaN result keeps the payload the driver gives. `docs/dev/TechnicalDebt.md` already lists the NaN payloads of scalar f16 arithmetic as the driver's, not the hardware's input propagation, and this doesn't change that. The payload now comes from the driver's f16 arithmetic instead of its f32 arithmetic. **Where it matters.** Shaders with scalar f16 math. Devices without native f16, and shaders whose `FLOAT_MODE` flushes f16 denormals or rounds f16 another way, are unchanged. ### Tested Windows 11, MinGW-w64 GCC 15.2.0, Release, rebased onto `main` at bab7b328 (with #4021's `Socket.cpp` fix applied locally, which `main` has since merged). RTX 4060 Laptop (driver 591.86), Intel UHD Graphics (Raptor Lake, driver 101.6790) and lavapipe from Mesa 25.2.8 (the version CI installs; Windows build, `GALLIUM_OVERRIDE_CPU_CAPS=avx`). - New `agc_driver_float16_native`: - It compiles one shader twice, with and without `Float16`, and compares every result. - The shader covers `v_add_f16`, `v_sub_f16`, `v_subrev_f16` and `v_mul_f16` (VOP2, and VOP3 with abs, neg and clamp), `v_sub_f16` with an inline constant, and the fma forms (`v_fma_f16` with `op_sel`, abs, neg and clamp, `v_fmac_f16`, `v_fmamk_f16` with a literal, `v_fmaak_f16` with a denormal literal), which must keep the f32 path. - It runs in ten float modes: no `FLOAT_MODE`, every combination of `DX10_CLAMP`, `IEEE_MODE` and `FP16_OVFL` at 0xc0, and 0x30 (f16 denormals flushed), where it checks that the f32 path is kept. - It checks that the native build uses f16 add and mul and no f16 `Fma`. - Results must be equal bit for bit, except that two NaN results may carry different payloads. - Results: 327,680 identical on the RTX 4060. On the Intel UHD all non-NaN results are identical and 604 NaN results have another payload. Skipped on lavapipe, which doesn't preserve f16 denormals. - The skip message reads `f16 native: skipped, the device has no native f16 with RTE rounding and kept denormals`, the form `tools/check_skips.py` accepts as a device limitation, as `agc_driver_packed_float16_native` has it. - The scanner that checks the emitted f16 math bounds its reads by each instruction's word count (fix by @jweidenh in review). - Two deliberate bugs make it fail: leaving out the `FP16_OVFL` fix (`v_mul_f16` gives 0xfc00 where the f32 path gives 0xfbff), and leaving out the clamp (`v_add_f16 ... clamp` gives 0x81f4 where the f32 path gives 0). - The f16, packed f16, `fp16_*` and SDWA tests (18) pass on all three devices. - The shader tests (`agc_driver_*`, `agc_shader_*`, `agc_spirv_*`, `vector_*`, `agc_masked_select`, `agc_validate_program`, `agc_denormal*`, `agc_float16_*`; 338 tests). I left out the BDA tests that hang on driver 591.86 until #3291 lands. - RTX 4060: everything passes except `agc_driver_prepared_shaders_registered_workgroup_sync` (added by #2261), which fails the same way on a build without this change. `agc_driver_graphics` failed once during the suite and passes on its own. - Intel UHD: the same, plus `agc_driver_ds_swizzle` and `agc_driver_f32_dot2_rounding` (no `Float64`; it throws instead of skipping), which fail the same way with `main`'s recompiler. - lavapipe 25.2.8: the same, plus the intermittent `agc_driver_depth_fast_clear_submit` segfault that also happens with `main`'s recompiler. - Rebased onto `main` c7601b797, with the skip message reworded (see above): - The f16, packed f16, SDWA, VOPC compare table, interpolation and mix tests and `agc_shader_memory`/`agc_shader_disk_cache` (28) pass on all three devices or are skipped for a missing feature. - `tools/check_skips.py` on lavapipe's ctest JUnit file accepts all three skips, `agc_driver_float16_native` included. The old wording doesn't match its pattern, which is what failed the Linux job. - Shader tests (381): everything passes on the RTX 4060. On the Intel UHD only `agc_driver_ds_swizzle` fails, as with `main`'s recompiler. On lavapipe 25.2.8 there are two segfaults: the intermittent `agc_driver_depth_fast_clear_submit`, and `agc_driver_depth_storage_dispatch` (new on `main`, 738ae9df0), which segfaults 4 of 5 times on its own and has no f16 code. **Limits.** - AMD: @thuanquang ran it on an RX 6700 XT (RDNA2, Adrenalin 26.8.1, Windows 11). The native path is taken, `agc_driver_float16_native` passes 3 of 3, and every non-NaN result is identical; 15,592 NaN results carry another payload. The same four tests fail with and without this change on that machine. - The decoder still rejects `op_sel` on the VOP3 forms of `v_add_f16`, `v_sub_f16`, `v_subrev_f16` and `v_mul_f16`, as before; abs, neg and clamp on them go through the native path. - The f16 fma forms, `v_ldexp_f16` and the f16 transcendentals still compute in f32. `v_min_f16` and `v_max_f16` pick their result on the bits since #3590. ### 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: NVIDIA GeForce RTX 4060 Laptop GPU (Ada), driver 591.86, Windows 11; Intel UHD Graphics (Raptor Lake), driver 101.6790, Windows 11; lavapipe (Mesa 25.2.8), Windows 11 - [x] AI-assisted: yes
MarcZX10 commented 2026-10-11 13:12:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T13:12:18Z.


The PR body says this is stacked on #3531 and that only the last commit is new, but this PR currently targets main, so its review diff includes #3531's entire packed-f16 implementation and test alongside the scalar-f16 changes. #3531 is still open as a separate PR. Could you set this PR's base to perf/shader-native-packed-f16 (or retarget/rebase it after #3531 merges) so the review diff contains only the scalar follow-up? That keeps the dependency explicit and avoids presenting the packed changes twice for review/merge.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109385292 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3557#issuecomment-6109385292). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T13:12:18Z. --- The PR body says this is stacked on #3531 and that only the last commit is new, but this PR currently targets `main`, so its review diff includes #3531's entire packed-f16 implementation and test alongside the scalar-f16 changes. #3531 is still open as a separate PR. Could you set this PR's base to `perf/shader-native-packed-f16` (or retarget/rebase it after #3531 merges) so the review diff contains only the scalar follow-up? That keeps the dependency explicit and avoids presenting the packed changes twice for review/merge.
karanvora2599 commented 2026-10-11 13:55:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by karanvora2599 on 2026-10-11T13:55:20Z.


Thanks. perf/shader-native-packed-f16 only exists in my fork, and a pull request here can only target a branch of this repository, so I can't set it as the base. Until #3531 merges, the scalar change on its own is the last commit, 16485b18. Once #3531 is in, I'll rebase this onto main so the diff here is only that commit. If you'd rather not review it until then, I can mark it as a draft.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109761132 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3557#issuecomment-6109761132). Originally posted by [karanvora2599](https://github.com/karanvora2599) on 2026-10-11T13:55:20Z. --- Thanks. `perf/shader-native-packed-f16` only exists in my fork, and a pull request here can only target a branch of this repository, so I can't set it as the base. Until #3531 merges, the scalar change on its own is the last commit, [16485b18](https://github.com/boykopovar/AnyPS5/pull/3557/commits/16485b1805475cdfbc1e1bbe509fbb6fc976b86d). Once #3531 is in, I'll rebase this onto `main` so the diff here is only that commit. If you'd rather not review it until then, I can mark it as a draft.
MarcZX10 commented 2026-10-11 13:56:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T13:56:56Z.


Thanks for clarifying. Since this repository cannot target your fork branch, please mark #3557 as a draft until #3531 merges, then rebase onto main so the review diff is limited to the scalar follow-up. I’ll review the scalar change once that diff is isolated.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109775170 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3557#issuecomment-6109775170). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T13:56:56Z. --- Thanks for clarifying. Since this repository cannot target your fork branch, please mark #3557 as a draft until #3531 merges, then rebase onto `main` so the review diff is limited to the scalar follow-up. I’ll review the scalar change once that diff is isolated.
jweidenh commented 2026-10-11 16:13:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jweidenh on 2026-10-11T16:13:17Z.


Additional Windows 11 / RTX 5090 correctness validation, with a small fix to the two new test scanners.

The tested integration 0911e71a is pinned main a11c8f7f plus Karan Vora’s existing packed-f16 commit from #3531 (317d23615) and scalar-f16 commit from this PR (16485b180), followed by the two-file scanner fix 14841ce2. The implementation commits retain their original authorship, and range-diff confirms their patches are unchanged. The scanner fix is based directly on this PR’s head and can be picked independently.

Both FindF16x2Math copies read spirv[offset + 1] for every instruction after discovering the f16 vector type. A final one-word OpFunctionEnd therefore reads past the span. The fix checks the opcode and minimum word count before reading operands. In a local harness using the exact scanner bodies, both originals report an ASan heap-buffer-overflow on this terminal-instruction case; both fixed scanners pass 23 boundary, arithmetic-classification and malformed-input cases each with ASan/UBSan. That check used macOS arm64, AppleClang 21, -O0 -fsanitize=address,undefined; it was a scanner harness, not a full-repository sanitizer run.

Windows validation used WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, SPIRV-Tools enabled, NVIDIA driver 617.42, and serial CTest with a 30-second per-test limit. ANYPS5_REQUIRE_VULKAN=1, ANYPS5_GPU=RTX 5090 and ANYPS5_NO_SHADER_CACHE=1 were set; pipeline statistics were disabled. Each GPU test logged the selected NVIDIA GeForce RTX 5090 (vendor=0x10de, device=0x2b85).

Test Result CTest duration
agc_driver_float16_native 327,680 results matched; 0 NaN results with another payload 3.44 s
agc_driver_packed_float16_native 294,912 halves matched bit for bit 2.87 s

Both tests reached their completion markers without capability skips. Their structural checks also passed: native f16 vector add/multiply were emitted, the emulated target contained no such arithmetic, and f16 FMA remained excluded. The existing rounding, denormal, modifiers, overflow, FMA, SDWA, min/max, dot-product, conversion and interpolation checks in the selected scope passed too.

All 24 selected tests passed across the initial run and one isolated retest, with no skips. The initial serial run passed 23 tests in 33.91 seconds; agc_masked_select did not start and CTest reported Process not started, [unknown error], and BAD_COMMAND. An unchanged isolated CTest rerun of agc_masked_select then passed in 0.02 seconds. The initial launch failure is unexplained; no source or test change was made for the retest. Both raw logs are retained. This was 21 GPU tests and three host tests, not the full repository suite.

These results validate the exercised native/emulated math outputs on Blackwell. No title, FPS, throughput or pipeline-compilation improvement was measured. The durations above are correctness-test runtimes.

AI-assisted: Codex prepared the scanner fix, review and validation harnesses; tests ran on the contributor’s machines.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6111010298 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3557#issuecomment-6111010298). Originally posted by [jweidenh](https://github.com/jweidenh) on 2026-10-11T16:13:17Z. --- Additional Windows 11 / RTX 5090 correctness validation, with a small fix to the two new test scanners. The tested [integration `0911e71a`](https://github.com/jweidenh/AnyPS5/commit/0911e71a8766a5bd2f686fa830bffb0c8b5aef80) is pinned main `a11c8f7f` plus Karan Vora’s existing packed-f16 commit from #3531 (`317d23615`) and scalar-f16 commit from this PR (`16485b180`), followed by the [two-file scanner fix `14841ce2`](https://github.com/jweidenh/AnyPS5/commit/14841ce24e60115128c99dd68e40a3a24a806f8d). The implementation commits retain their original authorship, and range-diff confirms their patches are unchanged. The scanner fix is based directly on this PR’s head and can be picked independently. Both `FindF16x2Math` copies read `spirv[offset + 1]` for every instruction after discovering the f16 vector type. A final one-word `OpFunctionEnd` therefore reads past the span. The fix checks the opcode and minimum word count before reading operands. In a local harness using the exact scanner bodies, both originals report an ASan heap-buffer-overflow on this terminal-instruction case; both fixed scanners pass 23 boundary, arithmetic-classification and malformed-input cases each with ASan/UBSan. That check used macOS arm64, AppleClang 21, `-O0 -fsanitize=address,undefined`; it was a scanner harness, not a full-repository sanitizer run. Windows validation used WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, SPIRV-Tools enabled, NVIDIA driver 617.42, and serial CTest with a 30-second per-test limit. `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_GPU=RTX 5090` and `ANYPS5_NO_SHADER_CACHE=1` were set; pipeline statistics were disabled. Each GPU test logged the selected NVIDIA GeForce RTX 5090 (`vendor=0x10de`, `device=0x2b85`). | Test | Result | CTest duration | | --- | --- | ---: | | `agc_driver_float16_native` | 327,680 results matched; 0 NaN results with another payload | 3.44 s | | `agc_driver_packed_float16_native` | 294,912 halves matched bit for bit | 2.87 s | Both tests reached their completion markers without capability skips. Their structural checks also passed: native f16 vector add/multiply were emitted, the emulated target contained no such arithmetic, and f16 FMA remained excluded. The existing rounding, denormal, modifiers, overflow, FMA, SDWA, min/max, dot-product, conversion and interpolation checks in the selected scope passed too. **All 24 selected tests passed across the initial run and one isolated retest, with no skips.** The initial serial run passed 23 tests in 33.91 seconds; `agc_masked_select` did not start and CTest reported `Process not started`, `[unknown error]`, and `BAD_COMMAND`. An unchanged isolated CTest rerun of `agc_masked_select` then passed in 0.02 seconds. The initial launch failure is unexplained; no source or test change was made for the retest. Both raw logs are retained. This was 21 GPU tests and three host tests, not the full repository suite. These results validate the exercised native/emulated math outputs on Blackwell. No title, FPS, throughput or pipeline-compilation improvement was measured. The durations above are correctness-test runtimes. AI-assisted: Codex prepared the scanner fix, review and validation harnesses; tests ran on the contributor’s machines.
karanvora2599 commented 2026-10-11 16:44:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by karanvora2599 on 2026-10-11T16:44:24Z.


@MarcZX100 marked as draft. I'll rebase it onto main once #3531 merges, so the diff is only the scalar change.

@jweidenh thanks for the RTX 5090 run, and for catching the scanner reading past the last instruction. I took your fix as is, split between the two PRs with you as the author: the Float16Native.cpp half is 6b67a8e6 here and the PackedFloat16Native.cpp half is f139b34b in #3531. With both, the two tests still pass on an RTX 4060 (327,680 results and 294,912 halves) and an Intel UHD.

On performance: the descriptions give instruction counts, so here are runtimes as well. RTX 4060 Laptop, driver 591.86, one build. Each instruction is compiled once for the device and once for the same target without Float16, which is the f32 path main takes. Dependent chains of 2048 instructions over 16384 groups of 32 threads, FLOAT_MODE 0xc0, median of 15 interleaved dispatches:

Chain f32 path (main) native
v_add_f16 16.6 ms 0.94 ms 17.7×
v_mul_f16 15.4 ms 0.75 ms 20.6×
v_pk_add_f16 (#3531) 34.6 ms 11.2 ms 3.1×
v_pk_mul_f16 (#3531) 33.3 ms 11.3 ms 2.9×
v_fma_f32 (reference) 6.7 ms

These are isolated chains. How much a title gains depends on how much of its GPU time goes to f16 arithmetic, and I have no title here to measure.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6111303331 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3557#issuecomment-6111303331). Originally posted by [karanvora2599](https://github.com/karanvora2599) on 2026-10-11T16:44:24Z. --- @MarcZX100 marked as draft. I'll rebase it onto `main` once #3531 merges, so the diff is only the scalar change. @jweidenh thanks for the RTX 5090 run, and for catching the scanner reading past the last instruction. I took your fix as is, split between the two PRs with you as the author: the `Float16Native.cpp` half is 6b67a8e6 here and the `PackedFloat16Native.cpp` half is f139b34b in #3531. With both, the two tests still pass on an RTX 4060 (327,680 results and 294,912 halves) and an Intel UHD. On performance: the descriptions give instruction counts, so here are runtimes as well. RTX 4060 Laptop, driver 591.86, one build. Each instruction is compiled once for the device and once for the same target without `Float16`, which is the f32 path `main` takes. Dependent chains of 2048 instructions over 16384 groups of 32 threads, `FLOAT_MODE` 0xc0, median of 15 interleaved dispatches: | Chain | f32 path (`main`) | native | | |---|---|---|---| | `v_add_f16` | 16.6 ms | 0.94 ms | 17.7× | | `v_mul_f16` | 15.4 ms | 0.75 ms | 20.6× | | `v_pk_add_f16` (#3531) | 34.6 ms | 11.2 ms | 3.1× | | `v_pk_mul_f16` (#3531) | 33.3 ms | 11.3 ms | 2.9× | | `v_fma_f32` (reference) | 6.7 ms | | | These are isolated chains. How much a title gains depends on how much of its GPU time goes to f16 arithmetic, and I have no title here to measure.
karanvora2599 commented 2026-10-11 23:50:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by karanvora2599 on 2026-10-11T23:50:08Z.


@MarcZX100 rebased onto main now that #3531 has merged, so the diff is only the scalar change (plus @jweidenh's scanner fix for its test), and it's out of draft. Retested on the RTX 4060, the Intel UHD and lavapipe; the results are in the description.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6115282321 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3557#issuecomment-6115282321). Originally posted by [karanvora2599](https://github.com/karanvora2599) on 2026-10-11T23:50:08Z. --- @MarcZX100 rebased onto `main` now that #3531 has merged, so the diff is only the scalar change (plus @jweidenh's scanner fix for its test), and it's out of draft. Retested on the RTX 4060, the Intel UHD and lavapipe; the results are in the description.
oneandonlydean commented 2026-10-13 05:02:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T05:02:27Z.


The full build fails on Linux: agc_driver_float16_native skips on llvmpipe and the skip check stops on it (error: agc_driver_float16_native skipped). Please add it to the expected skips in tools/check_skips.py with its reason, or make it run there. Windows passed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6138625903 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3557#issuecomment-6138625903). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-13T05:02:27Z. --- The full build fails on Linux: `agc_driver_float16_native` skips on llvmpipe and the skip check stops on it (`error: agc_driver_float16_native skipped`). Please add it to the expected skips in `tools/check_skips.py` with its reason, or make it run there. Windows passed.
karanvora2599 commented 2026-10-13 21:55:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by karanvora2599 on 2026-10-13T21:55:06Z.


Thanks @oneandonlydean. The skip itself is expected: lavapipe has no native f16 with RTE rounding and kept denormals. The check rejects it because of how the message is worded. check_skips.py accepts skipped, ... the device has no ..., but Float16Native prints the device has no ..., skipped. main already reworded PackedFloat16Native this way, so I'll reword Float16Native the same and rebase.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6156017886 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3557#issuecomment-6156017886). Originally posted by [karanvora2599](https://github.com/karanvora2599) on 2026-10-13T21:55:06Z. --- Thanks @oneandonlydean. The skip itself is expected: lavapipe has no native f16 with RTE rounding and kept denormals. The check rejects it because of how the message is worded. `check_skips.py` accepts `skipped, ... the device has no ...`, but `Float16Native` prints `the device has no ..., skipped`. `main` already reworded `PackedFloat16Native` this way, so I'll reword `Float16Native` the same and rebase.
thuanquang commented 2026-10-14 16:36:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-14T16:36:10Z.


An AMD run, since the description has none: the native path is taken on RDNA2 and its results match.

Setup: AMD Radeon RX 6700 XT (gfx1031, 0x73df, subgroup 64), Adrenalin 26.8.1 (driver 32.0.21045.5002), Windows 11 26200, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, ANYPS5_REQUIRE_VULKAN=1. Head 7237ec215 merged into main e34c47921.

  • agc_driver_float16_native is not skipped, so the driver reports native f16 with RTE and kept denormals, and it passes 3/3: f16 native tests passed (327680 results, 15592 NaN results with another payload). Every non-NaN result is identical; 15,592 NaN results carry another payload, against none on the RTX 4060 and 604 on the Intel UHD in the description.
  • Full suite in the same build directory, ctest --parallel 4 --timeout 120: main 1198 tests, this PR 1199. The same four fail on both: agc_driver_pixel_interlock, agc_driver_layered_volume_vertex_no_gpl and agc_driver_lds_mixed_width_atomics, which fail on AMD Windows (#5271), and guest_sce_net, which times out on this machine's slow host DNS lookups.

Not tested: speed on AMD, and any title.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6173287163 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3557#issuecomment-6173287163). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-14T16:36:10Z. --- An AMD run, since the description has none: the native path is taken on RDNA2 and its results match. Setup: AMD Radeon RX 6700 XT (gfx1031, `0x73df`, subgroup 64), Adrenalin 26.8.1 (driver 32.0.21045.5002), Windows 11 26200, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, `ANYPS5_REQUIRE_VULKAN=1`. Head `7237ec215` merged into `main` `e34c47921`. - `agc_driver_float16_native` is not skipped, so the driver reports native f16 with RTE and kept denormals, and it passes 3/3: `f16 native tests passed (327680 results, 15592 NaN results with another payload)`. Every non-NaN result is identical; 15,592 NaN results carry another payload, against none on the RTX 4060 and 604 on the Intel UHD in the description. - Full suite in the same build directory, `ctest --parallel 4 --timeout 120`: `main` 1198 tests, this PR 1199. The same four fail on both: `agc_driver_pixel_interlock`, `agc_driver_layered_volume_vertex_no_gpl` and `agc_driver_lds_mixed_width_atomics`, which fail on AMD Windows (#5271), and `guest_sce_net`, which times out on this machine's slow host DNS lookups. Not tested: speed on AMD, and any title. AI-assisted: yes (Claude Code).
karanvora2599 commented 2026-10-15 02:08:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by karanvora2599 on 2026-10-15T02:08:12Z.


@oneandonlydean, fixed in 05a2999a2. Float16Native now prints f16 native: skipped, the device has no native f16 with RTE rounding and kept denormals, the wording PackedFloat16Native uses and tools/check_skips.py accepts. The branch is rebased onto main c7601b797, and the description has the rerun on the RTX 4060, Intel UHD and lavapipe.

@thuanquang, thanks for the RX 6700 XT run. I've added it to the description.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6182772313 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3557#issuecomment-6182772313). Originally posted by [karanvora2599](https://github.com/karanvora2599) on 2026-10-15T02:08:12Z. --- @oneandonlydean, fixed in 05a2999a2. `Float16Native` now prints `f16 native: skipped, the device has no native f16 with RTE rounding and kept denormals`, the wording `PackedFloat16Native` uses and `tools/check_skips.py` accepts. The branch is rebased onto `main` c7601b797, and the description has the rerun on the RTX 4060, Intel UHD and lavapipe. @thuanquang, thanks for the RX 6700 XT run. I've added it to the description.
github-actions[bot] commented 2026-10-15 12:05:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:05:49Z.


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
core/shader/recompiler/Translation/src/FloatInstructions.cpp
PR 5021 core/shader/recompiler/Translation/src/FloatInstructions.cpp
PR 6503 core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191634781 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3557#issuecomment-6191634781). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:05:49Z. --- <!-- 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`<br>`core/shader/recompiler/Translation/src/FloatInstructions.cpp` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/shader/recompiler/Translation/src/FloatInstructions.cpp` | | [PR 6503](https://www.github.com/boykopovar/AnyPS5/pull/6503) | `core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp` |
odntht commented 2026-10-16 19:59:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by odntht on 2026-10-16T19:59:51Z.


A Gen9 Linux run, since the Intel data is Raptor Lake on Windows.

Setup: Intel HD Graphics 520 (Skylake GT2, Gen9), Mesa 25.2.8 ANV, Ubuntu 24.04 (container), kernel 6.12.111, GCC 13.3, Release. Head 05a2999a2 merged onto main f474fb776 (clean). ANYPS5_GPU="HD Graphics 520"; the log shows it selected.

  • agc_driver_float16_native takes the native path and passes 3 of 3: 327680 results, 246 NaN results with another payload. All non-NaN results are identical. The NaN count is the same in every run (604 on the Raptor Lake UHD in the description).
  • The other 10 float16 tests (agc_float16_conversion, agc_driver_float16_*, agc_driver_packed_float16_native) pass 3 of 3.

AI-assisted: yes (Claude Code). The runs are on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6223615886 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3557#issuecomment-6223615886). Originally posted by [odntht](https://github.com/odntht) on 2026-10-16T19:59:51Z. --- A Gen9 Linux run, since the Intel data is Raptor Lake on Windows. Setup: Intel HD Graphics 520 (Skylake GT2, Gen9), Mesa 25.2.8 ANV, Ubuntu 24.04 (container), kernel 6.12.111, GCC 13.3, Release. Head `05a2999a2` merged onto `main` `f474fb776` (clean). `ANYPS5_GPU="HD Graphics 520"`; the log shows it selected. - `agc_driver_float16_native` takes the native path and passes 3 of 3: `327680 results, 246 NaN results with another payload`. All non-NaN results are identical. The NaN count is the same in every run (604 on the Raptor Lake UHD in the description). - The other 10 `float16` tests (`agc_float16_conversion`, `agc_driver_float16_*`, `agc_driver_packed_float16_native`) pass 3 of 3. AI-assisted: yes (Claude Code). The runs are on my machine.
oneandonlydean commented 2026-10-17 00:41:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T00:41:23Z.


The Gen9 run (@odntht, HD 520, ANV, 3/3) and the RDNA2 run (@thuanquang, RX 6700 XT, 3/3) fill the gaps the description had: the native path is taken and matches on Gen9, RDNA2, Raptor Lake and the RTX 4060. The reworded skip message in 05a2999a2 uses the same wording as PackedFloat16Native, which is what tools/check_skips.py accepts, so the 10-13 point should be gone; the full build on this head will confirm it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6227470922 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3557#issuecomment-6227470922). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T00:41:23Z. --- The Gen9 run (@odntht, HD 520, ANV, 3/3) and the RDNA2 run (@thuanquang, RX 6700 XT, 3/3) fill the gaps the description had: the native path is taken and matches on Gen9, RDNA2, Raptor Lake and the RTX 4060. The reworded skip message in `05a2999a2` uses the same wording as `PackedFloat16Native`, which is what `tools/check_skips.py` accepts, so the 10-13 point should be gone; the full build on this head will confirm it.
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!3557
No description provided.