fix(shader): apply v_dot2_f32_f16's accumulator modifiers as RDNA 2 does #8886

Merged
thuanquang merged 1 commit from upstream-pr/8886 into main 2026-10-25 22:06:41 +00:00
thuanquang commented 2026-10-21 04:40:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-21T04:40:38Z.


What

v_dot2_f32_f16 was refused whenever its accumulator (src2) had op_sel set, neg_hi set or op_sel_hi clear: VOP3P v_dot2_f32_f16 accumulator op_sel, op_sel_hi and neg_hi are not implemented. A shader compiler may well leave op_sel_hi[2] at 0 for an f32 operand.

Measured on RDNA 2, the f32 accumulator behaves like a v_fma_mix f32 operand:

  • op_sel[2] and op_sel_hi[2] are ignored;
  • neg_lo[2] negates the accumulator;
  • neg_hi[2] takes its absolute value, so with both bits set the accumulator is -|c|.

The decoder now normalizes the accumulator's selects and turns neg_hi[2] into absolute. The accumulator read already applies absolute and then negate.

Source of the semantics: an RX 6700 XT (gfx1031) running raw ISA through the HIP runtime of AMD's Windows driver 32.0.21045.5002, on 64 random rows and on the 32 rows of Float16Dot.cpp. On those 32 rows, the default encoding reproduces that test's existing measured v_dot2 column exactly. Scripts and data: https://gist.github.com/thuanquang/cc3c7c9b1d198561ea25474766998ec9

Float16Dot.cpp's three refusal checks become a second program that runs five accumulator variants (op_sel, op_sel_hi cleared, neg_hi, neg_lo, neg_lo with neg_hi) and checks them against the values measured on the same rows.

Tested

Windows 11 26200, RX 6700 XT (gfx1031), AMD driver 32.0.21045.5002, MinGW GCC 15.2.0 Release, main 7d7b09740, ANYPS5_REQUIRE_VULKAN=1:

  • agc_driver_float16_dot: with this change it passes 3 of 3. With only the decoder change reverted, the new test fails with the old refusal.
  • --repeat until-fail:3 on 8 tests: agc_driver_float16_dot, agc_driver_f32_dot2_rounding, agc_driver_fma_mix_f16_denormal_modes, agc_driver_integer_dot, agc_driver_mix_precision, agc_driver_packed_alu, agc_driver_packed_f16_denormal_modes and agc_driver_vop3_pack_ldexp. All 8 pass with this change.
  • Khronos validation layer, ctest -V on the same 8: 8 of 8 on main and with this change, with 0 VUID- lines on either side. The layer was inserted in every test process.

Other GPUs, from reviewers:

  • @MaxLikesCode ran this head merged onto main cecb540a6 on an NVIDIA RTX 4090 (617.42, Windows 11 Pro 26200): the same 8 tests pass 8 of 8 on main and with this change, in 3 runs without and 3 with the Khronos validation layer, with no VUID- line on either side; agc_driver_float16_dot reports the new accumulator cases.

Not tested:

  • the console (gfx1013) and other RDNA generations;
  • FLOAT_MODE variants beyond the test's default;
  • any title.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 6700 XT (gfx1031), AMD Windows driver 32.0.21045.5002, Windows 11 26200; by a reviewer: NVIDIA GeForce RTX 4090, driver 617.42, Windows 11 Pro 26200 (@MaxLikesCode)
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4946492398 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8886). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-21T04:40:38Z. --- ### What `v_dot2_f32_f16` was refused whenever its accumulator (src2) had op_sel set, neg_hi set or op_sel_hi clear: `VOP3P v_dot2_f32_f16 accumulator op_sel, op_sel_hi and neg_hi are not implemented`. A shader compiler may well leave op_sel_hi[2] at 0 for an f32 operand. Measured on RDNA 2, the f32 accumulator behaves like a v_fma_mix f32 operand: - op_sel[2] and op_sel_hi[2] are ignored; - neg_lo[2] negates the accumulator; - neg_hi[2] takes its absolute value, so with both bits set the accumulator is -|c|. The decoder now normalizes the accumulator's selects and turns neg_hi[2] into `absolute`. The accumulator read already applies `absolute` and then `negate`. Source of the semantics: an RX 6700 XT (gfx1031) running raw ISA through the HIP runtime of AMD's Windows driver 32.0.21045.5002, on 64 random rows and on the 32 rows of `Float16Dot.cpp`. On those 32 rows, the default encoding reproduces that test's existing measured `v_dot2` column exactly. Scripts and data: https://gist.github.com/thuanquang/cc3c7c9b1d198561ea25474766998ec9 `Float16Dot.cpp`'s three refusal checks become a second program that runs five accumulator variants (op_sel, op_sel_hi cleared, neg_hi, neg_lo, neg_lo with neg_hi) and checks them against the values measured on the same rows. ### Tested Windows 11 26200, RX 6700 XT (gfx1031), AMD driver 32.0.21045.5002, MinGW GCC 15.2.0 Release, `main` `7d7b09740`, `ANYPS5_REQUIRE_VULKAN=1`: - `agc_driver_float16_dot`: with this change it passes 3 of 3. With only the decoder change reverted, the new test fails with the old refusal. - `--repeat until-fail:3` on 8 tests: `agc_driver_float16_dot`, `agc_driver_f32_dot2_rounding`, `agc_driver_fma_mix_f16_denormal_modes`, `agc_driver_integer_dot`, `agc_driver_mix_precision`, `agc_driver_packed_alu`, `agc_driver_packed_f16_denormal_modes` and `agc_driver_vop3_pack_ldexp`. All 8 pass with this change. - Khronos validation layer, `ctest -V` on the same 8: 8 of 8 on `main` and with this change, with 0 `VUID-` lines on either side. The layer was inserted in every test process. **Other GPUs, from reviewers:** - @MaxLikesCode [ran this head](https://github.com/boykopovar/AnyPS5/pull/8886#issuecomment-6321174375) merged onto `main` `cecb540a6` on an NVIDIA RTX 4090 (617.42, Windows 11 Pro 26200): the same 8 tests pass 8 of 8 on `main` and with this change, in 3 runs without and 3 with the Khronos validation layer, with no `VUID-` line on either side; `agc_driver_float16_dot` reports the new accumulator cases. Not tested: - the console (gfx1013) and other RDNA generations; - FLOAT_MODE variants beyond the test's default; - any title. ### 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) - [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 6700 XT (gfx1031), AMD Windows driver 32.0.21045.5002, Windows 11 26200; by a reviewer: NVIDIA GeForce RTX 4090, driver 617.42, Windows 11 Pro 26200 (@MaxLikesCode) - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
thuanquang commented 2026-10-21 06:20:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-21T06:20:56Z.


A Linux run, since this PR's runtime CI jobs were skipped. It uses lavapipe from Mesa 25.2.8 with LLVM 20.1.2, the same driver as Linux CI, on Ubuntu 24.04 (WSL) with GCC 13.3, Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON and ANYPS5_REQUIRE_VULKAN=1.

This PR's commit was applied onto a main d0852defa build, which also carries #8055's float-atomic files that this test doesn't reach. agc_driver_float16_dot passes 3 of 3, including the five accumulator variants checked against the RX 6700 XT's measured values.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6309505783 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8886#issuecomment-6309505783). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-21T06:20:56Z. --- A Linux run, since this PR's runtime CI jobs were skipped. It uses lavapipe from Mesa 25.2.8 with LLVM 20.1.2, the same driver as Linux CI, on Ubuntu 24.04 (WSL) with GCC 13.3, Release, `-DANYPS5_ENABLE_SPIRV_TOOLS=ON` and `ANYPS5_REQUIRE_VULKAN=1`. This PR's commit was applied onto a `main` `d0852defa` build, which also carries #8055's float-atomic files that this test doesn't reach. `agc_driver_float16_dot` passes 3 of 3, including the five accumulator variants checked against the RX 6700 XT's measured values.
MaxLikesCode commented 2026-10-21 16:35:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MaxLikesCode on 2026-10-21T16:35:23Z.


RTX 4090 (Ada) on Windows, head 994f69db4 merged onto main cecb540a6 (clean), the 8 tests from the Tested section (agc_driver_float16_dot, agc_driver_f32_dot2_rounding, agc_driver_fma_mix_f16_denormal_modes, agc_driver_integer_dot, agc_driver_mix_precision, agc_driver_packed_alu, agc_driver_packed_f16_denormal_modes, agc_driver_vop3_pack_ldexp):

  • main: 8 of 8 in 3 runs without and 3 with the validation layer.
  • this PR: 8 of 8 in the same 6 runs; agc_driver_float16_dot reports v_dot2_f32_f16 tests passed with the new accumulator cases.
  • No run on either side logs a VUID-.

NVIDIA GeForce RTX 4090, driver 617.42, Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, ctest --test-dir build -R <tests> -V. Validation runs add VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Vulkan-ValidationLayers vulkan-sdk-1.4.363.0, implicit layers disabled); the loader log shows the layer inserted in every Vulkan test process, and no log has was not found but was requested by env var VK_INSTANCE_LAYERS.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6321174375 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8886#issuecomment-6321174375). Originally posted by [MaxLikesCode](https://github.com/MaxLikesCode) on 2026-10-21T16:35:23Z. --- RTX 4090 (Ada) on Windows, head `994f69db4` merged onto `main` `cecb540a6` (clean), the 8 tests from the Tested section (`agc_driver_float16_dot`, `agc_driver_f32_dot2_rounding`, `agc_driver_fma_mix_f16_denormal_modes`, `agc_driver_integer_dot`, `agc_driver_mix_precision`, `agc_driver_packed_alu`, `agc_driver_packed_f16_denormal_modes`, `agc_driver_vop3_pack_ldexp`): - `main`: 8 of 8 in 3 runs without and 3 with the validation layer. - this PR: 8 of 8 in the same 6 runs; `agc_driver_float16_dot` reports `v_dot2_f32_f16 tests passed` with the new accumulator cases. - No run on either side logs a `VUID-`. NVIDIA GeForce RTX 4090, driver 617.42, Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `ctest --test-dir build -R <tests> -V`. Validation runs add `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (Vulkan-ValidationLayers `vulkan-sdk-1.4.363.0`, implicit layers disabled); the loader log shows the layer inserted in every Vulkan test process, and no log has `was not found but was requested by env var VK_INSTANCE_LAYERS`. AI-assisted: yes (Claude Code)
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!8886
No description provided.