ffx: reject unsupported ALU and packed modifiers in dispatch AOT #562

Merged
Neoplayer merged 1 commit from upstream-pr/568 into main 2026-11-22 13:18:11 +00:00
Neoplayer commented 2026-11-22 12:47:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Neoplayer on 2026-11-22T12:47:42Z.


Change

Reject unsupported or silently dropped instruction modifiers in tools/ffx_dispatch_aot.py instead of emitting incorrect HLSL:

  • In packed_op(), parse mods.split() strictly: reject unknown tokens, duplicate modifiers, mismatched op_sel/op_sel_hi/neg_lo/neg_hi vector lengths, and clamp on integer (_u16) packed ops (where saturate(...) was previously emitted).
  • In alu(), reject FLOAT modifiers other than "" and "mul:2" (such as clamp, mul:4, div:2, or combined clamp mul:2), and reject non-empty mods on non-FLOAT ops other than dot4_i32_i8.
  • Split clamp followed by another modifier (clamp(?: |$)) in predecessor() and translate().

Adds gfx1013 llvm-mc positive and negative modifier controls in tests/ffx_dispatch_aot_check.py.

Verification

  • Base commit: d3586dd
  • Host: macOS 26.5.1 (arm64), Python 3.12.13 (out/pe-env), Homebrew LLVM 15.0.7 (llvm@15)
  • Commands and results (LLVM="$(brew --prefix llvm@15)"):
    • ./out/pe-env/bin/python -B tests/ffx_dispatch_aot_check.py "$LLVM/bin/llvm-mc" "$LLVM/bin/llvm-objcopy" "$LLVM/lib/libLLVM-15.dylib" -> exit 0
    • ./out/pe-env/bin/python -B tests/pixel_aot_check.py binary "$LLVM/bin/llvm-mc" "$LLVM/bin/llvm-objcopy" "$LLVM/lib/libLLVM-15.dylib" -> exit 0
    • ./out/pe-env/bin/python -B tests/bidi_controls_check.py -> Self-test passed. Checked 549 tracked source, script and build/CI files: no bidirectional controls.
    • git diff --check -> exit 0
  • Not run locally: Windows DXC compilation and D3D12/WARP FFX/conversion dispatch tests require x64 Windows and are deferred to CI (build-and-test).

Evidence and follow-up

All new controls in tests/ffx_dispatch_aot_check.py are original inline gfx1013 assembly snippets assembled with llvm-mc and synthetic instruction lines under the repository's MIT license.

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. (N/A — no build requirements changed)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6542564653 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/568). Originally posted by [Neoplayer](https://github.com/Neoplayer) on 2026-11-22T12:47:42Z. --- ## Change Reject unsupported or silently dropped instruction modifiers in `tools/ffx_dispatch_aot.py` instead of emitting incorrect HLSL: - In `packed_op()`, parse `mods.split()` strictly: reject unknown tokens, duplicate modifiers, mismatched `op_sel`/`op_sel_hi`/`neg_lo`/`neg_hi` vector lengths, and `clamp` on integer (`_u16`) packed ops (where `saturate(...)` was previously emitted). - In `alu()`, reject `FLOAT` modifiers other than `""` and `"mul:2"` (such as `clamp`, `mul:4`, `div:2`, or combined `clamp mul:2`), and reject non-empty `mods` on non-`FLOAT` ops other than `dot4_i32_i8`. - Split `clamp` followed by another modifier (`clamp(?: |$)`) in `predecessor()` and `translate()`. Adds `gfx1013` `llvm-mc` positive and negative modifier controls in `tests/ffx_dispatch_aot_check.py`. ## Verification - Base commit: `d3586dd` - Host: macOS 26.5.1 (`arm64`), Python 3.12.13 (`out/pe-env`), Homebrew LLVM 15.0.7 (`llvm@15`) - Commands and results (`LLVM="$(brew --prefix llvm@15)"`): - `./out/pe-env/bin/python -B tests/ffx_dispatch_aot_check.py "$LLVM/bin/llvm-mc" "$LLVM/bin/llvm-objcopy" "$LLVM/lib/libLLVM-15.dylib"` -> exit 0 - `./out/pe-env/bin/python -B tests/pixel_aot_check.py binary "$LLVM/bin/llvm-mc" "$LLVM/bin/llvm-objcopy" "$LLVM/lib/libLLVM-15.dylib"` -> exit 0 - `./out/pe-env/bin/python -B tests/bidi_controls_check.py` -> `Self-test passed. Checked 549 tracked source, script and build/CI files: no bidirectional controls.` - `git diff --check` -> exit 0 - Not run locally: Windows DXC compilation and D3D12/WARP FFX/conversion dispatch tests require x64 Windows and are deferred to CI (`build-and-test`). ## Evidence and follow-up All new controls in `tests/ffx_dispatch_aot_check.py` are original inline `gfx1013` assembly snippets assembled with `llvm-mc` and synthetic instruction lines under the repository's MIT license. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. (N/A — no build requirements changed) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:43:43 +00:00
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!562
No description provided.