perf(shader): convert one f16 value instead of an (x, 0.0) pair #7698

Merged
tibzejoker merged 1 commit from upstream-pr/7698 into main 2026-10-19 04:52:01 +00:00
tibzejoker commented 2026-10-19 01:07:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-19T01:07:12Z.


What

ConvertF16F32 built an (x, 0.0) f32 pair and packed it. Unary f16 results (v_rcp_f16, v_sqrt_f16, ...) were also packed with a 0.0 high half. In both cases the constant half went through the whole f32-to-f16 conversion every time; without native f16 support, that is a bit-level rounding sequence of about twenty instructions. Both now convert only the one value. The high half of the bits is zero as before, so results do not change.

Tested

Windows 11, MinGW GCC 15.2:

  • New test agc_f16_single_convert. It recompiles four v_rcp_f16, once with and once without native f16 capabilities, and requires that no (x, 0.0) f32 pair is emitted. On main, each case emits four.
  • ctest -R ^agc_ on the RTX 4090: 727/728. The failure is agc_driver_bda_device, which fails on main too.
  • GTA V (PPSA04264) compute shaders dumped with APS5_DUMP_SHADERS were dispatched on synthetic guest memory with main and with this change, and every byte they wrote was compared:
RTX 4090 (616.92) UHD 770 (32.0.101.6129)
shaders with identical output 72/72 71/71
SPIR-V words, all of them 1,930,912 -> 1,855,984 (-3.9 %) 1,282,859 -> 1,272,641 (-0.8 %)
compute 0x25b393000 (FSR1 RCAS) 116,571 -> 106,539 116,567 -> 106,535

This change makes modules smaller; its effect is on pipeline creation time, not on the steady-state frame. A warm-cache trace of this title cannot separate it from scene variance (see #7673 for the attempt).

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: NVIDIA GeForce RTX 4090 (616.92, Windows 11); Intel UHD Graphics 770 (32.0.101.6129, Windows 11)
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

https://claude.ai/code/session_01XBXM4pgkMHYEtqN1EQni2P

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4914401305 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7698). Originally posted by [tibzejoker](https://github.com/tibzejoker) on 2026-10-19T01:07:12Z. --- ### What `ConvertF16F32` built an `(x, 0.0)` f32 pair and packed it. Unary f16 results (`v_rcp_f16`, `v_sqrt_f16`, ...) were also packed with a `0.0` high half. In both cases the constant half went through the whole f32-to-f16 conversion every time; without native f16 support, that is a bit-level rounding sequence of about twenty instructions. Both now convert only the one value. The high half of the bits is zero as before, so results do not change. ### Tested Windows 11, MinGW GCC 15.2: - New test `agc_f16_single_convert`. It recompiles four `v_rcp_f16`, once with and once without native f16 capabilities, and requires that no `(x, 0.0)` f32 pair is emitted. On `main`, each case emits four. - `ctest -R ^agc_` on the RTX 4090: 727/728. The failure is `agc_driver_bda_device`, which fails on `main` too. - GTA V (PPSA04264) compute shaders dumped with `APS5_DUMP_SHADERS` were dispatched on synthetic guest memory with `main` and with this change, and every byte they wrote was compared: | | RTX 4090 (616.92) | UHD 770 (32.0.101.6129) | |---|---|---| | shaders with identical output | 72/72 | 71/71 | | SPIR-V words, all of them | 1,930,912 -> 1,855,984 (-3.9 %) | 1,282,859 -> 1,272,641 (-0.8 %) | | compute 0x25b393000 (FSR1 RCAS) | 116,571 -> 106,539 | 116,567 -> 106,535 | This change makes modules smaller; its effect is on pipeline creation time, not on the steady-state frame. A warm-cache trace of this title cannot separate it from scene variance (see #7673 for the attempt). ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical 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: NVIDIA GeForce RTX 4090 (616.92, Windows 11); Intel UHD Graphics 770 (32.0.101.6129, Windows 11) - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01XBXM4pgkMHYEtqN1EQni2P
github-actions[bot] commented 2026-10-19 01:07:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T01:07:24Z.


This pull request is labeled perf, so it needs the summary line of a capture on main and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both aps5-summary.jsonl lines, attach the two traces and add the output of tools/trace_digest.py.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6257488147 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7698#issuecomment-6257488147). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T01:07:24Z. --- <!-- pr-labels-perf --> This pull request is labeled `perf`, so it needs the summary line of a capture on `main` and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both `aps5-summary.jsonl` lines, attach the two traces and add the output of `tools/trace_digest.py`.
github-actions[bot] commented 2026-10-19 01:27:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T01:27:36Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6611 core/libs/prx/libSceAgcDriver/CMakeLists.txt L1891
PR 7489 core/libs/prx/libSceAgcDriver/CMakeLists.txt L1891

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 1341 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 1368 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 1395 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 2434 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 4072 core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
core/shader/recompiler/Translation/src/FloatInstructions.cpp
PR 4891 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5021 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
core/shader/recompiler/Translation/src/FloatInstructions.cpp
PR 5371 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5426 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5431 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5480 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5499 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5656 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5925 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6044 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6185 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6186 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6188 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6192 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6249 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6280 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6300 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6360 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6412 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6481 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6501 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6503 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6535 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6645 core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
PR 6683 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6701 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6718 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6747 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6759 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6763 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6788 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6808 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6820 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6868 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6937 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6941 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6946 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6947 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6963 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6989 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6995 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7002 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7048 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7085 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7201 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7223 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7310 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7332 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
core/shader/recompiler/Translation/src/FloatInstructions.cpp
PR 7395 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7427 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7505 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7514 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7604 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7642 core/libs/prx/libSceAgcDriver/CMakeLists.txt
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6257705518 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7698#issuecomment-6257705518). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T01:27:36Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 6611](https://www.github.com/boykopovar/AnyPS5/pull/6611) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` [L1891](https://github.com/boykopovar/AnyPS5/blob/676d423968a1a8fcc79c6247020ce22090a8e0d4/core/libs/prx/libSceAgcDriver/CMakeLists.txt#L1891) | | | | [PR 7489](https://www.github.com/boykopovar/AnyPS5/pull/7489) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` [L1891](https://github.com/boykopovar/AnyPS5/blob/676d423968a1a8fcc79c6247020ce22090a8e0d4/core/libs/prx/libSceAgcDriver/CMakeLists.txt#L1891) | | | 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 1341](https://www.github.com/boykopovar/AnyPS5/pull/1341) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 1368](https://www.github.com/boykopovar/AnyPS5/pull/1368) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 1395](https://www.github.com/boykopovar/AnyPS5/pull/1395) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 2434](https://www.github.com/boykopovar/AnyPS5/pull/2434) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 4072](https://www.github.com/boykopovar/AnyPS5/pull/4072) | `core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp`<br>`core/shader/recompiler/Translation/src/FloatInstructions.cpp` | | [PR 4891](https://www.github.com/boykopovar/AnyPS5/pull/4891) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp`<br>`core/shader/recompiler/Translation/src/FloatInstructions.cpp` | | [PR 5371](https://www.github.com/boykopovar/AnyPS5/pull/5371) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5426](https://www.github.com/boykopovar/AnyPS5/pull/5426) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5431](https://www.github.com/boykopovar/AnyPS5/pull/5431) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5480](https://www.github.com/boykopovar/AnyPS5/pull/5480) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5499](https://www.github.com/boykopovar/AnyPS5/pull/5499) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5656](https://www.github.com/boykopovar/AnyPS5/pull/5656) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5925](https://www.github.com/boykopovar/AnyPS5/pull/5925) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6185](https://www.github.com/boykopovar/AnyPS5/pull/6185) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6186](https://www.github.com/boykopovar/AnyPS5/pull/6186) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6188](https://www.github.com/boykopovar/AnyPS5/pull/6188) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6192](https://www.github.com/boykopovar/AnyPS5/pull/6192) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6249](https://www.github.com/boykopovar/AnyPS5/pull/6249) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6280](https://www.github.com/boykopovar/AnyPS5/pull/6280) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6300](https://www.github.com/boykopovar/AnyPS5/pull/6300) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6360](https://www.github.com/boykopovar/AnyPS5/pull/6360) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6412](https://www.github.com/boykopovar/AnyPS5/pull/6412) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6481](https://www.github.com/boykopovar/AnyPS5/pull/6481) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6501](https://www.github.com/boykopovar/AnyPS5/pull/6501) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6503](https://www.github.com/boykopovar/AnyPS5/pull/6503) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6535](https://www.github.com/boykopovar/AnyPS5/pull/6535) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6645](https://www.github.com/boykopovar/AnyPS5/pull/6645) | `core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp` | | [PR 6683](https://www.github.com/boykopovar/AnyPS5/pull/6683) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6701](https://www.github.com/boykopovar/AnyPS5/pull/6701) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6718](https://www.github.com/boykopovar/AnyPS5/pull/6718) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6747](https://www.github.com/boykopovar/AnyPS5/pull/6747) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6759](https://www.github.com/boykopovar/AnyPS5/pull/6759) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6763](https://www.github.com/boykopovar/AnyPS5/pull/6763) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6788](https://www.github.com/boykopovar/AnyPS5/pull/6788) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6808](https://www.github.com/boykopovar/AnyPS5/pull/6808) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6820](https://www.github.com/boykopovar/AnyPS5/pull/6820) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6868](https://www.github.com/boykopovar/AnyPS5/pull/6868) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6937](https://www.github.com/boykopovar/AnyPS5/pull/6937) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6941](https://www.github.com/boykopovar/AnyPS5/pull/6941) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6946](https://www.github.com/boykopovar/AnyPS5/pull/6946) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6947](https://www.github.com/boykopovar/AnyPS5/pull/6947) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6963](https://www.github.com/boykopovar/AnyPS5/pull/6963) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6989](https://www.github.com/boykopovar/AnyPS5/pull/6989) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6995](https://www.github.com/boykopovar/AnyPS5/pull/6995) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7002](https://www.github.com/boykopovar/AnyPS5/pull/7002) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7048](https://www.github.com/boykopovar/AnyPS5/pull/7048) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7085](https://www.github.com/boykopovar/AnyPS5/pull/7085) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7223](https://www.github.com/boykopovar/AnyPS5/pull/7223) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7310](https://www.github.com/boykopovar/AnyPS5/pull/7310) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp`<br>`core/shader/recompiler/Translation/src/FloatInstructions.cpp` | | [PR 7395](https://www.github.com/boykopovar/AnyPS5/pull/7395) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7427](https://www.github.com/boykopovar/AnyPS5/pull/7427) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7505](https://www.github.com/boykopovar/AnyPS5/pull/7505) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7514](https://www.github.com/boykopovar/AnyPS5/pull/7514) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7604](https://www.github.com/boykopovar/AnyPS5/pull/7604) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 7642](https://www.github.com/boykopovar/AnyPS5/pull/7642) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` |
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!7698
No description provided.