shader: lower quad-local DPP16 and DPP8 f32/move/select ops in pixel_aot #402

Merged
KomaGuy merged 4 commits from upstream-pr/408 into main 2026-11-22 11:24:09 +00:00
KomaGuy commented 2026-11-22 00:36:56 +00:00 (Migrated from github.com)

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


Change

Lower quad-local DPP16 (quad_perm) and DPP8 (dpp8) forms for all 20 currently supported VOP1/VOP2 pixel operations in tools/pixel_aot.py, advancing coverage from 0/101 to 20/101 on DPP16 and 0/101 to 20/101 on DPP8 (+40 forms on both gfx1013 and gfx1030):

  • Supported v_*_dpp instructions (20): v_mov_b32_dpp, v_cvt_f32_f16_dpp, v_cndmask_b32_dpp, 9 unary f32 ops (log, exp, rcp, sqrt, rsq, floor, ceil, fract, trunc), and 8 binary/accumulate f32 ops (add, sub, subrev, mul, mul_legacy, min, max, fmac).
  • Portable SM 6.0 quad swizzling: Swizzles src0 as uint bits (asuint) through QuadReadAcrossX, QuadReadAcrossY, QuadReadAcrossDiagonal, or uniform QuadReadLaneAt (selected via WaveGetLaneIndex() & 3u), keeping subnormal/binary16 bit patterns intact and staying valid across wave widths 4 (WARP) through 64.
  • Strict fail-closed validation: Accepts quad_perm:[0..3,...] with row_mask:0xf bank_mask:0xf (plus optional bound_ctrl:[01]/fi:[01]) and quad-local dpp8:[p0..p3, p0+4..p3+4] (plus optional fi:[01]). Allows -/|.|/abs() modifiers on DPP16 floating-point ops and rejects them on DPP8, v_mov_b32_dpp, and v_cndmask_b32_dpp. Rejects cross-quad DPP8, row_*/wave_* controls, partial masks, non-VGPR operands, non-vcc select masks, WQM, and vmcnt hazards.
  • Genuine 4-lane quad draw fixture: DPP_BODY derives per-quad lane ID {0, 1, 2, 3} from interpolated uv.x/uv.y (v8/v9, while v_mov_b32_e32 keeps rejecting v8), tests all 20 forms across 2 constant sets with exact binary16 outputs immune to transcendental ULP differences, and verifies 6 negative mutations (AcrossX vs AcrossY, AcrossY vs AcrossX, cyclic dpp8 rotation, lane broadcast, DPP16 negation, and floor vs ceil).

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_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 20 DPP16 and 20 DPP8 forms against both docs/coverage/gfx1013.tsv and docs/coverage/rdna2.tsv.
  • Executed the actual generated HLSL for DPP_BODY and all 6 negative mutations on a 4-lane SIMT 2×2 pixel quad harness compiled as C++20 with clang++-19 -std=c++20 -O2 -Wall -Wextra -Wpedantic -Werror -fsanitize=undefined,address — bit-exact match across all 4 quad lanes on both constant sets and all 6 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.
  • Follow-up DPP16/DPP8 work: integer/bitwise/shift/conversion/f16 v_*_dpp forms once their corresponding base ops land or in focused follow-up 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:6536401724 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/408). Originally posted by [KomaGuy](https://github.com/KomaGuy) on 2026-11-22T00:36:56Z. --- ## Change Lower quad-local `DPP16` (`quad_perm`) and `DPP8` (`dpp8`) forms for all 20 currently supported `VOP1`/`VOP2` pixel operations in `tools/pixel_aot.py`, advancing coverage from `0/101` to `20/101` on `DPP16` and `0/101` to `20/101` on `DPP8` (+40 forms on both `gfx1013` and `gfx1030`): - **Supported `v_*_dpp` instructions (20):** `v_mov_b32_dpp`, `v_cvt_f32_f16_dpp`, `v_cndmask_b32_dpp`, 9 unary `f32` ops (`log`, `exp`, `rcp`, `sqrt`, `rsq`, `floor`, `ceil`, `fract`, `trunc`), and 8 binary/accumulate `f32` ops (`add`, `sub`, `subrev`, `mul`, `mul_legacy`, `min`, `max`, `fmac`). - **Portable SM 6.0 quad swizzling:** Swizzles `src0` as `uint` bits (`asuint`) through `QuadReadAcrossX`, `QuadReadAcrossY`, `QuadReadAcrossDiagonal`, or uniform `QuadReadLaneAt` (selected via `WaveGetLaneIndex() & 3u`), keeping subnormal/binary16 bit patterns intact and staying valid across wave widths 4 (WARP) through 64. - **Strict fail-closed validation:** Accepts `quad_perm:[0..3,...]` with `row_mask:0xf bank_mask:0xf` (plus optional `bound_ctrl:[01]`/`fi:[01]`) and quad-local `dpp8:[p0..p3, p0+4..p3+4]` (plus optional `fi:[01]`). Allows `-`/`|.|`/`abs()` modifiers on `DPP16` floating-point ops and rejects them on `DPP8`, `v_mov_b32_dpp`, and `v_cndmask_b32_dpp`. Rejects cross-quad `DPP8`, `row_*`/`wave_*` controls, partial masks, non-VGPR operands, non-`vcc` select masks, WQM, and `vmcnt` hazards. - **Genuine 4-lane quad draw fixture:** `DPP_BODY` derives per-quad lane ID `{0, 1, 2, 3}` from interpolated `uv.x`/`uv.y` (`v8`/`v9`, while `v_mov_b32_e32` keeps rejecting `v8`), tests all 20 forms across 2 constant sets with exact binary16 outputs immune to transcendental ULP differences, and verifies 6 negative mutations (`AcrossX` vs `AcrossY`, `AcrossY` vs `AcrossX`, cyclic `dpp8` rotation, lane broadcast, `DPP16` negation, and `floor` vs `ceil`). ## 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_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 20 `DPP16` and 20 `DPP8` forms against both `docs/coverage/gfx1013.tsv` and `docs/coverage/rdna2.tsv`. - Executed the actual generated HLSL for `DPP_BODY` and all 6 negative mutations on a 4-lane SIMT 2×2 pixel quad harness compiled as C++20 with `clang++-19 -std=c++20 -O2 -Wall -Wextra -Wpedantic -Werror -fsanitize=undefined,address` — bit-exact match across all 4 quad lanes on both constant sets and all 6 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. - Follow-up `DPP16`/`DPP8` work: integer/bitwise/shift/conversion/f16 `v_*_dpp` forms once their corresponding base ops land or in focused follow-up 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:53 +00:00
KomaGuy commented 2026-11-24 06:48:30 +00:00 (Migrated from github.com)

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


Refreshed #408 onto current main (075413d, preserving all merged VOP3P/SDWA/conversion draw suites and using the shared compile_shader helper); all 4 CI checks pass. Holding off on refreshing #414, #419, #421, #423, and #428 until this base lands.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7078060897 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/408#issuecomment-7078060897). Originally posted by [KomaGuy](https://github.com/KomaGuy) on 2026-11-22T10:51:28Z. --- Refreshed #408 onto current `main` (`075413d`, preserving all merged VOP3P/SDWA/conversion draw suites and using the shared `compile_shader` helper); all 4 CI checks pass. Holding off on refreshing #414, #419, #421, #423, and #428 until this base lands.
Leyukaka commented 2026-11-24 06:48:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-22T12:33:53Z.


Hardware result after this merge: pixel_aot_hardware fails on aefed61 at the first check_dpp_draw draw. pixel_aot_warp passes on the same build.

ctest --preset dev --no-tests=error -R '^pixel_aot_(hardware|warp)$' -V
  • Adapter: NVIDIA GeForce RTX 5080 (10de:2c02), driver 32.0.16.2101
  • Windows 11 build 26300.9974, debug layer unavailable
  • Commit: aefed61 fails; both tests pass on b515663, its parent commit
  • Result: 3 failures in 3 runs

The two check_render channel-order draws pass (max_absolute_error=0). Then the renderer reports:

Translated pixel pipeline failed (HRESULT 0x8007000e)

and subprocess.run(draw, check=True) raises in check_dpp_draw (tests/pixel_aot_check.py:2778, called from check_render at 4818). The HRESULT is E_OUTOFMEMORY, returned by CreateGraphicsPipelineState (tests/pixel_aot_render.cpp:99), so the draw fails before any pixel is compared. I have not narrowed it to a single v_*_dpp line.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7079197426 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/408#issuecomment-7079197426). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-22T12:33:53Z. --- Hardware result after this merge: `pixel_aot_hardware` fails on `aefed61` at the first `check_dpp_draw` draw. `pixel_aot_warp` passes on the same build. ```text ctest --preset dev --no-tests=error -R '^pixel_aot_(hardware|warp)$' -V ``` - Adapter: NVIDIA GeForce RTX 5080 (10de:2c02), driver 32.0.16.2101 - Windows 11 build 26300.9974, debug layer unavailable - Commit: `aefed61` fails; both tests pass on `b515663`, its parent commit - Result: 3 failures in 3 runs The two `check_render` channel-order draws pass (`max_absolute_error=0`). Then the renderer reports: ```text Translated pixel pipeline failed (HRESULT 0x8007000e) ``` and `subprocess.run(draw, check=True)` raises in `check_dpp_draw` (`tests/pixel_aot_check.py:2778`, called from `check_render` at 4818). The HRESULT is `E_OUTOFMEMORY`, returned by `CreateGraphicsPipelineState` (`tests/pixel_aot_render.cpp:99`), so the draw fails before any pixel is compared. I have not narrowed it to a single `v_*_dpp` line. AI-assisted.
KomaGuy commented 2026-11-24 06:48:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KomaGuy on 2026-11-22T12:55:46Z.


Thanks for the hardware measurement @Leyukaka! This matches the exact NVIDIA Blackwell driver exception recorded in #363 for the curve fixture (RTX 5060 Ti driver 32.0.16.2124 refused CreateGraphicsPipelineState with E_OUTOFMEMORY under -denorm preserve on curve, which uses log2/exp2/1.0f / x/mul_legacy, while passing under mode="any" and on WARP/AMD).

When #408 was refreshed onto #363, check_dpp_draw moved from ps_6_0 to compile_shader() (mode="preserve") and DPP_BODY uses those same operations (v_log_f32_dpp, v_exp_f32_dpp, v_rcp_f32_dpp, v_mul_legacy_f32_dpp). In addition, emit_quad_swizzle_u32 was inlining fast-path QuadRead* calls directly into v_mul_legacy_f32_dpp's ternary expression.

Opened #569 to:

  1. Compile check_dpp_draw with mode="any" and assert flush_ftz(word) == word on every expected word (matching curve), and
  2. Hoist non-identity QuadRead* calls into unconditional uint dpp{i}_s locals before any ternary expression.

If you have a moment to test #569 on your RTX 5080, that would confirm it clears the E_OUTOFMEMORY failure.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7079449066 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/408#issuecomment-7079449066). Originally posted by [KomaGuy](https://github.com/KomaGuy) on 2026-11-22T12:55:46Z. --- Thanks for the hardware measurement @Leyukaka! This matches the exact NVIDIA Blackwell driver exception recorded in #363 for the `curve` fixture (RTX 5060 Ti driver `32.0.16.2124` refused `CreateGraphicsPipelineState` with `E_OUTOFMEMORY` under `-denorm preserve` on `curve`, which uses `log2`/`exp2`/`1.0f / x`/`mul_legacy`, while passing under `mode="any"` and on WARP/AMD). When #408 was refreshed onto #363, `check_dpp_draw` moved from `ps_6_0` to `compile_shader()` (`mode="preserve"`) and `DPP_BODY` uses those same operations (`v_log_f32_dpp`, `v_exp_f32_dpp`, `v_rcp_f32_dpp`, `v_mul_legacy_f32_dpp`). In addition, `emit_quad_swizzle_u32` was inlining fast-path `QuadRead*` calls directly into `v_mul_legacy_f32_dpp`'s ternary expression. Opened #569 to: 1. Compile `check_dpp_draw` with `mode="any"` and assert `flush_ftz(word) == word` on every expected word (matching `curve`), and 2. Hoist non-identity `QuadRead*` calls into unconditional `uint dpp{i}_s` locals before any ternary expression. If you have a moment to test #569 on your RTX 5080, that would confirm it clears the `E_OUTOFMEMORY` failure.
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!402
No description provided.