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

Manually merged
github merged 2 commits from gh-pr/1182/head into gh-pr/1182/base 2026-11-26 22:46:50 +00:00
Owner

@⁠tedin7 on GitHub · 2026-11-24 02:49 UTC · original
tedin7:x2w-spirv-window-atomic-phi-parent → main · +25 −1 · 2 files · 2 commits · merged 2026-11-24 05:01 UTC

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.
**@⁠tedin7** on GitHub · 2026-11-24 02:49 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1182) `tedin7:x2w-spirv-window-atomic-phi-parent` → `main` · +25 −1 · 2 files · 2 commits · merged 2026-11-24 05:01 UTC ## 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:46:49 +00:00
github manually merged commit 16d2031f1f into gh-pr/1182/base 2026-11-26 22:46:50 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 03:30 UTC · original · edited 2026-11-24 03:33 UTC

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.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 03:30 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1182#issuecomment-7121158535) · edited 2026-11-24 03:33 UTC <!-- 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>
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 03:54 UTC · original

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** on GitHub · 2026-11-24 03:54 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1182#issuecomment-7121530927) 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.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 04:49 UTC · original

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)
**@⁠tedin7** on GitHub · 2026-11-24 04:49 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1182#issuecomment-7122366616) 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)
This discussion has been locked. Commenting is limited to contributors.
No description provided.