Skip to content

shader: lower quad-local DPP16 and DPP8 conversion ops in pixel_aot - #421

Open
KomaGuy wants to merge 2 commits into
R0Y00:mainfrom
KomaGuy:shader/dpp-quad-cvt-ops
Open

KomaGuy wants to merge 2 commits into
R0Y00:mainfrom
KomaGuy:shader/dpp-quad-cvt-ops

Conversation

@KomaGuy

@KomaGuy KomaGuy commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Change

Lower quad-local DPP16 (quad_perm) and DPP8 (dpp8) forms for all 19 conversion VOP1/VOP2 operations in tools/pixel_aot.py, covering 19 additional DPP16 and 19 additional DPP8 forms (+38 forms on both gfx1013 and gfx1030):

  • Supported v_*_dpp instructions (19):
    • Integer → float32 (7): v_cvt_f32_i32_dpp, v_cvt_f32_u32_dpp, v_cvt_f32_ubyte0_dpp, v_cvt_f32_ubyte1_dpp, v_cvt_f32_ubyte2_dpp, v_cvt_f32_ubyte3_dpp, v_cvt_off_f32_i4_dpp.
    • Float32 → integer (4): v_cvt_i32_f32_dpp, v_cvt_u32_f32_dpp, v_cvt_flr_i32_f32_dpp, v_cvt_rpi_i32_f32_dpp.
    • 16-bit integer ↔ float16 & normalized (6): v_cvt_f16_i16_dpp, v_cvt_f16_u16_dpp, v_cvt_i16_f16_dpp, v_cvt_u16_f16_dpp, v_cvt_norm_i16_f16_dpp, v_cvt_norm_u16_f16_dpp.
    • Packed conversions (2): v_sat_pk_u8_i16_dpp, v_cvt_pkrtz_f16_f32_dpp.
  • RDNA 2 semantics & portable SM 6.0 lowering: Swizzles src0 as uint bits via SM 6.0 quad intrinsics, preserves vdst[31:16] on all 7 16-bit destination forms per gfx1013 (rejecting uninitialized destination VGPRs), applies saturating integer conversions and deterministic pack16_rne/pack16_rtz helpers emitted only when used, allows -/|.| only on DPP16 float-input forms, and rejects integer-input modifiers, DPP8 modifiers, cross-quad DPP8, row_*/wave_*, partial masks, non-VGPR operands, WQM, and vmcnt hazards.
  • Genuine 4-lane quad draw fixture: DPP_CVT_BODY derives quad lane ID {0, 1, 2, 3} from uv.x/uv.y, tests all 19 forms across 2 constant sets, and checks 5 negative mutations (AcrossX vs AcrossY, cyclic dpp8 rotation, rpi vs flr, norm_i16 vs norm_u16, and DPP16 negation).

Verification

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

  • 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_CVT_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 19 DPP16 and 19 DPP8 forms against both docs/coverage/gfx1013.tsv and docs/coverage/rdna2.tsv.
  • Executed the actual generated HLSL (with verbatim generated helpers) for DPP_CVT_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 both 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

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.

@abilliontokens

Copy link
Copy Markdown
Contributor

Physical-silicon verification: DPP conversion forms pass on wave 4 / 32 / 64

Independent verification of the wave-width-independence claim ("valid across wave sizes 4 (WARP) through 64") that CI cannot cover (CI excludes _hardware tests). Measured on this dual-GPU Windows box.

PR head: 3b88c14f5e75d533971f086857ee68d205141667 (single commit on e5e0079, which is an ancestor of current main; PR mergeable/clean).

Environment

  • Windows 11 Pro, build 26200.9711
  • Toolchain via tools/dev.ps1 (VS 2022 BuildTools, MSVC 14.44.35207); venv Python for INTAKE_PYTHON
  • DXC: C:/Program Files (x86)/Windows Kits/10/bin/10.0.26100.0/x64/dxc.exe (Windows SDK 10.0.26100.0, CTest find_program)
  • debug_layer=unavailable on every backend (harness-reported); no debug-layer diagnostics available or claimed here
  • Backends (harness-reported adapter/driver lines):
    • WARP: adapter=Microsoft Basic Render Driver vendor=1414 device=008c, driver=10.0.26100.9711 — native wave width 4
    • adapter=AMD Radeon RX 9060 XT vendor=1002 device=7590, driver=32.0.32029.2010 — native wave width 64 (RDNA4)
    • adapter=NVIDIA GeForce RTX 5060 Ti vendor=10de device=2d04, driver=32.0.16.2124 — native wave width 32

Commands (exact)

git fetch origin pull/421/head:pr-421; git worktree add out/wt-421 pr-421
Set-Location out/wt-421; .\tools\dev.ps1 | Out-Null; $ErrorActionPreference='Continue'
cmake --preset dev -B out/build/dev-421 "-DINTAKE_PYTHON=C:/Users/james/Documents/Xbox2Windows/out/pe-env/Scripts/python.exe"
cmake --build out/build/dev-421                                          # 373/373 targets, 0 errors
ctest --test-dir out/build/dev-421 --no-tests=error -R '^pixel_aot_' --output-on-failure   # default adapter + WARP: 2/2 Passed
$env:XBOX2WINDOWS_ADAPTER='RX 9060 XT';  ctest --test-dir out/build/dev-421 --no-tests=error -R '^pixel_aot_hardware$' --output-on-failure
$env:XBOX2WINDOWS_ADAPTER='RTX 5060 Ti'; ctest --test-dir out/build/dev-421 --no-tests=error -R '^pixel_aot_hardware$' --output-on-failure
out/pe-env/Scripts/python.exe -B tests/pixel_aot_check.py binary out/tools/llvm-mc.exe out/tools/llvm15/bin/llvm-objcopy.exe out/tools/llvm15/bin/LLVM-C.dll

Results

Backend Native wave Result Readback
WARP 10.0.26100.9711 4 pixel_aot_warp: Passed pixels=4096 channels=16384 max_absolute_error=0
AMD RX 9060 XT (driver 32.0.32029.2010) 64 pixel_aot_hardware: Passed (22.98 s default run; 16.13 s explicit) pixels=4096 channels=16384 max_absolute_error=0
NVIDIA RTX 5060 Ti (driver 32.0.16.2124) 32 pixel_aot_hardware: Passed (22.06 s) pixels=4096 channels=16384 max_absolute_error=0
  • Binary round trip (LLVM 15.0.7 wrapper + llvm-objcopy + LLVM-C.dll): exit 0 — check_binary is assert-only/silent on success and includes with_constants(DPP_CVT_BODY), i.e. gfx1013 assembly → DXBC/XDAT/XBCH/FSSM → disassembly → lowering parity passed for this fixture alongside all pre-existing fixtures.
  • The draw run's FORM_COVERAGE_RECORD confirms all 19 new opcodes translated on every backend — exactly the 19 forms listed in the PR body: v_cvt_f32_i32_dpp v_cvt_f32_u32_dpp v_cvt_f32_ubyte0_dpp v_cvt_f32_ubyte1_dpp v_cvt_f32_ubyte2_dpp v_cvt_f32_ubyte3_dpp v_cvt_off_f32_i4_dpp v_cvt_i32_f32_dpp v_cvt_u32_f32_dpp v_cvt_flr_i32_f32_dpp v_cvt_rpi_i32_f32_dpp v_cvt_f16_i16_dpp v_cvt_f16_u16_dpp v_cvt_i16_f16_dpp v_cvt_u16_f16_dpp v_cvt_norm_i16_f16_dpp v_cvt_norm_u16_f16_dpp v_sat_pk_u8_i16_dpp v_cvt_pkrtz_f16_f32_dpp.
  • No pixel_aot_* skips on any backend (the bvh_wave64_* / wave_shuffle_warp capability skips are outside this group and did not occur here).
  • First mismatch: none — zero mismatches on any backend; nothing to quote.

Wave-width verdict

The claim that the quad-local DPP lowering is wave-width independent holds on silicon as measured: bit-exact readback (max_absolute_error=0 over 16384 channels × 2 constant sets) on all three native widths (WARP 4, RTX 5060 Ti 32, RX 9060 XT 64). Everything above was measured on this box except the native wave-width labels themselves, which are platform facts for these adapters (not re-derived by this harness run).

Note: this branch contains only this PR's own fixture (DPP_CVT_BODY), so this run measures #421's forms specifically. #423 and #428 were verified in separate worktrees (separate comments); #408/#414/#419 were not re-run here.

AI-assisted; runs executed locally.

@thepatrickworld

Copy link
Copy Markdown
Contributor

@KomaGuy Independent AMD (RDNA4, native wave64) result on 3c042c9. Measurements only, no code change.

Environment

  • Windows 11 25H2, build 26200.9711
  • MSVC 19.44.35230 (toolset 14.44.35207), Windows SDK 10.0.26100.0, DXC 1.9.2602.17
  • AMD Radeon RX 9070 XT, vendor 1002, device 7550, driver 32.0.32029.2010. native_wave_width=64 logical_width=64 measured in the same worktree (bvh_waves_hardware); the pixel_aot harness does not print the wave width itself.
  • debug_layer=unavailable (Tools.Graphics.DirectX is NotPresent here)
  • Clean worktree of the PR head 3c042c9.

Commands

cmake --preset dev
cmake --build --preset dev --parallel 12 --target offscreen_check
set XBOX2WINDOWS_ADAPTER=AMD Radeon RX 9070 XT
ctest --preset dev --no-tests=error -V -R "^pixel_aot_(hardware|warp)$"

Observed

1/2 Test: pixel_aot_hardware ... Passed
2/2 Test: pixel_aot_warp ....... Passed
Total Test time (real) = 36.30 sec
  • 111 draw cases on hardware: 110 at pixels=4096 channels=16384 and one at pixels=64 channels=256, every one max_absolute_error=0.
  • 111 draw cases on WARP in the same build, same split, max_absolute_error=0.
  • No non-zero absolute error on either backend.

Why an AMD result is worth having here

The conversions go through the same quad-local path (QuadReadAcross*, QuadReadLaneAt, WaveGetLaneIndex() & 3u). On a native wave64 part the lane-to-quad mapping has to produce the same source lane as on wave32, and rounding/conversion differences are exactly where a vendor-specific drift would show as a non-zero absolute error rather than a crash. None appeared: 16,384 channels per draw matched the CPU reference exactly on both backends.

Limit

The harness prints per-draw counters but no per-program label, so this is a whole-suite result: every one of the 111 draws matched, but I cannot attribute a given line of output to a specific conversion form.

AI-assisted; runs executed locally.

@KomaGuy

KomaGuy commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @thepatrickworld for the independent RX 9070 XT wave64 verification! Holding this branch in place until #419 lands, then I'll refresh onto main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants