compute: lower op_sel on VOP3 v_fma_f16 in direct compute #3234

Merged
Leyukaka merged 1 commit from upstream-pr/3234 into main 2026-11-28 01:07:33 +00:00
Leyukaka commented 2026-11-28 00:14:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T00:14:05Z.


Fixes #3233. Part of #2935. Target branch main.

Change (src/gfx1013_direct_compute.inl, the binary16 FMA lowering in DirectCompute::float_alu): VOP3 v_fma_f16 accepts op_sel.

  • Bits 0 to 2 read bits [31:16] of the matching VGPR source instead of [15:0]. Abs and neg apply after the selection.
  • Bit 3 writes the binary16 result to D[31:16] and keeps D[15:0]. Without it the result goes to D[15:0] and D[31:16] is kept, as before.
  • The half selection follows LLVM's AMDGPU modifier syntax (VOP3 op_sel: "the last value controls destination", 0 selects the low bits and 1 the high bits). That page does not say what happens to the other destination half. Keeping it mirrors what main already does for the low-half write. I have not measured it on console hardware.
  • Still refused:
    • op_sel on an SGPR or constant source, with the new message "unsupported v_fma_f16 high-half op_sel on non-VGPR source";
    • op_sel with clamp;
    • v_fmac_f16 with op_sel;
    • DPP and SDWA.
  • tests/native_fma_f16_check.py: the one refusal control that used a VGPR source selection now uses an inline-constant source, which stays refused.

Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on main 14d56502 plus this commit.

  • New native_fma_f16_opsel_ir and native_fma_f16_opsel_hardware (wave32 request, groups 0 and 1, EXEC set before the per-lane setup) cover the seven forms found in the captured requests.
    • Every source VGPR holds different values in its two halves: (1, 2), (3, 4) and (5, 16).
    • Each destination starts at 0xABCD1234, so a wrong destination half also changes the kept half.
    • Expected words come from tests/f16_packed_model.py: 0xABCD4980, 0xABCD4880, 0xABCD4A80, 0x4E001234, 0x4D001234, 0x4CC01234 and 0x45001234.
    • Three refusal controls: an SGPR source selection, v_fmac_f16 DPP, and clamp with op_sel.
  • Run with main's native_compute_ir_dump, the new test fails with "unsupported v_fma_f16 high-half op_sel".
  • 27 tests pass with -R "native_fma_f16|native_f16|native_sdwa_f16|native_packed|native_cvt_f16|native_direct_container".
  • Mutation check by hand: reading the low half for a selected source fails both new tests.

Measured with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests, on main 14d56502 and with this commit.

  • The compile counts do not change on a local capture of 2,689 requests (487 compile), on the requests of one start-up run (500 of 2,718), or on the 882 requests of #3224 (110).
  • One program (4,282 dispatches) gets past this refusal and stops at "direct DXIL lowering for v_pk_fmac_f16".
  • The two heavily dispatched programs first stop at the wave-size gap. With #3006 and this commit, both compile, 658,064 dispatches in that run.
  • Counts and instruction shape only.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5534811588 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3234). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-28T00:14:05Z. --- Fixes #3233. Part of #2935. Target branch `main`. **Change** (`src/gfx1013_direct_compute.inl`, the binary16 FMA lowering in `DirectCompute::float_alu`): VOP3 `v_fma_f16` accepts `op_sel`. - Bits 0 to 2 read bits [31:16] of the matching VGPR source instead of [15:0]. Abs and neg apply after the selection. - Bit 3 writes the binary16 result to D[31:16] and keeps D[15:0]. Without it the result goes to D[15:0] and D[31:16] is kept, as before. - The half selection follows LLVM's AMDGPU modifier syntax (VOP3 `op_sel`: "the last value controls destination", 0 selects the low bits and 1 the high bits). That page does not say what happens to the other destination half. Keeping it mirrors what `main` already does for the low-half write. I have not measured it on console hardware. - Still refused: - `op_sel` on an SGPR or constant source, with the new message "unsupported v_fma_f16 high-half op_sel on non-VGPR source"; - `op_sel` with clamp; - `v_fmac_f16` with `op_sel`; - DPP and SDWA. - `tests/native_fma_f16_check.py`: the one refusal control that used a VGPR source selection now uses an inline-constant source, which stays refused. **Tests.** The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on `main` `14d56502` plus this commit. - New `native_fma_f16_opsel_ir` and `native_fma_f16_opsel_hardware` (wave32 request, groups 0 and 1, EXEC set before the per-lane setup) cover the seven forms found in the captured requests. - Every source VGPR holds different values in its two halves: (1, 2), (3, 4) and (5, 16). - Each destination starts at `0xABCD1234`, so a wrong destination half also changes the kept half. - Expected words come from `tests/f16_packed_model.py`: `0xABCD4980`, `0xABCD4880`, `0xABCD4A80`, `0x4E001234`, `0x4D001234`, `0x4CC01234` and `0x45001234`. - Three refusal controls: an SGPR source selection, `v_fmac_f16` DPP, and clamp with `op_sel`. - Run with `main`'s `native_compute_ir_dump`, the new test fails with "unsupported v_fma_f16 high-half op_sel". - 27 tests pass with `-R "native_fma_f16|native_f16|native_sdwa_f16|native_packed|native_cvt_f16|native_direct_container"`. - Mutation check by hand: reading the low half for a selected source fails both new tests. **Measured** with `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests`, on `main` `14d56502` and with this commit. - The compile counts do not change on a local capture of 2,689 requests (487 compile), on the requests of one start-up run (500 of 2,718), or on the 882 requests of #3224 (110). - One program (4,282 dispatches) gets past this refusal and stops at "direct DXIL lowering for v_pk_fmac_f16". - The two heavily dispatched programs first stop at the wave-size gap. With #3006 and this commit, both compile, 658,064 dispatches in that run. - Counts and instruction shape only. AI-assisted.
R0Y00 commented 2026-11-28 01:07:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T01:07:28Z.

Review: APPROVED


Independent review of 728b5fe057 integrated over main 7364e6a9, tree a63cbe956636157d3cab71a4d025619540f81bc0. The VOP3 selector reads the requested VGPR halves before abs/neg and preserves the other destination half. The three refusal cases still reject selected non-VGPR operands, DPP on FMAC and clamp on the new op_sel path. The replay checks 14 exact result words across two groups and all guards.

Debug and Release /O2 each passed all nine tested entries, including the existing packed F16 and slot-67 wave-size checks. Windows 11 26200.9974, RTX 4060 Laptop driver 32.0.16.1656. No skips. Main has since added #3229's runtime-only output diagnostics and its fixture, outside the compiler and standalone replay inputs tested here.

ctest --preset dev --no-tests=error --output-on-failure -j 1 -R '^native_(fma_f16_.*|packed_f16_inline_(ir|controls|compute_hardware)|slot67_wave_size_hardware)$'
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6094816899 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3234#pullrequestreview-6094816899). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-28T01:07:28Z. **Review:** APPROVED --- Independent review of 728b5fe057bb478e04b3d54607edcf87c448142b integrated over main 7364e6a9, tree a63cbe956636157d3cab71a4d025619540f81bc0. The VOP3 selector reads the requested VGPR halves before abs/neg and preserves the other destination half. The three refusal cases still reject selected non-VGPR operands, DPP on FMAC and clamp on the new op_sel path. The replay checks 14 exact result words across two groups and all guards. Debug and Release /O2 each passed all nine tested entries, including the existing packed F16 and slot-67 wave-size checks. Windows 11 26200.9974, RTX 4060 Laptop driver 32.0.16.1656. No skips. Main has since added #3229's runtime-only output diagnostics and its fixture, outside the compiler and standalone replay inputs tested here. ```powershell ctest --preset dev --no-tests=error --output-on-failure -j 1 -R '^native_(fma_f16_.*|packed_f16_inline_(ir|controls|compute_hardware)|slot67_wave_size_hardware)$' ```
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
R0Y00/Xbox2Windows!3234
No description provided.