shader: lower binary32 add, sub, subrev, mul, min and max in the depth-mask translator #1118

Merged
tedin7 merged 1 commit from upstream-pr/1125 into main 2026-11-24 01:52:49 +00:00
tedin7 commented 2026-11-24 01:25:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T01:25:20Z.


Change

AI-assisted. Extends tools/depth_mask_aot.py so the two-table depth-only translator accepts v_add_f32_e32, v_sub_f32_e32, v_subrev_f32_e32, v_mul_f32_e32, v_min_f32_e32 and v_max_f32_e32. Before, any of them raised "Unsupported depth instruction". Reading a VGPR that no earlier instruction wrote now raises ValueError instead of KeyError (a small change in the same function, reachable through the new second source). No overlapping open PR found (gh pr list --state all, no related issue found with gh issue list --search depth).

Verification

Commit on top of main 32f63f9e, LLVM 19 locally (CI uses LLVM 15, not available here):

  • python3 -B tests/depth_mask_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so: exit 0 with the change.
  • The same command with tools/depth_mask_aot.py from main: exit 1, ValueError: Unsupported depth instruction: v_add_f32_e32.
  • Changing only subrev's lowering to sub's operand order: exit 1 (pinned lowered line no longer matches).
  • Not run: depth_mask_ops_draw_* (new CTest, depth_mask_check.py ops <dxc> <offscreen_check> <adapter>). It needs dxc and a D3D12 adapter, which this Linux host lacks. I only ran its Python flow against a stub compiler and stub renderer. No WARP or GPU readback of these six forms has been observed yet; capability skip is exit 77 as for the neighboring draw test.

Evidence and follow-up

  • Fixtures are original synthetic gfx1013 programs assembled by llvm-mc; no game data.
  • Each fixture computes op(0.5, v7) and feeds the existing discard compare. The lowered line is pinned as a literal per form, and replacing that one instruction word with each of the other five forms must change the line to that form's.
  • The draw test uses seeds 7 and 29 with thresholds 0.25 and 0.75, a CPU reference with Python operators on exactly representable values, and requires each other form's reference to fail with exactly the number of differing pixels.
  • Assumption: operands are finite and normal; NaN and subnormal behavior is not claimed (stated in docs/experiments.md).
  • Docs: docs/experiments.md "Buffered depth export" updated.

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:6572481213 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1125). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T01:25:20Z. --- ## Change AI-assisted. Extends `tools/depth_mask_aot.py` so the two-table depth-only translator accepts `v_add_f32_e32`, `v_sub_f32_e32`, `v_subrev_f32_e32`, `v_mul_f32_e32`, `v_min_f32_e32` and `v_max_f32_e32`. Before, any of them raised "Unsupported depth instruction". Reading a VGPR that no earlier instruction wrote now raises ValueError instead of KeyError (a small change in the same function, reachable through the new second source). No overlapping open PR found (`gh pr list --state all`, no related issue found with `gh issue list --search depth`). ## Verification Commit on top of main 32f63f9e, LLVM 19 locally (CI uses LLVM 15, not available here): - `python3 -B tests/depth_mask_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so`: exit 0 with the change. - The same command with `tools/depth_mask_aot.py` from main: exit 1, `ValueError: Unsupported depth instruction: v_add_f32_e32`. - Changing only `subrev`'s lowering to `sub`'s operand order: exit 1 (pinned lowered line no longer matches). - Not run: `depth_mask_ops_draw_*` (new CTest, `depth_mask_check.py ops <dxc> <offscreen_check> <adapter>`). It needs dxc and a D3D12 adapter, which this Linux host lacks. I only ran its Python flow against a stub compiler and stub renderer. No WARP or GPU readback of these six forms has been observed yet; capability skip is exit 77 as for the neighboring draw test. ## Evidence and follow-up - Fixtures are original synthetic gfx1013 programs assembled by llvm-mc; no game data. - Each fixture computes `op(0.5, v7)` and feeds the existing discard compare. The lowered line is pinned as a literal per form, and replacing that one instruction word with each of the other five forms must change the line to that form's. - The draw test uses seeds 7 and 29 with thresholds 0.25 and 0.75, a CPU reference with Python operators on exactly representable values, and requires each other form's reference to fail with exactly the number of differing pixels. - Assumption: operands are finite and normal; NaN and subnormal behavior is not claimed (stated in docs/experiments.md). - Docs: `docs/experiments.md` "Buffered depth export" updated. ## 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.
upstream-sync closed this pull request 2026-11-24 06:46:27 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:50:02 +00:00 (Migrated from github.com)

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


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-24T01:29:23.326792Z b66f869 PR opened
ℹ️ 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:7119086067 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1125#issuecomment-7119086067). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T01:25:29Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"b66f869b90778c8a17e973b668eb123cc78ba81f","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-24T01:29:23.326792Z">2026-11-24T01:29:23.326792Z</relative-time> | `b66f869` | PR opened | <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>
thepatrickworld commented 2026-11-24 06:50:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-24T01:53:43Z.


Ran the draw you couldn't: depth_mask_ops_draw_hardware on an RX 9070 XT (vendor 1002, device 7550), driver 32.0.32029.2010, Windows 26200.9711, head b66f869b merged onto 45b3c5d2 → 50895ce3, tree 159d1570, clean tree, DXC 1.9.2602.17, dev preset, debug_layer=unavailable.

4/4 passed, three consecutive runs. Timings from the first run: depth_mask_draw_hardware 2.31 s, depth_mask_ops_draw_hardware 5.93 s, and the two warp entries 0.93 s and 2.56 s. The ops test makes 42 draws per run: 12 against their own reference (mismatches=0) and 30 against another form's reference, each rejected with Draw reference mismatch and counts 512 (×10), 768 (×10), 256 (×8), 1024 (×2) — the same in all three runs, and consistent with the reference I recomputed in Python.

That recomputation is also the check on the two-case design: for (7, 0.25) and (29, 0.75), no two of the six forms produce the same pair of reference images. What carries it is worth stating: on the second case four of the six saturate at 1024/1024 low-depth pixels, so any separation between them rests on the first case — and there sub and subrev share the count 768 and differ only in which rows sit at the low depth. Counts alone never separate those two.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7119556115 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1125#issuecomment-7119556115). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-24T01:53:43Z. --- Ran the draw you couldn't: `depth_mask_ops_draw_hardware` on an RX 9070 XT (vendor 1002, device 7550), driver `32.0.32029.2010`, Windows `26200.9711`, head `b66f869b` merged onto `45b3c5d2` → `50895ce3`, tree `159d1570`, clean tree, DXC `1.9.2602.17`, `dev` preset, `debug_layer=unavailable`. 4/4 passed, three consecutive runs. Timings from the first run: `depth_mask_draw_hardware` 2.31 s, `depth_mask_ops_draw_hardware` 5.93 s, and the two warp entries 0.93 s and 2.56 s. The ops test makes 42 draws per run: 12 against their own reference (`mismatches=0`) and 30 against another form's reference, each rejected with `Draw reference mismatch` and counts 512 (×10), 768 (×10), 256 (×8), 1024 (×2) — the same in all three runs, and consistent with the reference I recomputed in Python. That recomputation is also the check on the two-case design: for (7, 0.25) and (29, 0.75), no two of the six forms produce the same pair of reference images. What carries it is worth stating: on the second case four of the six saturate at 1024/1024 low-depth pixels, so any separation between them rests on the first case — and there `sub` and `subrev` share the count 768 and differ only in which rows sit at the low depth. Counts alone never separate those two. _AI-assisted._
thepatrickworld commented 2026-11-24 06:50:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-24T02:12:24Z.


Confirmed on the merge commit, since the run above was on a merge I built myself (tree 159d1570) rather than on the tree that shipped: 0a4bd9da07e7b716647bbb26930733bd47a36c77, tree e1335f5047bcb58223c5a4abfda9c5c4d6d442b5, clean tree. depth_mask_draw_hardware 2.06 s, depth_mask_ops_draw_hardware 5.65 s, and the two warp entries pass — 4/4, twice.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7119864456 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1125#issuecomment-7119864456). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-24T02:12:24Z. --- Confirmed on the merge commit, since the run above was on a merge I built myself (tree `159d1570`) rather than on the tree that shipped: `0a4bd9da07e7b716647bbb26930733bd47a36c77`, tree `e1335f5047bcb58223c5a4abfda9c5c4d6d442b5`, clean tree. `depth_mask_draw_hardware` 2.06 s, `depth_mask_ops_draw_hardware` 5.65 s, and the two warp entries pass — 4/4, twice. _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!1118
No description provided.