shader: keep successor phi parents valid after splitting a window atomic #1175

Merged
tedin7 merged 2 commits from upstream-pr/1182 into main 2026-11-24 05:01:23 +00:00
tedin7 commented 2026-11-24 02:49:24 +00:00 (Migrated from github.com)

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


Change

Lowering a DWORD atomic in the SPIR-V address window splits its block into *_issue and *_merge. A successor block with an OpPhi that named the original block as its parent was left unchanged, and spirv-val rejects the result with "OpPhi's incoming basic block is not a predecessor". The adapter now records the block that ends in the branch after each split and rewrites those phi parents to it. A fixture module with an atomic followed by a phi in the next block is added to tests/spirv_window/check.py.

Related: #1088 (atomic lowering) and #1157 (the same problem for 64-bit accesses). #1157 is not merged, so this change is independent and uses its own small edit; a mixed 64-bit and atomic case in one block can be added once both land. The two PRs touch nearby lines of lower(), so whichever lands second may need a trivial rebase.

This work is AI-assisted.

Verification

  • python3 -B tests/spirv_window/check.py with spirv-as and spirv-val from SPIRV-Tools, with this change: exits 0, "physical, logical and combined SPIR-V validated; 8 atomics and rejection cases passed".
  • Negative control: the same command on origin/main (2da8071b) with only the new test applied exits 1 because spirv-val rejects the lowered phi module.
  • Not run here: the Windows jobs and the GPU readback; this change only affects SPIR-V validity of the lowered module.

Evidence and follow-up

  • The fixture is synthetic, derived from the existing subtract.spvasm, and is MIT licensed with the repository.
  • docs/experiments.md gets one sentence about the phi parent rewrite.
  • Follow-up: mixed 64-bit and atomic accesses in one block, after #1157 lands.

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:6573495312 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1182). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T02:49:24Z. --- ## Change Lowering a DWORD atomic in the SPIR-V address window splits its block into `*_issue` and `*_merge`. A successor block with an `OpPhi` that named the original block as its parent was left unchanged, and `spirv-val` rejects the result with "OpPhi's incoming basic block is not a predecessor". The adapter now records the block that ends in the branch after each split and rewrites those phi parents to it. A fixture module with an atomic followed by a phi in the next block is added to `tests/spirv_window/check.py`. Related: #1088 (atomic lowering) and #1157 (the same problem for 64-bit accesses). #1157 is not merged, so this change is independent and uses its own small edit; a mixed 64-bit and atomic case in one block can be added once both land. The two PRs touch nearby lines of `lower()`, so whichever lands second may need a trivial rebase. This work is AI-assisted. ## Verification - `python3 -B tests/spirv_window/check.py` with spirv-as and spirv-val from SPIRV-Tools, with this change: exits 0, "physical, logical and combined SPIR-V validated; 8 atomics and rejection cases passed". - Negative control: the same command on origin/main (2da8071b) with only the new test applied exits 1 because `spirv-val` rejects the lowered phi module. - Not run here: the Windows jobs and the GPU readback; this change only affects SPIR-V validity of the lowered module. ## Evidence and follow-up - The fixture is synthetic, derived from the existing `subtract.spvasm`, and is MIT licensed with the repository. - `docs/experiments.md` gets one sentence about the phi parent rewrite. - Follow-up: mixed 64-bit and atomic accesses in one block, after #1157 lands. ## 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:45 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:50:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T03:30: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-24T03:33:25.199798Z 4e5c1a7 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:7121158535 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1182#issuecomment-7121158535). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T03:30:11Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"4e5c1a79afbf9314d2763f77fb12e0659d2cda27","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-24T03:33:25.199798Z">2026-11-24T03:33:25.199798Z</relative-time> | `4e5c1a7` | 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:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T03:54:29Z.


AI-assisted. Merged main (one conflict in the address-window tool). Main now carries the same successor phi-parent rewrite, so this PR keeps only the regression test and the docs sentence on top of it. tests/spirv_window/check.py passes with SPIRV-Tools on Linux. Merge commit 16d2031f.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7121530927 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1182#issuecomment-7121530927). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T03:54:29Z. --- AI-assisted. Merged main (one conflict in the address-window tool). Main now carries the same successor phi-parent rewrite, so this PR keeps only the regression test and the docs sentence on top of it. tests/spirv_window/check.py passes with SPIRV-Tools on Linux. Merge commit 16d2031f.
tedin7 commented 2026-11-24 06:50:21 +00:00 (Migrated from github.com)

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


Windows Server 2025 verification (16d2031f) — PASS (Debug + Release /O2, WARP)

  • Environment: Windows Server 2025 Build 26100, MSVC 14.44.35207, AMD Ryzen 5 PRO 5650U, D3D12 WARP
  • Debug (--preset dev) (24.30s build+test):
    • cmake --build --preset dev -j 6 --target offscreen_check
    • ctest --test-dir out\build\dev -R "^spirv_.*_warp$" --output-on-failure -> 11/11 passed (0 skipped, 11.65s)
  • Release /O2 (--preset release) (26.57s configure+build+test):
    • cmake --preset release && cmake --build --preset release -j 6 --target offscreen_check
    • ctest --test-dir out\build\release -R "^spirv_.*_warp$" --output-on-failure -> 11/11 passed (0 skipped, 10.10s)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7122366616 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1182#issuecomment-7122366616). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T04:49:08Z. --- Windows Server 2025 verification (`16d2031f`) — **PASS (Debug + Release `/O2`, WARP)** - **Environment**: Windows Server 2025 Build 26100, MSVC 14.44.35207, AMD Ryzen 5 PRO 5650U, D3D12 WARP - **Debug (`--preset dev`)** (24.30s build+test): - `cmake --build --preset dev -j 6 --target offscreen_check` - `ctest --test-dir out\build\dev -R "^spirv_.*_warp$" --output-on-failure` -> **11/11 passed** (0 skipped, 11.65s) - **Release `/O2` (`--preset release`)** (26.57s configure+build+test): - `cmake --preset release && cmake --build --preset release -j 6 --target offscreen_check` - `ctest --test-dir out\build\release -R "^spirv_.*_warp$" --output-on-failure` -> **11/11 passed** (0 skipped, 10.10s)
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!1175
No description provided.