compute: accept SGPR and inline-constant sources in binary16 SDWA #3242

Manually merged
github merged 1 commit from github-bot/gh-3240 into gh-pr/3240/base 2026-11-28 01:43:48 +00:00 AGit
Owner

@⁠Leyukaka on GitHub · 2026-11-28 01:20 UTC · original
Leyukaka:sdwa-f16-scalar-src → main · +140 −12 · 6 files · 1 commits · merged 2026-11-28 01:42 UTC

Part of #2935, claimed in #3226 (item 1 of my comment there). Target branch main.

Change (src/gfx1013_compute_native.cpp, src/gfx1013_direct_compute.inl, docs/experiments/native-sdwa-f16.md): the binary16 SDWA VOP2 arithmetic (v_add_f16, v_sub_f16, v_subrev_f16, v_mul_f16) accepts an SGPR or an inline constant as src0 or src1. GFX10 SDWA allows this through extension bits 23 and 31, which tools/disasm_rdna2.py decodes the same way.

  • The source selection applies to the 32-bit scalar word. DWORD and WORD_0 read bits [15:0], and WORD_1 reads bits [31:16].
  • An inline float is first turned into its binary16 value with packed_f16_inline_constant (#3232).
  • Still refused:
    • A WORD_1 selection of an inline constant, with the new message "unsupported SDWA binary16 inline constant selection". What sits in the other half of such a constant is not modelled here.
    • Literals, since SDWA has none.
    • The other modifiers.
  • v_min_f16/v_max_f16 SDWA are untouched. They wait for #3127.
  • tests/native_sdwa_f16_check.py drops its two controls that expected these legal encodings to be refused.

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

  • New native_sdwa_f16_scalar_ir and _hardware compare exact words against tests/f16_packed_model.py for five cases:

    • add with an SGPR DWORD src0;
    • add with inline 1.0 WORD_0 and integer 0 DWORD;
    • mul with an SGPR WORD_1 src1;
    • sub and subrev with an SGPR src1.

    Every register source (SGPR and VGPR) has distinct halves, and the destination checks both UNUSED_PRESERVE (sentinel kept) and UNUSED_PAD (zero).

  • Refusal controls: a literal, an SGPR selection with a modifier, a WORD_1 inline constant, and two SDWA min/max forms (0x39, 0x3a), still refused as "unimplemented direct SDWA operand profile".

  • With main's native_compute_ir_dump, the new test fails on "SDWA binary16 source must be a VGPR".

  • 33 tests pass with -R "native_sdwa|native_f16|native_fma_f16|native_packed|native_cvt_f16|native_direct_container".

  • Mutation check by hand: ignoring the inline-constant conversion fails both new tests.

Measured with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests on main 7364e6a9, before and with this commit.

  • No compile count changes on a local capture of 2,689 requests (494), on the requests of one start-up run (507), or on the 882 requests of #3226 (128). Nothing regresses.
  • Three capture programs get past this refusal. Two stop at "multi-wave64 exchange requires converged group control flow" and one at v_rcp_f16, which #3222 lowers.
  • With #3222 also applied, those programs still stop later.
  • In the 882 requests, the two programs that move account for 85,776 dispatches.
  • Counts and instruction shape only.

AI-assisted.

**@⁠Leyukaka** on GitHub · 2026-11-28 01:20 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3240) `Leyukaka:sdwa-f16-scalar-src` → `main` · +140 −12 · 6 files · 1 commits · merged 2026-11-28 01:42 UTC Part of #2935, claimed in #3226 (item 1 of my comment there). Target branch `main`. **Change** (`src/gfx1013_compute_native.cpp`, `src/gfx1013_direct_compute.inl`, `docs/experiments/native-sdwa-f16.md`): the binary16 SDWA VOP2 arithmetic (`v_add_f16`, `v_sub_f16`, `v_subrev_f16`, `v_mul_f16`) accepts an SGPR or an inline constant as src0 or src1. GFX10 SDWA allows this through extension bits 23 and 31, which `tools/disasm_rdna2.py` decodes the same way. - The source selection applies to the 32-bit scalar word. DWORD and WORD_0 read bits [15:0], and WORD_1 reads bits [31:16]. - An inline float is first turned into its binary16 value with `packed_f16_inline_constant` (#3232). - Still refused: - A WORD_1 selection of an inline constant, with the new message "unsupported SDWA binary16 inline constant selection". What sits in the other half of such a constant is not modelled here. - Literals, since SDWA has none. - The other modifiers. - `v_min_f16`/`v_max_f16` SDWA are untouched. They wait for #3127. - `tests/native_sdwa_f16_check.py` drops its two controls that expected these legal encodings to be refused. **Tests.** The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, Release, on `main` `7364e6a9` plus this commit. - New `native_sdwa_f16_scalar_ir` and `_hardware` compare exact words against `tests/f16_packed_model.py` for five cases: - add with an SGPR DWORD src0; - add with inline 1.0 WORD_0 and integer 0 DWORD; - mul with an SGPR WORD_1 src1; - sub and subrev with an SGPR src1. Every register source (SGPR and VGPR) has distinct halves, and the destination checks both UNUSED_PRESERVE (sentinel kept) and UNUSED_PAD (zero). - Refusal controls: a literal, an SGPR selection with a modifier, a WORD_1 inline constant, and two SDWA min/max forms (0x39, 0x3a), still refused as "unimplemented direct SDWA operand profile". - With `main`'s `native_compute_ir_dump`, the new test fails on "SDWA binary16 source must be a VGPR". - 33 tests pass with `-R "native_sdwa|native_f16|native_fma_f16|native_packed|native_cvt_f16|native_direct_container"`. - Mutation check by hand: ignoring the inline-constant conversion fails both new tests. **Measured** with `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests` on `main` `7364e6a9`, before and with this commit. - No compile count changes on a local capture of 2,689 requests (494), on the requests of one start-up run (507), or on the 882 requests of #3226 (128). Nothing regresses. - Three capture programs get past this refusal. Two stop at "multi-wave64 exchange requires converged group control flow" and one at `v_rcp_f16`, which #3222 lowers. - With #3222 also applied, those programs still stop later. - In the 882 requests, the two programs that move account for 85,776 dispatches. - Counts and instruction shape only. AI-assisted.
The binary16 SDWA VOP2 arithmetic (add, sub, subrev, mul) accepts an
SGPR or an inline constant as src0/src1, as GFX10 SDWA allows (extension
bits 23 and 31). The source selection applies to the 32-bit scalar
word; an inline float is materialized as its binary16 value first. A
WORD_1 selection of an inline constant stays refused because its other
half is not modelled here. Literals stay refused (SDWA has none).

New test native_sdwa_f16_scalar (IR and hardware): SGPR DWORD/WORD_1,
inline 1.0 and integer 0, with distinct halves in every source and the
preserved/padded destination half, plus refusal controls.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 01:25:41 +00:00
github-bot changed target branch from main to gh-pr/3240/base 2026-11-28 01:43:45 +00:00
github manually merged commit ae208bb98b into gh-pr/3240/base 2026-11-28 01:43:48 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-28 01:42 UTC · original · approved these changes

Reviewed ae208bb98b on main 8007a539. The integrated source tree is 6fa0888f63. Checked the direct compute path for SGPR DWORD/WORD_0/WORD_1 and inline DWORD/WORD_0 as well as the inline high-half, literal, sign extension and opcode refusal controls.

Debug 8/8 and Release /O2 8/8, no skips, using:

ctest --test-dir <build> --no-tests=error --output-on-failure -j 1 -R "^(native_sdwa_f16(_scalar)?_(ir|hardware)|native_f16_alu_(ir|hardware)|native_fma_f16_opsel_ir|native_direct_container)$"

RTX 4060 Laptop GPU, driver 32.0.16.1656, Windows 11 26200.9974, standalone replay without the debug layer. Hosted Windows (required), Linux Python, and gfx1013 assembly jobs passed. The hosted /O2 job was skipped.

**@⁠R0Y00** on GitHub · 2026-11-28 01:42 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3240#pullrequestreview-6094961066) · **approved these changes** Reviewed ae208bb98b57 on main 8007a539. The integrated source tree is 6fa0888f63ccbe245925e1a5b03746f3d852e74e. Checked the direct compute path for SGPR DWORD/WORD_0/WORD_1 and inline DWORD/WORD_0 as well as the inline high-half, literal, sign extension and opcode refusal controls. Debug 8/8 and Release /O2 8/8, no skips, using: ``` ctest --test-dir <build> --no-tests=error --output-on-failure -j 1 -R "^(native_sdwa_f16(_scalar)?_(ir|hardware)|native_f16_alu_(ir|hardware)|native_fma_f16_opsel_ir|native_direct_container)$" ``` RTX 4060 Laptop GPU, driver 32.0.16.1656, Windows 11 26200.9974, standalone replay without the debug layer. Hosted Windows (required), Linux Python, and gfx1013 assembly jobs passed. The hosted /O2 job was skipped.
This discussion has been locked. Commenting is limited to contributors.
No description provided.