Skip to content

shader: lower quad-local DPP16 and DPP8 extra f32, carry, and dot ops in pixel_aot - #423

Open
KomaGuy wants to merge 3 commits into
R0Y00:mainfrom
KomaGuy:shader/dpp-quad-extra-f32-co
Open

KomaGuy wants to merge 3 commits into
R0Y00:mainfrom
KomaGuy:shader/dpp-quad-extra-f32-co

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 the remaining 12 extra f32, carry-in/carry-out u32, and gfx1030 dot-accumulate instructions in tools/pixel_aot.py, covering 12 additional DPP16 and 12 additional DPP8 forms on gfx1013 (+24 forms) and 11 additional DPP16 and 11 additional DPP8 forms on gfx1030 (+22 forms; v_mac_f32_dpp is gfx1013-only):

  • Supported v_*_dpp instructions (12):
    • Extra f32 unary & accumulate (7): v_rndne_f32_dpp, v_sin_f32_dpp, v_cos_f32_dpp, v_rcp_iflag_f32_dpp, v_frexp_mant_f32_dpp, v_frexp_exp_i32_f32_dpp, v_mac_f32_dpp.
    • Carry-in / carry-out u32 (3): v_add_co_ci_u32_dpp, v_sub_co_ci_u32_dpp, v_subrev_co_ci_u32_dpp (reading and updating the tracked vcc / vcc_lo per-lane condition).
    • Packed dot-accumulate (gfx1030, 2): v_dot2c_f32_f16_dpp and v_dot4c_i32_i8_dpp.
  • RDNA 2 semantics & portable SM 6.0 lowering: Swizzles src0 as uint bits through SM 6.0 quad intrinsics, handles frexp subnormals purely with bitwise firstbithigh (immune to desktop denormal flushing), applies DPP16 -/|.| modifiers on floating-point and packed f16x2 (v_dot2c_f32_f16_dpp) operands, emits optional helpers only when used, and rejects modifiers on DPP8 or integer ops, cross-quad DPP8, row_*/wave_*, partial masks, non-VGPR operands, uninitialized accumulators, untracked/mismatched vcc, WQM, and vmcnt hazards.
  • Genuine 4-lane quad fixtures: DPP_EXTRA_BODY (assembled on gfx1013, 2 constant sets, 5 negative mutations) and DPP_DOTC_BODY (assembled on gfx1030, 2 constant sets, 4 negative mutations) derive quad coordinates from uv.x/uv.y and exercise all 12 forms end to end.

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, gfx1013 assembly→DXBC/XDAT/XBCH/FSSM→disassembly→lowering parity for DPP_EXTRA_BODY and all existing fixtures, and gfx1030 parity for DPP_DOTC_BODY).
  • 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 12 DPP16 + 12 DPP8 forms against docs/coverage/gfx1013.tsv and 11 DPP16 + 11 DPP8 forms against docs/coverage/rdna2.tsv.
  • Executed the actual generated HLSL (with verbatim generated helpers) for DPP_EXTRA_BODY, DPP_DOTC_BODY, all 9 negative mutations, and frexp subnormal/±0/±Inf/NaN edge cases 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 and all 9 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: extra f32 / carry / dot-accumulate DPP 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: b7bb9d1e8de3e7a3107d2f8b41fd6ad18a30cdbe (single commit on e5e0079, 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/423/head:pr-423; git worktree add out/wt-423 pr-423
Set-Location out/wt-423; .\tools\dev.ps1 | Out-Null; $ErrorActionPreference='Continue'
cmake --preset dev -B out/build/dev-423 "-DINTAKE_PYTHON=C:/Users/james/Documents/Xbox2Windows/out/pe-env/Scripts/python.exe"
cmake --build out/build/dev-423                                          # 373/373 targets, 0 errors
ctest --test-dir out/build/dev-423 --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-423 --no-tests=error -R '^pixel_aot_hardware$' --output-on-failure
$env:XBOX2WINDOWS_ADAPTER='RTX 5060 Ti'; ctest --test-dir out/build/dev-423 --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 (4.45 s) pixels=4096 channels=16384 max_absolute_error=0
AMD RX 9060 XT (driver 32.0.32029.2010) 64 pixel_aot_hardware: Passed (24.35 s default; explicit re-run also Passed) pixels=4096 channels=16384 max_absolute_error=0
NVIDIA RTX 5060 Ti (driver 32.0.16.2124) 32 pixel_aot_hardware: Passed 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 both new fixtures (with_constants(DPP_EXTRA_BODY) gfx1013 and with_constants(DPP_DOTC_BODY) gfx1030): assembly → DXBC/XDAT/XBCH/FSSM → disassembly → lowering parity passed alongside all pre-existing fixtures.
  • The draw run's FORM_COVERAGE_RECORD confirms all 12 new opcodes translated on every backend: v_rndne_f32_dpp v_sin_f32_dpp v_cos_f32_dpp v_rcp_iflag_f32_dpp v_frexp_mant_f32_dpp v_frexp_exp_i32_f32_dpp v_mac_f32_dpp v_add_co_ci_u32_dpp v_sub_co_ci_u32_dpp v_subrev_co_ci_u32_dpp v_dot2c_f32_f16_dpp v_dot4c_i32_i8_dpp — exactly the 12 forms listed in the PR body, including both gfx1030 dot-accumulate forms.
  • No pixel_aot_* skips on any backend; capability skips outside this group (bvh_wave64_*, wave_shuffle_warp) did not occur here.
  • First mismatch: none — zero mismatches on any backend; nothing to quote. Of particular interest on this box: the vcc-tracking carry forms (v_add_co_ci_u32_dpp etc.) and the frexp bitwise-subnormal path were bit-exact on desktop GPUs that flush FTZ in other contexts — no denormal-flushing divergence observed.

Wave-width verdict

The wave-width-independence claim 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.

#421 (conversions) and #428 (v_movrel*) were verified in separate worktrees; separate comments posted there.

AI-assisted; runs executed locally.

@JB2WIN

JB2WIN commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

@KomaGuy, a quick coordination question so we don't overlap: this PR adds the DPP16/DPP8 forms of v_dot2c_f32_f16 and v_dot4c_i32_i8, but as far as I can see the plain VOP2 e32 forms (v_dot2c_f32_f16_e32, v_dot4c_i32_i8_e32) are still rejected on main. Do you plan to add them here or in a follow-up? If not, I'd add them after this lands, reusing your dpp_dot4c_i32_i8 / dot2c helpers rather than adding parallel ones. I'll hold off until you reply.

This comment is AI-assisted.

@KomaGuy

KomaGuy commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

@KomaGuy, a quick coordination question so we don't overlap: this PR adds the DPP16/DPP8 forms of v_dot2c_f32_f16 and v_dot4c_i32_i8, but as far as I can see the plain VOP2 e32 forms (v_dot2c_f32_f16_e32, v_dot4c_i32_i8_e32) are still rejected on main. Do you plan to add them here or in a follow-up? If not, I'd add them after this lands, reusing your dpp_dot4c_i32_i8 / dot2c helpers rather than adding parallel ones. I'll hold off until you reply.

This comment is AI-assisted.

Thanks for checking! I'm away from my PC for the next ~4 hours, so I'll add the plain VOP2 e32 forms to this PR once I'm back.

@MarlomMedeiros MarlomMedeiros left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran the Windows gates the author could not (Linux-only environment) on Windows 11 build 26300.10075, RTX 5070 (10de:2f04) driver 32.0.16.2135, in-box WARP 10.0.26100.10068, debug layer enabled.

Results:

  • tests/pixel_aot_check.py controls (run inside binary mode): pass. tests/form_coverage_check.py: pass. LLVM 15 gfx1013 binary round-trip: pass.
  • pixel_aot_warp under ctest: pass (12.3s, debug_errors=0).
  • pixel_aot_hardware: the complete draw suite passes on the RTX 5070 when run directly, python -B tests/pixel_aot_check.py draw <dxc> offscreen_check.exe hardware: 113 renderer runs, every one max_absolute_error=0, debug_errors=0 debug_warnings=0, including the new dpp_extra and dpp_dotc fixtures with all negative mutations reporting pixel_mismatch. Total wall time ~61s.

One non-code flag: the same run under ctest reports Timeout, because this branch's set_tests_properties(pixel_aot_hardware ... TIMEOUT 60) is 60s and the suite needs ~61s on this adapter. Not a correctness issue: current main splits draw modes so each registered test fits, and a rebase onto it resolves the bookkeeping.

Semantic review of the new code:

  • The co_ci ops model carry-in conservatively: carry-out must equal carry-in (vcc/vcc_lo) and scalar["vcc"] must hold a tracked ("condition", expr, 0, 1) tuple. The carry/borrow formulas (t < a || r < t for add, a < b || t < ci for sub, mirrored for subrev) are correct for two-step carry propagation.
  • v_dot2c_f32_f16_dpp applies abs/neg at the packed halfword level (0x7fff7fff / 0x80008000) and accumulates dst's prior value; v_dot4c_i32_i8_dpp sign-extends each byte lane with <<24 >>24 arithmetic shifts. Both match ISA semantics.
  • v_mac_f32_dpp correctly reads dst before writing (mad(a, b, acc)), and dpp_extra_vgpr rejects non-VGPR operands and uninitialized destinations.
  • mods_ok = is_dpp16 and allow_fp_mods enforces both ISA rules at once: DPP8 never takes source modifiers, and integer ops never take fp modifiers.
  • frexp helpers are bit-exact (subnormal normalization via firstbithigh, inf/NaN/zero passthrough, exponent forced to 0.5<=m<1), consistent with the existing f32 frexp/ldexp approach.
  • Interaction with #651: all new _dpp mnemonics are auto-denied inside exec-masked regions by the existing _dpp pattern, which is correct since quad-local ops are not pure per-lane.

Base note: this branch sits on a8e2d39 and carries its own dpp_extra_vgpr/parse_dpp_suffix/emit_quad_swizzle_u32; current main already has dpp_vgpr/parse_dpp/emit_quad_swizzle_u32 plus the dpp and dpp_int32 fixtures, so the rebase will want to fold DPP_EXTRA onto the upstream helpers rather than keep parallel copies.

No blockers on the change itself.

AI-assisted: yes. All reported checks ran locally on the adapter and driver listed.

@KomaGuy

KomaGuy commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Added the plain VOP2 e32 dot-accumulate forms (v_dot2c_f32_f16_e32 and v_dot4c_i32_i8_e32) and refreshed onto main (b5509fe) in df675d7:

  • @JB2WIN: Both v_dot2c_f32_f16_e32 and v_dot4c_i32_i8_e32 (accepting both _e32 and bare spellings, VGPR/SGPR/literal/inline src0 with VGPR vsrc1, reusing dot_word, dpp_vgpr, and dpp_dot4c_i32_i8) are now lowered, exercised in DPP_DOTC_BODY (gfx1030 binary round-trip + draw + 2 new e32 mutations), and covered by positive/negative controls.
  • @MarlomMedeiros: Thanks for the RTX 5070 + debug-layer verification and semantic review! This refresh removes the duplicate dpp_extra_vgpr/parse_dpp_suffix/emit_quad_swizzle_u32 copies in favor of the shared upstream helpers, pulls in main's split draw tests (fixing the 60s ctest budget), and compiles check_dpp_extra_draw with mode="any" + flush_ftz assertion (matching curve and shader: hoist DPP quad swizzles and use mode="any" for dpp fixture #569).

All 4/4 CI checks are green (df675d7).

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.

5 participants