perf(shader): reuse packed f16 operand lanes #5811

Merged
MarcZX10 merged 1 commit from upstream-pr/5811 into main 2026-10-14 14:16:16 +00:00
MarcZX10 commented 2026-10-14 11:55:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T11:55:52Z.


What

packedFloat16 emits the packed f16 operand selection and lane extraction once to form a native f16x2 add/multiply. When it emits the exact NaN/overflow repair path, it recomputes the same selected low/high halves for those operands. Cache each half lazily during the translation and reuse it for the result and repair logic. This avoids duplicate IR for extraction, OP_SEL, absolute value, and negate handling. The instruction result and existing repair rules are unchanged.

This is the smaller follow-up suggested in the review of closed #5057 after the guarded repair path showed no Palworld gain and grew the SPIR-V module. It makes no title-level performance claim. It depends on #4072, which changes the same packed-f16 translation function.

Tested

  • The changed translation unit compiled with the repository's Release C++20 compiler flags (GCC 12.2).
  • git diff --check passed.
  • Focused execution tests were not run: the available stale CMake build expanded the test target into a broad rebuild of unrelated dependencies, so I stopped it before running out-of-scope work.

Checklist

  • Based on current main; no other open PR implements this reuse
  • 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: #4072
  • Unblocks: none
  • GPUs tested: none; this is an IR reuse change
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4857477340 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5811). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-14T11:55:52Z. --- ### What `packedFloat16` emits the packed f16 operand selection and lane extraction once to form a native f16x2 add/multiply. When it emits the exact NaN/overflow repair path, it recomputes the same selected low/high halves for those operands. Cache each half lazily during the translation and reuse it for the result and repair logic. This avoids duplicate IR for extraction, `OP_SEL`, absolute value, and negate handling. The instruction result and existing repair rules are unchanged. This is the smaller follow-up suggested in the review of closed #5057 after the guarded repair path showed no Palworld gain and grew the SPIR-V module. It makes no title-level performance claim. It depends on #4072, which changes the same packed-f16 translation function. ### Tested - The changed translation unit compiled with the repository's Release C++20 compiler flags (GCC 12.2). - `git diff --check` passed. - Focused execution tests were not run: the available stale CMake build expanded the test target into a broad rebuild of unrelated dependencies, so I stopped it before running out-of-scope work. ### Checklist - [x] Based on current `main`; no other open PR implements this reuse - [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: #4072 - [x] Unblocks: none - [x] GPUs tested: none; this is an IR reuse change - [x] AI-assisted: yes
adriadam10 commented 2026-10-14 13:39:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T13:39:10Z.


Checked the diff: sourceLaneBits only memoizes laneBits per (source, half) within one packedFloat16 call. The emitted operations and bit rules are unchanged, and straight-line IR means the cached value dominates every use. Ran build + ctest for the AGC driver (including PackedFloat16Native, PackedAlu, Float16MinMaxBits, Fp16Overflow, Float16FmaRounding, Dx10Clamp); all pass. The only failure is agc_driver_tessellation, which also fails on main. The diff applies cleanly on main, so the #4072 dependency isn't needed. Merging once the full build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6169699860 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5811#issuecomment-6169699860). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T13:39:10Z. --- Checked the diff: `sourceLaneBits` only memoizes `laneBits` per (source, half) within one `packedFloat16` call. The emitted operations and bit rules are unchanged, and straight-line IR means the cached value dominates every use. Ran build + ctest for the AGC driver (including PackedFloat16Native, PackedAlu, Float16MinMaxBits, Fp16Overflow, Float16FmaRounding, Dx10Clamp); all pass. The only failure is `agc_driver_tessellation`, which also fails on main. The diff applies cleanly on main, so the #4072 dependency isn't needed. Merging once the full build is green.
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!5811
No description provided.