shader: lower ceil and mul:4/div:2 omod in dispatch translator #1384

Merged
tedin7 merged 1 commit from upstream-pr/1391 into main 2026-11-24 11:02:19 +00:00
tedin7 commented 2026-11-24 10:18:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T10:18:19Z.


What

  • tools/ffx_dispatch_aot.py: v_ceil_f32 joins the float table (ceil({0}), one source), for the e32 and e64 spellings, with the same clamp handling as v_floor_f32.
  • The VOP3 output modifiers mul:4 (4.0*(expr)) and div:2 (0.5*(expr)) are accepted next to mul:2 on the float ops. They are VOP3-only, so an e32 spelling with them is refused (ValueError). mul:2 on an e32 spelling stays accepted as before. An omod together with clamp is still refused in both orders, and so is any other omod text.
  • tests/ffx_dispatch_aot_check.py: seven new LLVM-assembled forms with tabulated expected words (math.ceil, exact power-of-two scaling), twelve mutation controls, new refusal controls. The two old checks that expected mul:4/div:2 on v_mul_f32_e64 to be refused now check acceptance.
  • docs/experiments.md: new short section.

Why

On origin/main v_ceil_f32 failed with a KeyError and mul:4/div:2 failed with Unsupported float modifier, so a dispatch program using them could not be lowered.

The hardware output modifier flushes denormals and quiets NaN differently from a plain multiply. The translation, like the existing mul:2, is a plain multiply: exact for normal results, denormal and NaN-payload behaviour is not modelled. Fixtures avoid both, and avoid ceil inputs in (-1, 0) (result -0.0).

Tested

Windows (not run here):

cmake --build --preset dev --target ffx_pass26_lds offscreen_check rcas_coordinate_readback
ctest --preset dev --no-tests=error -R '^(ffx_float_math_warp|ffx_float_to_int_warp|ffx_immediate_float_to_int_warp|ffx_pass26_lds_warp|pixel_aot_u32_from_f32_warp|rcas_coordinate_negative_warp|rcas_coordinate_positive_warp)$' -V

ffx_float_math_warp is the one that runs the new rows through the generated HLSL on WARP; it compares exact words.

Linux (ran):

  • python3 -B tests/ffx_dispatch_aot_check.py llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so passes.
  • Over 13,248 (mnemonic, source count, modifier) combinations the old and new alu give identical results or errors, except 832 that are explained (new ceil, new mul:4/div:2).
  • py_compile, tests/docs_links_check.py, tests/bidi_controls_check.py, git diff --check. All row HLSL lines lower for the readback path.

Not run: DXC, WARP, and LLVM 15 (llvm-mc-15 is not installed here). v_ceil_f32 and the mul:4/div:2 omods exist in LLVM 15, and no new syntax is used.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6579566009 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1391). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T10:18:19Z. --- ## What - `tools/ffx_dispatch_aot.py`: `v_ceil_f32` joins the float table (`ceil({0})`, one source), for the e32 and e64 spellings, with the same clamp handling as `v_floor_f32`. - The VOP3 output modifiers `mul:4` (`4.0*(expr)`) and `div:2` (`0.5*(expr)`) are accepted next to `mul:2` on the float ops. They are VOP3-only, so an e32 spelling with them is refused (ValueError). `mul:2` on an e32 spelling stays accepted as before. An omod together with `clamp` is still refused in both orders, and so is any other omod text. - `tests/ffx_dispatch_aot_check.py`: seven new LLVM-assembled forms with tabulated expected words (`math.ceil`, exact power-of-two scaling), twelve mutation controls, new refusal controls. The two old checks that expected `mul:4`/`div:2` on `v_mul_f32_e64` to be refused now check acceptance. - `docs/experiments.md`: new short section. ## Why On origin/main `v_ceil_f32` failed with a KeyError and `mul:4`/`div:2` failed with `Unsupported float modifier`, so a dispatch program using them could not be lowered. The hardware output modifier flushes denormals and quiets NaN differently from a plain multiply. The translation, like the existing `mul:2`, is a plain multiply: exact for normal results, denormal and NaN-payload behaviour is not modelled. Fixtures avoid both, and avoid ceil inputs in (-1, 0) (result -0.0). ## Tested Windows (not run here): ```powershell cmake --build --preset dev --target ffx_pass26_lds offscreen_check rcas_coordinate_readback ctest --preset dev --no-tests=error -R '^(ffx_float_math_warp|ffx_float_to_int_warp|ffx_immediate_float_to_int_warp|ffx_pass26_lds_warp|pixel_aot_u32_from_f32_warp|rcas_coordinate_negative_warp|rcas_coordinate_positive_warp)$' -V ``` `ffx_float_math_warp` is the one that runs the new rows through the generated HLSL on WARP; it compares exact words. Linux (ran): - `python3 -B tests/ffx_dispatch_aot_check.py llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so` passes. - Over 13,248 (mnemonic, source count, modifier) combinations the old and new `alu` give identical results or errors, except 832 that are explained (new ceil, new mul:4/div:2). - `py_compile`, `tests/docs_links_check.py`, `tests/bidi_controls_check.py`, `git diff --check`. All row HLSL lines lower for the readback path. Not run: DXC, WARP, and LLVM 15 (`llvm-mc-15` is not installed here). `v_ceil_f32` and the `mul:4`/`div:2` omods exist in LLVM 15, and no new syntax is used.
upstream-sync closed this pull request 2026-11-24 11:02:47 +00:00
tedin7 commented 2026-11-24 11:02:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T10:22:40Z.


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

  • Debug (--preset dev): ctest --preset dev -R '^ffx_float_math_warp$' --no-tests=error --output-on-failure — 1/1 passed (1.18s)
  • Release /O2 (--preset release): ctest --preset release -R '^ffx_float_math_warp$' --no-tests=error --output-on-failure — 1/1 passed (1.18s)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7128693759 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1391#issuecomment-7128693759). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T10:22:40Z. --- Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `54838ce6`: - **Debug (`--preset dev`)**: `ctest --preset dev -R '^ffx_float_math_warp$' --no-tests=error --output-on-failure` — **1/1 passed** (1.18s) - **Release `/O2` (`--preset release`)**: `ctest --preset release -R '^ffx_float_math_warp$' --no-tests=error --output-on-failure` — **1/1 passed** (1.18s)
chatgpt-codex-connector[bot commented 2026-11-24 11:03:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T10:22:53Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T10:25:28.107480Z 54838ce Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7128699292 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1391#issuecomment-7128699292). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T10:22:53Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"54838ce6e4712b6e0a0e781c7b9342ab632ccb7c","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T10:25:28.107480Z">2026-11-24T10:25:28.107480Z</relative-time> | `54838ce` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
SimSalabimse commented 2026-11-24 12:03:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-24T11:20:37Z.


Tested on Windows 11 26200, MSVC 19.42, RTX 4070 Ti (driver 621.35) at 54838ce. The filter ^ffx_floatmath(warp|hardware)$ matched no tests. The registered name is ffx_float_math_warp, and it passed. No hardware test is registered, so I ran the same readback on the 4070 Ti. ceil, mul:4 and div:2 matched, but it failed on an older fract row: v_fract_f32_e32 input 0xb0800000 gave 0x3f800000, expected 0x3f7fffff.

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7129974237 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1391#issuecomment-7129974237). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-11-24T11:20:37Z. --- Tested on Windows 11 26200, MSVC 19.42, RTX 4070 Ti (driver 621.35) at 54838ce. The filter `^ffx_floatmath(warp|hardware)$` matched no tests. The registered name is `ffx_float_math_warp`, and it **passed**. No hardware test is registered, so I ran the same readback on the 4070 Ti. ceil, mul:4 and div:2 matched, but it **failed** on an older fract row: `v_fract_f32_e32` input 0xb0800000 gave 0x3f800000, expected 0x3f7fffff. AI-Assisted
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!1384
No description provided.