startup: lower v_fma_mix_f32 and op_sel on v_fma_mix in gfx2hlsl #2423

Closed
stan495 wants to merge 1 commit from upstream-pr/2431 into main
stan495 commented 2026-11-25 16:33:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-25T16:33:42Z.


Summary

Lower _fma_mix_f32 and add op_sel half-selection support across _fma_mix_f32, _fma_mixlo_f16, and _fma_mixhi_f16 in ools/startup/gfx2hlsl.py.

  • ** ools/startup/gfx2hlsl.py**:
    • Add INLINE_F16 and refactor Stage.mix(ops, mods, dest_mode) to support 'f32', 'lo', and 'hi' destinations (op_v_fma_mix_f32, op_v_fma_mixlo_f16, op_v_fma_mixhi_f16).
    • Parse both op_sel:[...] and op_sel_hi:[...] (plus clamp), rejecting duplicate or unknown modifiers and high-half op_sel bits when op_sel_hi is not set.
    • For op_sel_hi=1 (f16) operands, extract the selected half (>> 16 when op_sel=1, else low 16 bits with low16_only=True) and widen via 16tof32(...) before applying |abs| and -/
      eg(...) modifiers (matching ools/pixel_aot.py).
    • For _fma_mix_f32, emit via set_vf (honoring clamp and clearing low16_only on full 32-bit write); preserve untouched halves and low16_only semantics on mixlo/mixhi_f16.
  • ** ests/startup_gfx2hlsl_fma_mix_check.py**:
    • Pure-Python controls covering _fma_mix_f32, _fma_mixlo_f16, _fma_mixhi_f16, op_sel + op_sel_hi, bs/
      eg widening order, inline f16 constants, -0, odd-d16 low16 tracking (op_sel=0 accepted, op_sel=1 refused), invalid modifiers/operands, and a negative control removing op_v_fma_mix_f32.
  • CMakeLists.txt, .github/workflows/windows.yml, AGENTS.md: Register startup_gfx2hlsl_fma_mix_check.py.

Verification

  • Commit: d4dddc32 (based on upstream/main 7092683a)
  • Commands & Results:
    • python -B tests/startup_gfx2hlsl_fma_mix_check.py -> PASS
    • python -B tests/startup_image_load_d16_check.py -> PASS
    • python -B tests/startup_gfx2hlsl_handler_arity_check.py -> PASS
    • python -B tests/startup_gfx2hlsl_operand_count_check.py -> PASS
    • python -B tests/docs_links_check.py -> PASS (19 Markdown files, 464 links)
    • python -B tests/bidi_controls_check.py -> PASS (1723 tracked files)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6609017713 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2431). Originally posted by [stan495](https://github.com/stan495) on 2026-11-25T16:33:42Z. --- ## Summary Lower _fma_mix_f32 and add op_sel half-selection support across _fma_mix_f32, _fma_mixlo_f16, and _fma_mixhi_f16 in ools/startup/gfx2hlsl.py. - ** ools/startup/gfx2hlsl.py**: - Add INLINE_F16 and refactor Stage.mix(ops, mods, dest_mode) to support 'f32', 'lo', and 'hi' destinations (op_v_fma_mix_f32, op_v_fma_mixlo_f16, op_v_fma_mixhi_f16). - Parse both op_sel:[...] and op_sel_hi:[...] (plus clamp), rejecting duplicate or unknown modifiers and high-half op_sel bits when op_sel_hi is not set. - For op_sel_hi=1 (f16) operands, extract the selected half (>> 16 when op_sel=1, else low 16 bits with low16_only=True) and widen via 16tof32(...) *before* applying |abs| and -/ eg(...) modifiers (matching ools/pixel_aot.py). - For _fma_mix_f32, emit via set_vf (honoring clamp and clearing low16_only on full 32-bit write); preserve untouched halves and low16_only semantics on mixlo/mixhi_f16. - ** ests/startup_gfx2hlsl_fma_mix_check.py**: - Pure-Python controls covering _fma_mix_f32, _fma_mixlo_f16, _fma_mixhi_f16, op_sel + op_sel_hi, bs/ eg widening order, inline f16 constants, -0, odd-d16 low16 tracking (op_sel=0 accepted, op_sel=1 refused), invalid modifiers/operands, and a negative control removing op_v_fma_mix_f32. - **CMakeLists.txt, .github/workflows/windows.yml, AGENTS.md**: Register startup_gfx2hlsl_fma_mix_check.py. ## Verification - **Commit**: `d4dddc32` (based on upstream/main 7092683a) - **Commands & Results**: - `python -B tests/startup_gfx2hlsl_fma_mix_check.py` -> PASS - `python -B tests/startup_image_load_d16_check.py` -> PASS - `python -B tests/startup_gfx2hlsl_handler_arity_check.py` -> PASS - `python -B tests/startup_gfx2hlsl_operand_count_check.py` -> PASS - `python -B tests/docs_links_check.py` -> PASS (19 Markdown files, 464 links) - `python -B tests/bidi_controls_check.py` -> PASS (1723 tracked files)
upstream-sync closed this pull request 2026-11-25 17:01:44 +00:00
stan495 commented 2026-11-25 17:01:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-25T16:43:53Z.


Closing in favor of #2055 (which already covers v_fma_mix_f32 + op_sel with WARP/hardware dispatch readbacks and handles negated inline/literal edge cases).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7168443679 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2431#issuecomment-7168443679). Originally posted by [stan495](https://github.com/stan495) on 2026-11-25T16:43:53Z. --- Closing in favor of #2055 (which already covers v_fma_mix_f32 + op_sel with WARP/hardware dispatch readbacks and handles negated inline/literal edge cases).

Pull request closed

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!2423
No description provided.