shader: lower VOP3P dot-product instructions in pixel_aot #385

Merged
KomaGuy merged 3 commits from upstream-pr/391 into main 2026-11-22 09:01:31 +00:00
KomaGuy commented 2026-11-22 00:09:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KomaGuy on 2026-11-22T00:09:33Z.


Change

Lower all seven VOP3P dot-product forms in tools/pixel_aot.py, covering 7 additional VOP3P forms on both gfx1013 and gfx1030:

  • Supported instructions: v_dot2_f32_f16, v_dot2_i32_i16, v_dot2_u32_u16, v_dot4_i32_i8, v_dot4_u32_u8, v_dot8_i32_i4, and v_dot8_u32_u4.
  • v_dot2_f32_f16 semantics: Widens src0/src1 binary16 lanes through widen16 using op_sel (default [0,0,0]) and op_sel_hi (default [1,1,1]), applies neg_lo (including neg_lo[2] on the f32 accumulator src2) and neg_hi, zero-extends inline f16 float constants in src0/src1 matching RDNA 2 hardware, and optionally saturates to [0, 1] with clamp.
  • Integer dot-product semantics & exact SM 6.0 saturation: v_dot2_{i,u}32_{i,u}16 support op_sel, op_sel_hi, and clamp; v_dot4_{i,u}32_{i,u}8 and v_dot8_{i,u}32_{i,u}4 support clamp only (rejecting op_sel/neg_*). All six integer forms accumulate in emulated 64-bit unsigned pairs (uint2) emitted only when used, keeping wrapping and saturating clamp (INT32_MIN / INT32_MAX / UINT32_MAX) bit-exact on SM 6.0 without requiring 64-bit integer shader support.
  • Fixture & controls: Added DOT_BODY and check_dot_draw in tests/pixel_aot_check.py (assembled on gfx1030 in check_binary because LLVM's gfx1013 subtarget omits dot-product instructions) across 4 constant sets covering mixed signs, op_sel/neg_lo/neg_hi, INT32_MAX/INT32_MIN/UINT32_MAX saturation and wraparound, plus 5 negative mutations and negative controls for invalid modifiers, out-of-scope VOP3P neighbors, WQM, and vmcnt/lgkmcnt hazards.

Verification

Tested on Linux x86_64 (Python 3.13.5, LLVM 19.1.7, Clang 19.1.7) on top of 9bdbb20:

  • python3 -B tests/pixel_aot_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM-19.so — passed (controls, negative controls, llvm-mc -mcpu=gfx1030 round-trip assembly→DXBC/XDAT/XBCH/FSSM→disassembly→lowering parity for DOT_BODY, and gfx1013 parity for all existing fixtures).
  • python3 -B tests/ffx_dispatch_aot_check.py llvm-mc-19 llvm-objcopy-19 libLLVM-19.so — passed.
  • python3 -B tests/script_state_check.py, tests/bcpack_check.py, tests/resource_ranges_check.py, tests/layout_chunks_check.py, tests/docs_links_check.py, tests/bidi_controls_check.py — all passed.
  • Verified tools/form_coverage.py records all 7 dot-product forms (v_dot2_f32_f16, v_dot2_i32_i16, v_dot2_u32_u16, v_dot4_i32_i8, v_dot4_u32_u8, v_dot8_i32_i4, v_dot8_u32_u4) against both docs/coverage/gfx1013.tsv and docs/coverage/rdna2.tsv.
  • Compiled the generated HLSL for DOT_BODY and all 5 negative mutations (neg_lo, dot2 signed vs unsigned, dot4_i32_i8 clamp, dot8 signed vs unsigned, dot8_u32_u4 clamp) as C++20 with clang++-19 -std=c++20 -O2 -Wall -Wextra -Wpedantic -Werror -fsanitize=undefined,address — bit-exact match on all 4 constant sets and all 5 mutations caught; 0 sanitizer errors.
  • Windows C++, DXC (dxc -Gis -T ps_6_0), WARP (pixel_aot_warp), and hardware (pixel_aot_hardware) checks were not run locally on Linux; relying on the build-and-test Windows CI job to verify DXC compilation and D3D12 WARP readback.

Evidence and follow-up

  • All new test fixtures in tests/pixel_aot_check.py are original MIT-licensed RDNA 2 (gfx1030) assembly sequences built from source at test time.
  • Semantics follow the AMD RDNA 2 Instruction Set Architecture Reference Guide.
  • Complements #376 (v_pk_*_f16) and #389 (v_fma_mix*) without overlapping their opcodes; packed 16-bit integer VOP3P instructions stay rejected here for a separate focused PR.
  • This contribution was AI-assisted.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6536165173 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/391). Originally posted by [KomaGuy](https://github.com/KomaGuy) on 2026-11-22T00:09:33Z. --- ## Change Lower all seven `VOP3P` dot-product forms in `tools/pixel_aot.py`, covering 7 additional `VOP3P` forms on both `gfx1013` and `gfx1030`: - **Supported instructions:** `v_dot2_f32_f16`, `v_dot2_i32_i16`, `v_dot2_u32_u16`, `v_dot4_i32_i8`, `v_dot4_u32_u8`, `v_dot8_i32_i4`, and `v_dot8_u32_u4`. - **`v_dot2_f32_f16` semantics:** Widens `src0`/`src1` binary16 lanes through `widen16` using `op_sel` (default `[0,0,0]`) and `op_sel_hi` (default `[1,1,1]`), applies `neg_lo` (including `neg_lo[2]` on the `f32` accumulator `src2`) and `neg_hi`, zero-extends inline `f16` float constants in `src0`/`src1` matching RDNA 2 hardware, and optionally saturates to `[0, 1]` with `clamp`. - **Integer dot-product semantics & exact SM 6.0 saturation:** `v_dot2_{i,u}32_{i,u}16` support `op_sel`, `op_sel_hi`, and `clamp`; `v_dot4_{i,u}32_{i,u}8` and `v_dot8_{i,u}32_{i,u}4` support `clamp` only (rejecting `op_sel`/`neg_*`). All six integer forms accumulate in emulated 64-bit unsigned pairs (`uint2`) emitted only when used, keeping wrapping and saturating `clamp` (`INT32_MIN` / `INT32_MAX` / `UINT32_MAX`) bit-exact on SM 6.0 without requiring 64-bit integer shader support. - **Fixture & controls:** Added `DOT_BODY` and `check_dot_draw` in `tests/pixel_aot_check.py` (assembled on `gfx1030` in `check_binary` because LLVM's `gfx1013` subtarget omits dot-product instructions) across 4 constant sets covering mixed signs, `op_sel`/`neg_lo`/`neg_hi`, `INT32_MAX`/`INT32_MIN`/`UINT32_MAX` saturation and wraparound, plus 5 negative mutations and negative controls for invalid modifiers, out-of-scope `VOP3P` neighbors, WQM, and `vmcnt`/`lgkmcnt` hazards. ## Verification Tested on Linux x86_64 (Python 3.13.5, LLVM 19.1.7, Clang 19.1.7) on top of `9bdbb20`: - `python3 -B tests/pixel_aot_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM-19.so` — passed (controls, negative controls, `llvm-mc -mcpu=gfx1030` round-trip assembly→DXBC/XDAT/XBCH/FSSM→disassembly→lowering parity for `DOT_BODY`, and `gfx1013` parity for all existing fixtures). - `python3 -B tests/ffx_dispatch_aot_check.py llvm-mc-19 llvm-objcopy-19 libLLVM-19.so` — passed. - `python3 -B tests/script_state_check.py`, `tests/bcpack_check.py`, `tests/resource_ranges_check.py`, `tests/layout_chunks_check.py`, `tests/docs_links_check.py`, `tests/bidi_controls_check.py` — all passed. - Verified `tools/form_coverage.py` records all 7 dot-product forms (`v_dot2_f32_f16`, `v_dot2_i32_i16`, `v_dot2_u32_u16`, `v_dot4_i32_i8`, `v_dot4_u32_u8`, `v_dot8_i32_i4`, `v_dot8_u32_u4`) against both `docs/coverage/gfx1013.tsv` and `docs/coverage/rdna2.tsv`. - Compiled the generated HLSL for `DOT_BODY` and all 5 negative mutations (`neg_lo`, `dot2` signed vs unsigned, `dot4_i32_i8` clamp, `dot8` signed vs unsigned, `dot8_u32_u4` clamp) as C++20 with `clang++-19 -std=c++20 -O2 -Wall -Wextra -Wpedantic -Werror -fsanitize=undefined,address` — bit-exact match on all 4 constant sets and all 5 mutations caught; 0 sanitizer errors. - Windows C++, DXC (`dxc -Gis -T ps_6_0`), WARP (`pixel_aot_warp`), and hardware (`pixel_aot_hardware`) checks were not run locally on Linux; relying on the `build-and-test` Windows CI job to verify DXC compilation and D3D12 WARP readback. ## Evidence and follow-up - All new test fixtures in `tests/pixel_aot_check.py` are original MIT-licensed RDNA 2 (`gfx1030`) assembly sequences built from source at test time. - Semantics follow the [AMD RDNA 2 Instruction Set Architecture Reference Guide](https://docs.amd.com/v/u/en-US/rdna2-shader-instruction-set-architecture). - Complements #376 (`v_pk_*_f16`) and #389 (`v_fma_mix*`) without overlapping their opcodes; packed 16-bit integer `VOP3P` instructions stay rejected here for a separate focused PR. - This contribution was AI-assisted. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets.
upstream-sync closed this pull request 2026-11-24 06:42:48 +00:00
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!385
No description provided.