feat(shader): accept SDWA byte destination selectors on v_cvt_f16_f32 #17605

Merged
Kikoarl merged 3 commits from upstream-pr/17605 into main 2026-11-15 20:02:09 +00:00
Kikoarl commented 2026-11-09 01:00:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-11-09T01:00:45Z.


What

Accept Sub-Dword Addressing (SDWA) byte destination selectors on v_cvt_f16_f32 (VOP1 opcode 0x0a).

Updates vop1SdwaRules for VCvtF16F32 to allow sdwaSelBytes() | sdwaSelWords() (previously restricted to sdwaSelWords()). In AMD RDNA2 ISA §13.3.7 Table 88, 16-bit destination instructions accept byte destination selectors (BYTE_0..BYTE_3) alongside word destination selectors (WORD_0, WORD_1) and destination unused modes UNUSED_PAD, UNUSED_SEXT, and UNUSED_PRESERVE.

Sources:

  • AMD RDNA2 ISA Manual §§6.8, 12.8 opcode 10, 13.3.7 Table 88
  • LLVM 19.1.0 VOP1Instructions.td (lines 294-295) and SIPeepholeSDWA.cpp destination folding
  • Canonical technical debt documented in docs/dev/debt/shader.md under ### Functional strictly < 1000 characters (Lesson L60)

Tested

  • Physical GPU execution test tests/agc_driver_sdwa_cvt_f16_f32_bytes_tests executed on host Intel(R) Graphics (RPL-S) (Vulkan 1.4):
    • Wave32: passed (returncode 0)
    • Wave64: passed (returncode 0)
  • Verified 6 pinned input float values through full 16-bit half float conversions, 6 sub-dword destination selections (BYTE_0..BYTE_3, WORD_0, WORD_1), and 3 unused modes (UNUSED_PAD, UNUSED_SEXT, UNUSED_PRESERVE).
  • Negative refusal tests confirming decoder throws std::invalid_argument on invalid selector 7 and illegal destination unused mode 3.
  • Passed python3 tools/check_conventions.py --base origin/main with 100% compliance.

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: Intel(R) Graphics (RPL-S) (Vulkan 1.4.303, Linux 7.2.11 cachyos)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5217047910 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17605). Originally posted by [Kikoarl](https://github.com/Kikoarl) on 2026-11-09T01:00:45Z. --- ### What Accept Sub-Dword Addressing (SDWA) byte destination selectors on `v_cvt_f16_f32` (VOP1 opcode 0x0a). Updates `vop1SdwaRules` for `VCvtF16F32` to allow `sdwaSelBytes() | sdwaSelWords()` (previously restricted to `sdwaSelWords()`). In AMD RDNA2 ISA §13.3.7 Table 88, 16-bit destination instructions accept byte destination selectors (`BYTE_0`..`BYTE_3`) alongside word destination selectors (`WORD_0`, `WORD_1`) and destination unused modes `UNUSED_PAD`, `UNUSED_SEXT`, and `UNUSED_PRESERVE`. Sources: - AMD RDNA2 ISA Manual §§6.8, 12.8 opcode 10, 13.3.7 Table 88 - LLVM 19.1.0 `VOP1Instructions.td` (lines 294-295) and `SIPeepholeSDWA.cpp` destination folding - Canonical technical debt documented in `docs/dev/debt/shader.md` under `### Functional` strictly < 1000 characters (Lesson L60) ### Tested - Physical GPU execution test `tests/agc_driver_sdwa_cvt_f16_f32_bytes_tests` executed on host `Intel(R) Graphics (RPL-S)` (Vulkan 1.4): - Wave32: passed (returncode 0) - Wave64: passed (returncode 0) - Verified 6 pinned input float values through full 16-bit half float conversions, 6 sub-dword destination selections (`BYTE_0`..`BYTE_3`, `WORD_0`, `WORD_1`), and 3 unused modes (`UNUSED_PAD`, `UNUSED_SEXT`, `UNUSED_PRESERVE`). - Negative refusal tests confirming decoder throws `std::invalid_argument` on invalid selector 7 and illegal destination unused mode 3. - Passed `python3 tools/check_conventions.py --base origin/main` with 100% compliance. ### 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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: Intel(R) Graphics (RPL-S) (Vulkan 1.4.303, Linux 7.2.11 cachyos) - [x] AI-assisted: yes
milescoviello commented 2026-11-09 10:53:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-09T10:53:25Z.

Review: APPROVED


NVIDIA result to go with DonRyuzaki's AMD run, this time with validation on.

Setup: Ubuntu 26.04.1, RTX 4070 Ti, NVIDIA 615.71.09, GCC 15.2, Release, head 13e7063eb6. Run with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (layer 1.4.341, VK_LOADER_DEBUG=layer), ctest -R '^agc_driver_sdwa_cvt_f16_f32_bytes' -V, 3 runs.

  • agc_driver_sdwa_cvt_f16_f32_bytes (Wave32) and _tests_wave64 pass 3 of 3 runs each, none skipped.
  • 2 of 2 pass in 3 of 3 runs, with 0 VUID- lines. The loader inserted the layer in both tests and a physical device was selected in each, so the layer checked both.

From reading: the only decoder change is the destination mask of the VCvtF16F32 row in vop1SdwaRules (RdnaVectorOpDecoder.cpp:1131), widened to sdwaSelBytes() | sdwaSelWords(). That matches the row above it for VCvtF32F16. Source selects and the clamp flag are unchanged, so no other SDWA form of this opcode changes behaviour.

Edited 11-09: the validation numbers above come from a re-run with layer 1.4.341, where VK_LOADER_DEBUG=layer shows the loader inserting it in every test. The 1.4.363 layer my first run pointed at wasn't installed, and these test programs don't print the loader's "not found" error, so that run validated nothing (#17896).

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5824844879 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17605#pullrequestreview-5824844879). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-11-09T10:53:25Z. **Review:** APPROVED --- NVIDIA result to go with DonRyuzaki's AMD run, this time with validation on. **Setup:** Ubuntu 26.04.1, RTX 4070 Ti, NVIDIA 615.71.09, GCC 15.2, Release, head `13e7063eb6`. Run with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (layer 1.4.341, `VK_LOADER_DEBUG=layer`), `ctest -R '^agc_driver_sdwa_cvt_f16_f32_bytes' -V`, 3 runs. - `agc_driver_sdwa_cvt_f16_f32_bytes` (Wave32) and `_tests_wave64` pass 3 of 3 runs each, none skipped. - 2 of 2 pass in 3 of 3 runs, with 0 `VUID-` lines. The loader inserted the layer in both tests and a physical device was selected in each, so the layer checked both. From reading: the only decoder change is the destination mask of the `VCvtF16F32` row in `vop1SdwaRules` (`RdnaVectorOpDecoder.cpp:1131`), widened to `sdwaSelBytes() | sdwaSelWords()`. That matches the row above it for `VCvtF32F16`. Source selects and the clamp flag are unchanged, so no other SDWA form of this opcode changes behaviour. *Edited 11-09: the validation numbers above come from a re-run with layer 1.4.341, where `VK_LOADER_DEBUG=layer` shows the loader inserting it in every test. The 1.4.363 layer my first run pointed at wasn't installed, and these test programs don't print the loader's "not found" error, so that run validated nothing (#17896).* 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!17605
No description provided.