Skip to content

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

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

R0Y00 merged 4 commits into
R0Y00:mainfrom
KomaGuy:shader/dpp-quad-f32-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 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.

@KomaGuy

KomaGuy commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

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.

@R0Y00
R0Y00 enabled auto-merge (squash) November 22, 2026 11:19
@R0Y00
R0Y00 merged commit aefed61 into R0Y00:main Nov 22, 2026
4 checks passed
@Leyukaka

Copy link
Copy Markdown
Contributor

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.

@KomaGuy

KomaGuy commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

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

3 participants