shader: keep a NaN input a NaN in the depth-mask v_fract_f32 cap #1246

Merged
tedin7 merged 1 commit from upstream-pr/1253 into main 2026-11-24 06:54:03 +00:00
tedin7 commented 2026-11-24 05:34:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:34:14Z.


Change

The depth-mask translator lowered v_fract_f32_e32 as min(frac(x), asfloat(0x3f7fffffu)). D3D min returns its other operand for a NaN, so a NaN input became the finite cap, while v_fract_f32 returns a NaN. It now emits (frac(x) >= 1.0f ? asfloat(0x3f7fffffu) : frac(x)), the cap the pixel translator already uses; a NaN fails the comparison and passes through. Same fix as #1202 and #1223 for other translators; this PR touches only tools/depth_mask_aot.py, its check and the docs.

This change was AI-assisted.

Verification

  • python3 -B tests/depth_mask_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so: passes (LLVM 15 is what CI uses; not available locally).
  • fract_nan (new, in the same mode) against the unchanged translator from main: fails on the emitted expression; with the change: passes.
  • python3 -B tests/rdna2_tools_check.py: OK. No Windows or GPU run.

Evidence and follow-up

fract_nan lowers the fixture, evaluates the emitted expression with D3D semantics and compares binary32 bits with an independent reference (NaN stays NaN; -2^-30 and -2^-28 give 0x3f7fffff). Controls: the previous min form must mismatch on both NaN payloads, and an uncapped frac on both tiny negative inputs. No store or atomic is involved. The draw fixtures are unchanged.

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:6575380353 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1253). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:34:14Z. --- ## Change The depth-mask translator lowered `v_fract_f32_e32` as `min(frac(x), asfloat(0x3f7fffffu))`. D3D `min` returns its other operand for a NaN, so a NaN input became the finite cap, while `v_fract_f32` returns a NaN. It now emits `(frac(x) >= 1.0f ? asfloat(0x3f7fffffu) : frac(x))`, the cap the pixel translator already uses; a NaN fails the comparison and passes through. Same fix as #1202 and #1223 for other translators; this PR touches only `tools/depth_mask_aot.py`, its check and the docs. This change was AI-assisted. ## Verification - `python3 -B tests/depth_mask_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so`: passes (LLVM 15 is what CI uses; not available locally). - `fract_nan` (new, in the same mode) against the unchanged translator from main: fails on the emitted expression; with the change: passes. - `python3 -B tests/rdna2_tools_check.py`: OK. No Windows or GPU run. ## Evidence and follow-up `fract_nan` lowers the fixture, evaluates the emitted expression with D3D semantics and compares binary32 bits with an independent reference (NaN stays NaN; -2^-30 and -2^-28 give `0x3f7fffff`). Controls: the previous `min` form must mismatch on both NaN payloads, and an uncapped `frac` on both tiny negative inputs. No store or atomic is involved. The draw fixtures are unchanged. ## 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.
chatgpt-codex-connector[bot commented 2026-11-24 06:50:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T05:36: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-24T05:39:37.034776Z af36254 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:7123112470 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1253#issuecomment-7123112470). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T05:36:53Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"af36254cacfd9d1583553efd8f548171aa9ff742","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-24T05:39:37.034776Z">2026-11-24T05:39:37.034776Z</relative-time> | `af36254` | 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>
tedin7 commented 2026-11-24 06:50:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:52:49Z.


Verified on Windows Server 2025 (Build 26100, MSVC 14.44, D3D12 WARP) at commit af36254cacfd9d1583553efd8f548171aa9ff742:

  • cmake --preset dev + cmake --build --preset dev --target offscreen_check + ctest --preset dev -R "^depth_mask_.*_warp$": 3/3 passed (depth_mask_draw_warp, depth_mask_ops_draw_warp, depth_mask_cmpx_draw_warp)
  • cmake --preset release + cmake --build --preset release --target offscreen_check + ctest --preset release -R "^depth_mask_.*_warp$": 3/3 passed (depth_mask_draw_warp, depth_mask_ops_draw_warp, depth_mask_cmpx_draw_warp)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7123361230 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1253#issuecomment-7123361230). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:52:49Z. --- Verified on Windows Server 2025 (Build 26100, MSVC 14.44, D3D12 WARP) at commit `af36254cacfd9d1583553efd8f548171aa9ff742`: - `cmake --preset dev` + `cmake --build --preset dev --target offscreen_check` + `ctest --preset dev -R "^depth_mask_.*_warp$"`: 3/3 passed (`depth_mask_draw_warp`, `depth_mask_ops_draw_warp`, `depth_mask_cmpx_draw_warp`) - `cmake --preset release` + `cmake --build --preset release --target offscreen_check` + `ctest --preset release -R "^depth_mask_.*_warp$"`: 3/3 passed (`depth_mask_draw_warp`, `depth_mask_ops_draw_warp`, `depth_mask_cmpx_draw_warp`)
upstream-sync closed this pull request 2026-11-24 07:00:37 +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!1246
No description provided.