shader: lower bounded 64-bit word loads and stores through the SPIR-V address window #1157

Manually merged
github merged 4 commits from gh-pr/1157/head into gh-pr/1157/base 2026-11-26 22:44:57 +00:00
Owner

@⁠tedin7 on GitHub · 2026-11-24 01:56 UTC · original
tedin7:x2w-spirv-address-window-64bit-loads → main · +510 −30 · 9 files · 4 commits · merged 2026-11-24 03:42 UTC

Bounded 64-bit loads and stores through the SPIR-V address window.

A plain 64-bit load or store through a physical pointer becomes two 32-bit accesses inside an explicit branch, taken only for an address that is 8-byte aligned, below 0xfffffff8, and does not wrap on an indexed address. Otherwise a load returns zero and a store changes nothing; the substitute index is never used (same approach as the atomics). Atomics, Volatile, other alignments and other uses of the pointer are rejected.

  • tests/spirv_window/check.py: shape of the lowering, 7 rejection cases and 6 mutations that must each be caught. Fails on main.
  • New GPU readback (qword.spvasm, qword.py, readback.cpp): the 16-word memory is compared with an independent C++ model over 11 cases, including misaligned, above-window, index-wrap and out-of-view ones, which must leave memory intact; six negative controls each fail at a predicted case and word. Not run locally (no Windows or dxc); the Windows jobs are its first run.
  • docs/experiments.md updated; the existing readback function now takes init/apply callables so the new cases reuse it.

AI-assisted.

**@⁠tedin7** on GitHub · 2026-11-24 01:56 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1157) `tedin7:x2w-spirv-address-window-64bit-loads` → `main` · +510 −30 · 9 files · 4 commits · merged 2026-11-24 03:42 UTC Bounded 64-bit loads and stores through the SPIR-V address window. A plain 64-bit load or store through a physical pointer becomes two 32-bit accesses inside an explicit branch, taken only for an address that is 8-byte aligned, below 0xfffffff8, and does not wrap on an indexed address. Otherwise a load returns zero and a store changes nothing; the substitute index is never used (same approach as the atomics). Atomics, Volatile, other alignments and other uses of the pointer are rejected. - tests/spirv_window/check.py: shape of the lowering, 7 rejection cases and 6 mutations that must each be caught. Fails on main. - New GPU readback (qword.spvasm, qword.py, readback.cpp): the 16-word memory is compared with an independent C++ model over 11 cases, including misaligned, above-window, index-wrap and out-of-view ones, which must leave memory intact; six negative controls each fail at a predicted case and word. Not run locally (no Windows or dxc); the Windows jobs are its first run. - docs/experiments.md updated; the existing readback function now takes init/apply callables so the new cases reuse it. AI-assisted.
A plain %ulong load or store through a physical pointer (direct cast or an
indexed %rt_ulong chain) becomes two DWORD accesses inside a branch taken only
for an 8-byte aligned, in-window, non-wrapping address. Outside the branch a
load yields zero and a store changes nothing; the substitute index is never
used. Adds a QWORD fixture, a dedicated D3D12 readback with an independent
CPU model, a narrow-window build, six negative controls, Linux shape checks
and rejection cases, and documents the profile in docs/experiments.md.

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:44:56 +00:00
github manually merged commit 10da0549be into gh-pr/1157/base 2026-11-26 22:44:57 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 02:35 UTC · original · edited 2026-11-24 02:39 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-24T02:39:48.468194Z 3f8a40b 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 02:35 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1157#issuecomment-7120287848) · edited 2026-11-24 02:39 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"3f8a40bbc918f0baa3aeff53954b66d052b87908","has_any_findings":true,"has_unresolved_findings":true,"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-24T02:39:48.468194Z">2026-11-24T02:39:48.468194Z</relative-time> | `3f8a40b` | 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>
@ -150,0 +253,4 @@
stem = "%x2w_" + (f"load_{fields[0][1:]}" if wide_load else f"store_{wide_accesses}")
new, label = wide_access(kind, stem, valid_of[pointer], label, wide_words[pointer], fields)
final_label[origin] = label
output.extend(new)
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 02:39 UTC · original

P2 Badge Rewrite successor phi parents when splitting QWORD blocks

When a QWORD access occurs in a block that feeds a successor OpPhi, this moves the original terminator into a generated *_merge block without updating the successor's incoming parent label. In a variant of qword.spvasm that branches from %entry to %exit with %copied = OpPhi %ulong %result %entry, lowering retains %entry in that phi even though %x2w_load_value_merge is now the actual predecessor. The generated SPIR-V is therefore invalid, so output validation rejects an otherwise supported shader. Track each original block's final label and rewrite the original successor phi parents after inserting these guards.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 02:39 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1157#discussion_r4674843414) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Rewrite successor phi parents when splitting QWORD blocks** When a QWORD access occurs in a block that feeds a successor `OpPhi`, this moves the original terminator into a generated `*_merge` block without updating the successor's incoming parent label. In a variant of `qword.spvasm` that branches from `%entry` to `%exit` with `%copied = OpPhi %ulong %result %entry`, lowering retains `%entry` in that phi even though `%x2w_load_value_merge` is now the actual predecessor. The generated SPIR-V is therefore invalid, so output validation rejects an otherwise supported shader. Track each original block's final label and rewrite the original successor phi parents after inserting these guards. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 02:42 UTC · original

AI-assisted update addressing the P2 finding: a QWORD access that splits a block now rewrites the parent label of OpPhis in successor blocks to the generated *_merge block. tests/spirv_window/check.py gains a module with a successor phi, validated with spirv-as and spirv-val before and after lowering. The check fails on the previous lowering (spirv-val: phi parent is not a predecessor) and passes now. docs/experiments.md notes the rewrite.

**@⁠tedin7** on GitHub · 2026-11-24 02:42 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1157#issuecomment-7120411160) AI-assisted update addressing the P2 finding: a QWORD access that splits a block now rewrites the parent label of `OpPhi`s in successor blocks to the generated `*_merge` block. `tests/spirv_window/check.py` gains a module with a successor phi, validated with spirv-as and spirv-val before and after lowering. The check fails on the previous lowering (spirv-val: phi parent is not a predecessor) and passes now. `docs/experiments.md` notes the rewrite.
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 02:39 UTC · original · reviewed

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3f8a40bbc9

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 02:39 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1157#pullrequestreview-6032867554) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `3f8a40bbc9` <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". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback". </details>
This discussion has been locked. Commenting is limited to contributors.
No description provided.