Skip to content

gfx2hlsl: accept float neg/abs sources on pixel-stage DPP quad swaps (Part of #1723) - #2559

Merged
tedin7 merged 3 commits into
R0Y00:mainfrom
lambirou:startup/gfx2hlsl-dpp-swap-omod
Nov 25, 2026
Merged

tedin7 merged 3 commits into
R0Y00:mainfrom
lambirou:startup/gfx2hlsl-dpp-swap-omod

Conversation

@lambirou

Copy link
Copy Markdown
Contributor

Problem

Startup pixel-stage DPP16 quad swaps (v_mov_b32_dpp and the VOP2 float forms) refused a source carrying the neg/abs modifier (-vN, |vN|). The disassembler already prints those bits for the float forms, so a shader that uses them stopped translation.

Change

  • In dpp(), the binary32 path accepts -vN, |vN| and -|vN| on VGPR sources. The permuted word is read from the neighbour lane first (QuadReadAcross*), then the modifier applies, matching RDNA 2 ISA 12.19 and LLVM 15's _dpp spelling.
  • Integer sources, SGPR sources, non-VGPR operands and every other modifier stay refused, under the same whole-quad requirement.
  • tests/startup_gfx2hlsl_dpp_quad_swap_check.py now asserts that -v0 negates the neighbour word and |v0| takes its absolute value, and keeps an integer -v0 refused.
  • Note in docs/experiments.md.

Verification

python -B tests/startup_gfx2hlsl_dpp_quad_swap_check.py   # PASS
python -B tests/docs_links_check.py                        # 19 files, 479 links
git diff --check                                           # clean

Rebased on 20725622.

Limits

  • No binary round-trip or GPU draw of the modified forms yet: this host has no llvm-mc or DXC, so the existing swap binary/draw modes still cover the unmodified fixtures only. GPU behavior of the modifiers is not claimed here.

Refs #1723.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review of head 4d0dda0 against current main (comment only).

What looks right

  • tools/startup/gfx2hlsl.py dpp(): for the float path the permuted word is read with QuadReadAcross* first, then abs, then neg are applied. That order matches the ISA text cited in the PR. The abs then neg nesting also gives -|vN| correctly.
  • Integer sources, SGPR sources and non-VGPR bases are still refused. The whole-quad / exec checks are unchanged.
  • The src1 operand goes through self.f(...), so it keeps its own modifier handling.

What is missing before this can merge

  • The new test only checks the generated HLSL text (and that an integer -v0 is refused). The repo rule for shader/math lowerings is a real D3D12 WARP GPU readback compared with a CPU reference, not string checks alone. The PR's own "Limits" section says the binary and draw modes cover only the unmodified fixtures. Please add a -v0 and a |v0| case to the existing swap draw/readback fixture and show it passes on WARP (including a lane whose neighbour value is negative, so abs and neg are not no-ops).
  • Small note: the destination operand (ops[0]) is no longer checked by the v\d+ regex on the float path. A modifier on the destination should still be refused. A one-line check plus a test would close that.

Checks run locally on a clean worktree of this head

  • python3 -B tests/startup_gfx2hlsl_dpp_quad_swap_check.py -> PASS
  • python3 tests/docs_links_check.py -> 19 files, 487 links
  • python3 tests/bidi_controls_check.py -> clean
  • git diff --check origin/main...HEAD -> clean
  • Mutation 1: drop the neg wrap -> test FAILS ("-v0 negates the neighbour word"). Mutation 2: drop the abs wrap -> test FAILS ("|v0| takes abs"). So the text test does guard the lowering, but it does not prove GPU behavior.

I did not run Win2025 for this head and did not merge. Merge stays blocked until the WARP readback test exists.

AI-assisted; commands listed were executed locally.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review of head 3248960 against current main (comment only).

What looks right

  • tools/startup/gfx2hlsl.py dpp(): float path reads the neighbour lane first (QuadReadAcross*), then abs, then neg. Integer, SGPR and destination-modifier forms stay refused.
  • The test now has a real binary round-trip (llvm-mc words) and a D3D12 draw with readback against a quad reference, wired into .github/workflows/windows.yml. Three control draws each omit one modifier and must fail the readback, so the draw really guards neg, abs and neg-abs.
  • No other open or merged PR covers float neg/abs on pixel-stage DPP quad swaps (searched dpp neg abs).

Commands run in a local worktree

  • python3 -B tests/startup_gfx2hlsl_dpp_quad_swap_check.py : PASS (the llvm-mc and DXC modes are skipped on Linux, they run in the Windows CI job)
  • python3 -B tests/docs_links_check.py : ok, 19 files, 487 links
  • python3 -B tests/bidi_controls_check.py : ok
  • git diff --check origin/main...HEAD : clean
  • Mutation: dropping the neg wrapper makes the check fail; dropping the abs wrapper makes it fail. Both restored.

Care note: .github/workflows/windows.yml gains one line; the PR's own Windows CI run must execute it.

AI-assisted; commands listed were executed locally.

R0Y00 commented Nov 25, 2026

Copy link
Copy Markdown
Owner

32489609 adds a signed-normal DPP fixture and restores rejection of a modified destination. The Windows Release controls and draws passed 3/3 on WARP and RTX 4060 Laptop. Each of the 256 pixels matched the three neighbour channels (NEG, ABS, NEG+ABS); dropping each modifier separately changed the readback. The new gfx1013 assembly comparison runs in Linux CI.

@tedin7

tedin7 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Win2025 WARP receipt for head d853584 after updating with main.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit d853584ae0928d799831c34cd6add59f88dae1fe:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2): 0.29s (configure 0.00s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2): 0.27s (configure 0.00s)
  • Windows Python checks: tests/startup_gfx2hlsl_dpp_quad_swap_check.py ok (0.1s), tests/startup_gfx2hlsl_swap_check.py ok (0.3s)
  • Wall: 6.9s

Note: only the plain Python mode of the DPP check ran on the VM (0.1s); the llvm-mc binary and D3D12 draw modes run in the PR's own Windows CI job.

AI-assisted; commands listed were executed locally.

@tedin7
tedin7 merged commit 18f2f85 into R0Y00:main Nov 25, 2026
5 checks passed
@lambirou
lambirou deleted the startup/gfx2hlsl-dpp-swap-omod branch November 25, 2026 23:30
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