shader: lower quad-local DPP16 and DPP8 32-bit integer/bitwise/shift ops in pixel_aot #408

Merged
KomaGuy merged 3 commits from upstream-pr/414 into main 2026-11-22 11:55:40 +00:00
KomaGuy commented 2026-11-22 00:51:28 +00:00 (Migrated from github.com)

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


Change

Lower quad-local DPP16 (quad_perm) and DPP8 (dpp8) forms for 23 32-bit integer, 24-bit multiply, bitwise, shift, and bit-scan VOP1/VOP2 operations in tools/pixel_aot.py, covering 23 additional DPP16 and 23 additional DPP8 forms (+46 forms on both gfx1013 and gfx1030):

  • Supported v_*_dpp instructions (23):
    • Integer add/sub/min/max (7): v_add_nc_u32_dpp, v_sub_nc_u32_dpp, v_subrev_nc_u32_dpp, v_min_i32_dpp, v_max_i32_dpp, v_min_u32_dpp, v_max_u32_dpp.
    • 24-bit multiply (4): v_mul_i32_i24_dpp, v_mul_hi_i32_i24_dpp, v_mul_u32_u24_dpp, v_mul_hi_u32_u24_dpp.
    • Bitwise logic (5): v_and_b32_dpp, v_or_b32_dpp, v_xor_b32_dpp, v_xnor_b32_dpp, v_not_b32_dpp.
    • Shifts & bit-scan (7): v_lshlrev_b32_dpp, v_lshrrev_b32_dpp, v_ashrrev_i32_dpp, v_bfrev_b32_dpp, v_ffbl_b32_dpp, v_ffbh_u32_dpp, v_ffbh_i32_dpp.
  • Portable SM 6.0 semantics: Swizzles src0 as uint bits via QuadReadAcrossX, QuadReadAcrossY, QuadReadAcrossDiagonal, or uniform QuadReadLaneAt (selected via WaveGetLaneIndex() & 3u), staying valid across wave sizes 4 (WARP) through 64. Optional helpers (dpp_mul_hi_u24, dpp_mul_hi_i24 using 12-bit limb splits without 64-bit integer shader requirements, and MSB-indexed dpp_ffbh_u32/dpp_ffbh_i32) are emitted only when used; existing shaders emit none of them.
  • Strict fail-closed controls: Rejects cross-quad DPP8, row_*/wave_* controls, partial masks (row_mask/bank_mask != 0xf), FP source modifiers (-/|.|), non-VGPR operands, WQM, and vmcnt hazards.
  • Genuine 4-lane quad draw fixture: DPP_INT32_BODY derives integer quad lane ID {0, 1, 2, 3} from uv.x/uv.y, exercises all 23 forms across 3 constant sets (including negative/extreme i24 products, zero/all-ones bit scans, and shift counts >= 32), exports all 4 bytes of the 32-bit accumulator as exact [0, 255] integers, and checks 5 negative mutations.

Verification

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

  • python3 -B tests/pixel_aot_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM-19.so — passed (controls, negative controls, and llvm-mc -mcpu=gfx1013 assembly→DXBC/XDAT/XBCH/FSSM→disassembly→lowering parity for DPP_INT32_BODY and 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 23 DPP16 and 23 DPP8 forms against both docs/coverage/gfx1013.tsv and docs/coverage/rdna2.tsv.
  • Executed the actual generated HLSL (including verbatim dpp_mul_hi_{u,i}24 and dpp_ffbh_{u,i}32 helpers) for DPP_INT32_BODY and all 5 negative mutations on a 4-lane SIMT 2×2 pixel quad C++20 harness with clang++-19 -std=c++20 -O2 -Wall -Wextra -Wpedantic -Werror -fsanitize=undefined,address — bit-exact match across all 4 quad lanes on all 3 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 quad readback.

Evidence and follow-up

  • All new test fixtures in tests/pixel_aot_check.py are original MIT-licensed gfx1013 assembly sequences built from source at test time.
  • Semantics follow the AMD RDNA 2 Instruction Set Architecture Reference Guide and DirectX Shader Model 6.0 quad-intrinsic specification.
  • Complements #408 (20 f32/move/select DPP16/DPP8 forms) with zero opcode overlap; remaining f16 and conversion v_*_dpp forms stay rejected here for separate focused PRs.
  • 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:6536518930 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/414). Originally posted by [KomaGuy](https://github.com/KomaGuy) on 2026-11-22T00:51:28Z. --- ## Change Lower quad-local `DPP16` (`quad_perm`) and `DPP8` (`dpp8`) forms for 23 32-bit integer, 24-bit multiply, bitwise, shift, and bit-scan `VOP1`/`VOP2` operations in `tools/pixel_aot.py`, covering 23 additional `DPP16` and 23 additional `DPP8` forms (+46 forms on both `gfx1013` and `gfx1030`): - **Supported `v_*_dpp` instructions (23):** - Integer add/sub/min/max (7): `v_add_nc_u32_dpp`, `v_sub_nc_u32_dpp`, `v_subrev_nc_u32_dpp`, `v_min_i32_dpp`, `v_max_i32_dpp`, `v_min_u32_dpp`, `v_max_u32_dpp`. - 24-bit multiply (4): `v_mul_i32_i24_dpp`, `v_mul_hi_i32_i24_dpp`, `v_mul_u32_u24_dpp`, `v_mul_hi_u32_u24_dpp`. - Bitwise logic (5): `v_and_b32_dpp`, `v_or_b32_dpp`, `v_xor_b32_dpp`, `v_xnor_b32_dpp`, `v_not_b32_dpp`. - Shifts & bit-scan (7): `v_lshlrev_b32_dpp`, `v_lshrrev_b32_dpp`, `v_ashrrev_i32_dpp`, `v_bfrev_b32_dpp`, `v_ffbl_b32_dpp`, `v_ffbh_u32_dpp`, `v_ffbh_i32_dpp`. - **Portable SM 6.0 semantics:** Swizzles `src0` as `uint` bits via `QuadReadAcrossX`, `QuadReadAcrossY`, `QuadReadAcrossDiagonal`, or uniform `QuadReadLaneAt` (selected via `WaveGetLaneIndex() & 3u`), staying valid across wave sizes 4 (WARP) through 64. Optional helpers (`dpp_mul_hi_u24`, `dpp_mul_hi_i24` using 12-bit limb splits without 64-bit integer shader requirements, and MSB-indexed `dpp_ffbh_u32`/`dpp_ffbh_i32`) are emitted only when used; existing shaders emit none of them. - **Strict fail-closed controls:** Rejects cross-quad `DPP8`, `row_*`/`wave_*` controls, partial masks (`row_mask`/`bank_mask != 0xf`), FP source modifiers (`-`/`|.|`), non-VGPR operands, WQM, and `vmcnt` hazards. - **Genuine 4-lane quad draw fixture:** `DPP_INT32_BODY` derives integer quad lane ID `{0, 1, 2, 3}` from `uv.x`/`uv.y`, exercises all 23 forms across 3 constant sets (including negative/extreme `i24` products, zero/all-ones bit scans, and shift counts `>= 32`), exports all 4 bytes of the 32-bit accumulator as exact `[0, 255]` integers, and checks 5 negative mutations. ## Verification Tested on Linux x86_64 (Python 3.13.5, LLVM 19.1.7, Clang 19.1.7) on top of `6549244`: - `python3 -B tests/pixel_aot_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM-19.so` — passed (controls, negative controls, and `llvm-mc -mcpu=gfx1013` assembly→DXBC/XDAT/XBCH/FSSM→disassembly→lowering parity for `DPP_INT32_BODY` and 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 23 `DPP16` and 23 `DPP8` forms against both `docs/coverage/gfx1013.tsv` and `docs/coverage/rdna2.tsv`. - Executed the actual generated HLSL (including verbatim `dpp_mul_hi_{u,i}24` and `dpp_ffbh_{u,i}32` helpers) for `DPP_INT32_BODY` and all 5 negative mutations on a 4-lane SIMT 2×2 pixel quad C++20 harness with `clang++-19 -std=c++20 -O2 -Wall -Wextra -Wpedantic -Werror -fsanitize=undefined,address` — bit-exact match across all 4 quad lanes on all 3 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 quad readback. ## Evidence and follow-up - All new test fixtures in `tests/pixel_aot_check.py` are original MIT-licensed `gfx1013` 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) and DirectX Shader Model 6.0 quad-intrinsic specification. - Complements #408 (20 `f32`/move/select `DPP16`/`DPP8` forms) with zero opcode overlap; remaining `f16` and conversion `v_*_dpp` forms stay rejected here for separate focused PRs. - 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:55 +00:00
KomaGuy commented 2026-11-24 06:48:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KomaGuy on 2026-11-22T11:56:43Z.


Refreshed #414 onto current main (96e836d, reusing #408's shared dpp_vgpr / parse_dpp / emit_quad_swizzle_u32 helpers and compile_shader); all 4 CI checks pass. Holding off on refreshing #419, #421, #423, and #428 until this lands.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7078770982 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/414#issuecomment-7078770982). Originally posted by [KomaGuy](https://github.com/KomaGuy) on 2026-11-22T11:56:43Z. --- Refreshed #414 onto current `main` (`96e836d`, reusing #408's shared `dpp_vgpr` / `parse_dpp` / `emit_quad_swizzle_u32` helpers and `compile_shader`); all 4 CI checks pass. Holding off on refreshing #419, #421, #423, and #428 until this lands.
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!408
No description provided.