shader: pin v_fma_mix half selection per source position #2798

Merged
RenzoWit35 merged 1 commit from upstream-pr/2806 into main 2026-11-26 11:09:54 +00:00
RenzoWit35 commented 2026-11-26 11:00:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RenzoWit35 on 2026-11-26T11:00:53Z.


Change

Adds test_vop3p_fma_mix_half_select_per_source_position to tests/rdna2_tools_check.py, next to the existing fma_mix test. No tool code changes: tools/pixel_aot.py and every other tool are untouched.

Refs #2103. When closing that PR the maintainer wrote: "Your test that isolates each source position is useful independently. Please rebase and keep that discriminator, removing the overlapping lowering. The merged parser rejects a half-select bit on a full-width input, so check the refusal class while keeping the swapped-source control."

For each source position (0, 1, 2) and for both v_fma_mix_f32 and v_fma_mixlo_f16 (v_fma_mixhi_f16 is covered by the existing test):

  • op_sel_hi alone widens the low half of that source only; the other sources stay binary32. Asserted on the exact lowered mad(...) text and on the parsed fields.
  • op_sel plus op_sel_hi on that source selects the high half of that source only (exact text). A variant with op_sel_hi:[1,1,1] and op_sel on one source checks that the half bit does not move to a neighbour.
  • op_sel alone is refused with ValueError matching "High-half selection requires an f16 operand", both from parse_fma_mix and through lower(), also when op_sel_hi is set on a different source.
  • Swapped-source control: the lowered text for a modifier at one position differs from the text at every other position, and low differs from high.

The test needs no LLVM: it feeds assembly text to lower(). It runs on Windows and in the Linux CI list (the file is already registered).

Verification

Commands from the worktree, with C:\XBOX2Windows\repo\out\pe-env\Scripts\python.exe -B:

  • Before: tests/rdna2_tools_check.py gave Ran 157 tests, OK (skipped=19).
  • After: Ran 158 tests, OK (skipped=19). The skips are LLVM-only tests.

Mutants of tools/pixel_aot.py (each applied by hand, then restored; git diff -- tools empty after each):

Mutant main's test_vop3p_fma_mix_inline_abs_neg_modifiers new test
1. lower() pairs op_sel[1] and op_sel[2] swapped passes (survives) FAILS (high-half cases, positions 1 and 2, both opcodes)
2. refusal in parse_fma_mix limited to positions 0 and 1 passes (survives) FAILS (op_sel alone at position 2, both opcodes, 2 failures)
3. zip(tokens, op_sel, op_sel_hi) plain swap in lower() fails (already caught) FAILS (7 failures)

Not run: tests/pixel_aot_check.py (needs LLVM and a GPU/WARP device; not touched), the full CTest suite.

Evidence and follow-up

Overlap: gh pr list --state open --search "fma_mix" shows only #2753 (gfx2hlsl) and #532 (integer multiplies), neither edits tests/rdna2_tools_check.py. Open PRs #1572 and #531 touch the file elsewhere (not near the fma_mix tests); the new method sits between the existing fma_mix test and test_mubuf_opcode_table_synthetic_forms. The immediate handling from #2100 (-0, -16..-1) is not touched.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6625196359 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2806). Originally posted by [RenzoWit35](https://github.com/RenzoWit35) on 2026-11-26T11:00:53Z. --- ## Change Adds `test_vop3p_fma_mix_half_select_per_source_position` to `tests/rdna2_tools_check.py`, next to the existing fma_mix test. No tool code changes: `tools/pixel_aot.py` and every other tool are untouched. Refs #2103. When closing that PR the maintainer wrote: "Your test that isolates each source position is useful independently. Please rebase and keep that discriminator, removing the overlapping lowering. The merged parser rejects a half-select bit on a full-width input, so check the refusal class while keeping the swapped-source control." For each source position (0, 1, 2) and for both `v_fma_mix_f32` and `v_fma_mixlo_f16` (`v_fma_mixhi_f16` is covered by the existing test): - `op_sel_hi` alone widens the low half of that source only; the other sources stay binary32. Asserted on the exact lowered `mad(...)` text and on the parsed fields. - `op_sel` plus `op_sel_hi` on that source selects the high half of that source only (exact text). A variant with `op_sel_hi:[1,1,1]` and `op_sel` on one source checks that the half bit does not move to a neighbour. - `op_sel` alone is refused with `ValueError` matching "High-half selection requires an f16 operand", both from `parse_fma_mix` and through `lower()`, also when `op_sel_hi` is set on a different source. - Swapped-source control: the lowered text for a modifier at one position differs from the text at every other position, and low differs from high. The test needs no LLVM: it feeds assembly text to `lower()`. It runs on Windows and in the Linux CI list (the file is already registered). ## Verification Commands from the worktree, with `C:\XBOX2Windows\repo\out\pe-env\Scripts\python.exe -B`: - Before: `tests/rdna2_tools_check.py` gave `Ran 157 tests`, `OK (skipped=19)`. - After: `Ran 158 tests`, `OK (skipped=19)`. The skips are LLVM-only tests. Mutants of `tools/pixel_aot.py` (each applied by hand, then restored; `git diff -- tools` empty after each): | Mutant | main's `test_vop3p_fma_mix_inline_abs_neg_modifiers` | new test | |---|---|---| | 1. `lower()` pairs `op_sel[1]` and `op_sel[2]` swapped | passes (survives) | FAILS (high-half cases, positions 1 and 2, both opcodes) | | 2. refusal in `parse_fma_mix` limited to positions 0 and 1 | passes (survives) | FAILS (`op_sel alone` at position 2, both opcodes, 2 failures) | | 3. `zip(tokens, op_sel, op_sel_hi)` plain swap in `lower()` | fails (already caught) | FAILS (7 failures) | Not run: `tests/pixel_aot_check.py` (needs LLVM and a GPU/WARP device; not touched), the full CTest suite. ## Evidence and follow-up Overlap: `gh pr list --state open --search "fma_mix"` shows only #2753 (gfx2hlsl) and #532 (integer multiplies), neither edits `tests/rdna2_tools_check.py`. Open PRs #1572 and #531 touch the file elsewhere (not near the fma_mix tests); the new method sits between the existing fma_mix test and `test_mubuf_opcode_table_synthetic_forms`. The immediate handling from #2100 (`-0`, `-16..-1`) is not touched. AI-assisted.
upstream-sync closed this pull request 2026-11-26 12:04:45 +00:00
tedin7 commented 2026-11-26 12:04:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T11:07:20Z.

Review: COMMENTED


Review of head fa2b5f73 (test-only change: tests/rdna2_tools_check.py, +86 lines, no tool code touched).

Findings: none blocking.

  • The new test pins the half-select per source position for v_fma_mix_f32 and v_fma_mixlo_f16, with exact lowered text, the refusal class ("High-half selection requires an f16 operand") from both parse_fma_mix and lower(), and a swapped-source control. This matches the maintainer's request on #2103.
  • No lowering is added or changed, so no new GPU readback is needed for this PR. The test checks the lowered text and parsed fields, as the existing fma_mix tests do.
  • Overlap: no other open or merged PR adds this discriminator.

Commands run locally (worktree at the PR head, 4 commits behind main):

  • python3 -B tests/rdna2_tools_check.py: Ran 158 tests, OK (skipped=19).
  • python3 tests/docs_links_check.py: ok. python3 tests/bidi_controls_check.py: ok. git diff --check origin/main...HEAD: clean.
  • Mutation 1 (op_sel pairing for positions 1 and 2 swapped in lower()): 5 failures. Restored.
  • Mutation 2 (high-half refusal limited to positions 0 and 1 in parse_fma_mix): 2 failures. Restored.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6073051247 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2806#pullrequestreview-6073051247). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T11:07:20Z. **Review:** COMMENTED --- Review of head fa2b5f73 (test-only change: `tests/rdna2_tools_check.py`, +86 lines, no tool code touched). Findings: none blocking. - The new test pins the half-select per source position for `v_fma_mix_f32` and `v_fma_mixlo_f16`, with exact lowered text, the refusal class ("High-half selection requires an f16 operand") from both `parse_fma_mix` and `lower()`, and a swapped-source control. This matches the maintainer's request on #2103. - No lowering is added or changed, so no new GPU readback is needed for this PR. The test checks the lowered text and parsed fields, as the existing fma_mix tests do. - Overlap: no other open or merged PR adds this discriminator. Commands run locally (worktree at the PR head, 4 commits behind main): - `python3 -B tests/rdna2_tools_check.py`: Ran 158 tests, OK (skipped=19). - `python3 tests/docs_links_check.py`: ok. `python3 tests/bidi_controls_check.py`: ok. `git diff --check origin/main...HEAD`: clean. - Mutation 1 (`op_sel` pairing for positions 1 and 2 swapped in `lower()`): 5 failures. Restored. - Mutation 2 (high-half refusal limited to positions 0 and 1 in `parse_fma_mix`): 2 failures. Restored. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 12:04:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T11:08:06Z.


Win2025 receipt for head fa2b5f73.

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

  • Windows Python checks: tests/rdna2_tools_check.py ok (4.0s), PYCHECK name=tests/rdna2_tools_check.py rc=0
  • Python-only change (no builds, no CTest targets affected).
  • Real-GPU run not available (no lowering change in this PR).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7190315469 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2806#issuecomment-7190315469). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T11:08:06Z. --- Win2025 receipt for head fa2b5f73. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `fa2b5f73d03b9faa75f49bc3c37a1af054819248`: - **Windows Python checks**: `tests/rdna2_tools_check.py` ok (`4.0s`), `PYCHECK name=tests/rdna2_tools_check.py rc=0` - Python-only change (no builds, no CTest targets affected). - Real-GPU run not available (no lowering change in this PR). 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!2798
No description provided.