Skip to content

shader: lower quad-local DPP16 and DPP8 v_movrel ops in pixel_aot - #428

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

KomaGuy wants to merge 2 commits into
R0Y00:mainfrom
KomaGuy:shader/dpp-quad-movrel-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 four relative VGPR-indexing move instructions in tools/pixel_aot.py, covering the final 4 DPP16 and 4 DPP8 forms (+8 forms on both gfx1013 and gfx1030):

  • Supported v_*_dpp instructions (4): v_movreld_b32_dpp, v_movrels_b32_dpp, v_movrelsd_b32_dpp, and v_movrelsd_2_b32_dpp.
  • Static & runtime-dynamic m0 indexing:
    • Resolves static m0 immediates directly (VGPR[dst + m0], VGPR[src + m0], or split src + m0[9:0] / dst + m0[25:16] on v_movrelsd_2_b32_dpp).
    • Tracks scalar possible-ones bitmasks across s_bfe_u32, s_and_b64, s_or_b64, s_lshl_b64, s_lshr_b64, and s_mov_b32 so runtime-dynamic m0 offsets proven bounded (up to 16 reachable slots, all initialized and in 0..255) lower to conditional VGPR selects and per-slot conditional updates (reading all reachable sources before updating destinations, supporting overlapping source/destination banks).
    • Swizzles the selected 32-bit word via portable SM 6.0 quad intrinsics (QuadReadAcross*, QuadReadLaneAt, WaveGetLaneIndex() & 3u), emitting zero extra helper functions for existing shaders.
    • Rejects m0 still holding interp_base, unbounded or overly wide dynamic m0, out-of-range or uninitialized reachable VGPRs, source modifiers (-/|.|), cross-quad DPP8, row_*/wave_*, partial masks, non-VGPR operands, WQM, and vmcnt / sample_dest hazards.
  • Genuine 4-lane quad fixture: DPP_MOVREL_BODY derives quad coordinates from uv.x/uv.y, tests all 4 forms across both DPP16 and DPP8 with both runtime-dynamic m0 (different VGPR indices across 2 constant sets on one compiled shader) and static m0, and verifies 5 negative mutations.

Verification

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

  • 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_MOVREL_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 4 DPP16 and 4 DPP8 forms against both docs/coverage/gfx1013.tsv and docs/coverage/rdna2.tsv.
  • Executed the actual generated HLSL for DPP_MOVREL_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: v_movrel* 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. This is the first Windows/hardware coverage for the dynamic-VGPR-indexing forms.

PR head: 5654af9e70b7e109d80860060fd96c333f62d8ef (single commit on ac48a50, 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/428/head:pr-428; git worktree add out/wt-428 pr-428
Set-Location out/wt-428; .\tools\dev.ps1 | Out-Null; $ErrorActionPreference='Continue'
cmake --preset dev -B out/build/dev-428 "-DINTAKE_PYTHON=C:/Users/james/Documents/Xbox2Windows/out/pe-env/Scripts/python.exe"
cmake --build out/build/dev-428                                          # 387/387 targets, 0 errors
ctest --test-dir out/build/dev-428 --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-428 --no-tests=error -R '^pixel_aot_hardware$' --output-on-failure
$env:XBOX2WINDOWS_ADAPTER='RTX 5060 Ti'; ctest --test-dir out/build/dev-428 --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.11 s) pixels=4096 channels=16384 max_absolute_error=0
AMD RX 9060 XT (driver 32.0.32029.2010) 64 pixel_aot_hardware: Passed (23.05 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 with_constants(DPP_MOVREL_BODY): gfx1013 assembly → DXBC/XDAT/XBCH/FSSM → disassembly → lowering parity passed alongside all pre-existing fixtures.
  • The draw run's FORM_COVERAGE_RECORD confirms all four new opcodes translated on every backend: v_movreld_b32_dpp v_movrels_b32_dpp v_movrelsd_b32_dpp v_movrelsd_2_b32_dpp (both the runtime-dynamic-m0 and static-m0 constant sets exercised by the fixture).
  • 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.

Wave-width verdict

The wave-width-independence claim holds on silicon as measured for the dynamic-VGPR-indexing forms: bit-exact readback (max_absolute_error=0 over 16384 channels) on all three native widths (WARP 4, RTX 5060 Ti 32, RX 9060 XT 64) — i.e. the QuadReadAcross* / QuadReadLaneAt-based conditional-select lowering behaves identically whether the quad occupies a full wave (WARP width 4), a quarter wave (RDNA4 wave 64), or half a Blackwell wave (width 32). Everything above was measured on this box except the native wave-width labels themselves, which are platform facts for these adapters.

#421 (conversions) and #423 (extra f32/carry/dot) were verified in separate worktrees; separate comments posted there.

AI-assisted; runs executed locally.

@thepatrickworld

Copy link
Copy Markdown
Contributor

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

Why this adapter matters for these forms

Your lowering turns quad-local DPP16/DPP8 relative moves into QuadReadAcross*, QuadReadLaneAt and WaveGetLaneIndex() & 3u. The RX 9070 XT is a native wave64 part, not wave32, so the quad-intrinsic path is exercised under a different lane topology than your adapter. That is the specific thing this run adds; it is not just a repeat of your numbers.

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 2d16598.

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 #184: pixel_aot_hardware ... Passed
2/2 Test #191: pixel_aot_warp ..... Passed
Total Test time (real) = 37.55 sec
  • 111 draw cases on hardware per backend: 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 case reported a non-zero absolute error on either backend.

What it establishes

The static and runtime-dynamic m0 resolution, the split m0[9:0] / m0[25:16] destination path on v_movrelsd_2_b32_dpp, and the refusal set (unbounded m0, out-of-range or uninitialised indexed VGPRs, cross-quad DPP8, row_*/wave_*, partial masks, WQM) behave identically on a wave64 adapter, where WaveGetLaneIndex() & 3u has to select the same quad as on wave32.

The negative mutations built into DPP_MOVREL_BODY are part of the same run and did not fire, so the fixtures are still discriminating.

Limit

The harness prints per-draw counters but no per-program label, so this is a whole-suite result: I can say every one of the 111 draws matched with zero absolute error, not which line of output belongs to which of the four instructions.

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 on the v_movrel* forms! Holding this branch in place until the earlier DPP PRs land, then I'll refresh onto main.

@FZNull

FZNull commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Independent Windows verification on a physical GPU (the PR author verified only on Linux and left Windows to CI). I trial-merged this PR onto main and ran the draws here.

Merge state: conflicts against current main (5a2c782) in docs/experiments.md and tests/pixel_aot_check.py, both from additive hunks landing on the same regions (main gained #477/#475/#471 content there). tools/pixel_aot.py merged cleanly. I resolved the two hunks locally for measurement only; nothing was pushed. The PR needs a rebase to be mergeable (mergeable_state: dirty).

Environment: Windows 11 build 26300.9974, NVIDIA GeForce RTX 4060, driver 32.0.16.2124, debug layer unavailable, MSVC 19.50.35726, Windows SDK 10.0.26100.0, DXC 1.9.2609.5, Python 3.13.12.

Build: 881/881 targets, exit 0.

Check Result
pixel_aot_warp PASS, 12.65 s, max_absolute_error=0
pixel_aot_hardware Draw passes: exit 0, max_absolute_error=0 for every case. ctest reports Timeout because the test's TIMEOUT property is 60 s and the draw takes 61.2 s on this machine (see #448).
tests/rdna2_tools_check.py PASS
tests/form_coverage_check.py PASS

The four new forms do run in the hardware draw: FORM_COVERAGE_RECORD contains v_movreld_b32_dpp, v_movrels_b32_dpp, v_movrelsd_b32_dpp and v_movrelsd_2_b32_dpp, matching the four DPP16/DPP8 forms this PR declares.

The timeout is not a mismatch — the same test needs about 59 s on this adapter on unmodified main and crosses the 60 s limit once the extra draw cases are added. Raising or removing the per-test TIMEOUT, or landing the batch-device mode proposed in #448, would let the hardware job report the result instead of a timeout.

Verdict on behavior: the new DPP16/DPP8 v_movrel* lowering produces correct pixels on RTX 4060 hardware and WARP at this commit. The blocker for merging is the rebase, not the DQ.

AI-assisted.

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