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

Merged
lambirou merged 3 commits from upstream-pr/2559 into main 2026-11-25 21:25:08 +00:00
lambirou commented 2026-11-25 21:02:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-25T21:02:43Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6613694955 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2559). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-25T21:02:43Z. --- ## 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.
upstream-sync closed this pull request 2026-11-25 22:02:04 +00:00
tedin7 commented 2026-11-25 22:02:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:06:50Z.

Review: COMMENTED


Review of head 4d0dda0d 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6064989090 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2559#pullrequestreview-6064989090). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T21:06:50Z. **Review:** COMMENTED --- Review of head 4d0dda0d 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 commented 2026-11-25 22:02:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:21:36Z.

Review: COMMENTED


Review of head 32489609 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6065153272 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2559#pullrequestreview-6065153272). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T21:21:36Z. **Review:** COMMENTED --- Review of head 32489609 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 2026-11-25 22:02:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T21:23:03Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7175003643 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2559#issuecomment-7175003643). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T21:23:03Z. --- `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 commented 2026-11-25 22:02:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:24:57Z.


Win2025 WARP receipt for head d853584a 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7175045706 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2559#issuecomment-7175045706). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T21:24:57Z. --- Win2025 WARP receipt for head d853584a 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2551
No description provided.