Add ceil, exp2 and log2 to the depth-mask translator #1370

Merged
tedin7 merged 1 commit from upstream-pr/1377 into main 2026-11-24 10:11:25 +00:00
tedin7 commented 2026-11-24 09:47:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T09:47:41Z.


Change

The shader depth-mask translator accepts three more one-source binary32 forms: v_ceil_f32, v_exp_f32 and v_log_f32 (also in the plain _e64 spelling), lowering to ceil, exp2 and log2. They join the table added in #1302. This work is AI-assisted.

Verification

  • python3 -B tests/depth_mask_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM.so.19.1: passes (exit 0). It assembles each form (e32 and e64 spelling), pins the lowered HLSL line, swaps that one instruction word for every other form, and rejects source modifiers, clamp, output modifiers, a second source, an unwritten source and a missing operand.
  • Negative control: with tools/depth_mask_aot.py from origin/main the same test fails with ValueError: Unsupported depth instruction: v_exp_f32_e32.
  • python3 -B tests/rdna2_tools_check.py, tests/docs_links_check.py, tests/bidi_controls_check.py: pass.
  • Not run: the WARP draw (depth_mask_unary_draw_warp), no Windows host here. LLVM 15 was not run.

Evidence and follow-up

  • Ceil is compared exactly against Python math.ceil on 4 * (v7 - 0.5). Exp2 and log2 are not claimed to be bit-exact: they get inputs with an exact integer result (exp2(5) = 32, log2(32) = 5) through a zero the compiler cannot prove, the result is rounded to the nearest integer, then scaled by v7.
  • The reference pictures are computed with Python arithmetic, and a check requires every form's picture to differ from every other form's, so a sibling swap (ceil/floor, exp/log, exp/rcp) changes the depth.
  • Not covered, and stated in docs/experiments.md: log2 of zero or a negative value, exp2 overflow, NaN, infinity, denormals, denormal flushing, signed zero.
  • Outside --preset pr: depth_mask_unary_draw_warp.

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.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6579030487 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1377). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T09:47:41Z. --- ## Change The shader depth-mask translator accepts three more one-source binary32 forms: `v_ceil_f32`, `v_exp_f32` and `v_log_f32` (also in the plain `_e64` spelling), lowering to `ceil`, `exp2` and `log2`. They join the table added in #1302. This work is AI-assisted. ## Verification - `python3 -B tests/depth_mask_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM.so.19.1`: passes (exit 0). It assembles each form (e32 and e64 spelling), pins the lowered HLSL line, swaps that one instruction word for every other form, and rejects source modifiers, clamp, output modifiers, a second source, an unwritten source and a missing operand. - Negative control: with `tools/depth_mask_aot.py` from origin/main the same test fails with `ValueError: Unsupported depth instruction: v_exp_f32_e32`. - `python3 -B tests/rdna2_tools_check.py`, `tests/docs_links_check.py`, `tests/bidi_controls_check.py`: pass. - Not run: the WARP draw (`depth_mask_unary_draw_warp`), no Windows host here. LLVM 15 was not run. ## Evidence and follow-up - Ceil is compared exactly against Python `math.ceil` on `4 * (v7 - 0.5)`. Exp2 and log2 are not claimed to be bit-exact: they get inputs with an exact integer result (exp2(5) = 32, log2(32) = 5) through a zero the compiler cannot prove, the result is rounded to the nearest integer, then scaled by v7. - The reference pictures are computed with Python arithmetic, and a check requires every form's picture to differ from every other form's, so a sibling swap (ceil/floor, exp/log, exp/rcp) changes the depth. - Not covered, and stated in docs/experiments.md: log2 of zero or a negative value, exp2 overflow, NaN, infinity, denormals, denormal flushing, signed zero. - Outside `--preset pr`: `depth_mask_unary_draw_warp`. ## 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. - [x] I did not include game files, dumps, distribution links or secrets.
tedin7 commented 2026-11-24 10:02:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T09:50:59Z.


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

  • Debug (--preset dev): offscreen_check build 3.60s; ctest --preset dev -R '^depth_mask_.*_warp$' --parallel 4 --no-tests=error --output-on-failure: 4/4 passed (depth_mask_draw_warp 1.39s, depth_mask_cmpx_draw_warp 1.99s, depth_mask_ops_draw_warp 3.16s, depth_mask_unary_draw_warp 5.73s)
  • Release /O2 (--preset release): offscreen_check build 0.97s; ctest --preset release -R '^depth_mask_.*_warp$' --parallel 4 --no-tests=error --output-on-failure: 4/4 passed (depth_mask_draw_warp 1.33s, depth_mask_cmpx_draw_warp 1.83s, depth_mask_ops_draw_warp 2.85s, depth_mask_unary_draw_warp 5.23s)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7127973547 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1377#issuecomment-7127973547). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T09:50:59Z. --- Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `6518a75adc7f9f91bf26ada1c29d91bf79131ac0`: - **Debug (`--preset dev`)**: `offscreen_check` build `3.60s`; `ctest --preset dev -R '^depth_mask_.*_warp$' --parallel 4 --no-tests=error --output-on-failure`: **4/4 passed** (`depth_mask_draw_warp` `1.39s`, `depth_mask_cmpx_draw_warp` `1.99s`, `depth_mask_ops_draw_warp` `3.16s`, `depth_mask_unary_draw_warp` `5.73s`) - **Release `/O2` (`--preset release`)**: `offscreen_check` build `0.97s`; `ctest --preset release -R '^depth_mask_.*_warp$' --parallel 4 --no-tests=error --output-on-failure`: **4/4 passed** (`depth_mask_draw_warp` `1.33s`, `depth_mask_cmpx_draw_warp` `1.83s`, `depth_mask_ops_draw_warp` `2.85s`, `depth_mask_unary_draw_warp` `5.23s`)
chatgpt-codex-connector[bot commented 2026-11-24 10:02:42 +00:00 (Migrated from github.com)

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


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-24T09:55:32.258214Z 6518a75 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:7127977936 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1377#issuecomment-7127977936). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T09:51:11Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"6518a75adc7f9f91bf26ada1c29d91bf79131ac0","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-24T09:55:32.258214Z">2026-11-24T09:55:32.258214Z</relative-time> | `6518a75` | 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>
upstream-sync closed this pull request 2026-11-24 11:02:40 +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!1370
No description provided.