Skip to content

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

Merged
R0Y00 merged 3 commits into
R0Y00:mainfrom
KomaGuy:shader/dpp-quad-int32-ops
Nov 22, 2026
Merged

R0Y00 merged 3 commits into
R0Y00:mainfrom
KomaGuy:shader/dpp-quad-int32-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 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

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.

@R0Y00
R0Y00 merged commit 3ba3472 into R0Y00:main Nov 22, 2026
4 checks passed
@KomaGuy

KomaGuy commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

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

2 participants