shader: lower single-word constant buffer reads #273

Merged
Vonsek merged 1 commit from upstream-pr/277 into main 2026-11-21 20:26:42 +00:00
Vonsek commented 2026-11-21 20:08:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T20:08:52Z.


Change

Lower gfx1013 s_buffer_load_dword for reads from the existing four-SGPR constant-buffer binding. The translator validates the descriptor's provenance and readiness, accepts dword-aligned immediate offsets within the 256-byte desktop binding and waits for LGKM completion before scalar consumption. The destination can overwrite a consumed descriptor word, so a subsequent read through that descriptor is rejected.

The shared interface is tools/pixel_aot.py::lower. The scalar ALU work in #257 consumes values from the existing four-word reader. Partial VM waits in #176 and outstanding VGPR destination checks in #273 concern texture samples. This change stays within constant-buffer loads and scalar LGKM readiness.

Verification

Commit a284cb6f3f782c170a73fcf1747c581b354f20fa on upstream 496fc28aafe3755637ee394b6404044457dfe292.

  • cmake --preset dev in the Visual Studio x64 environment with the local venv set as INTAKE_PYTHON, followed by cmake --build --preset dev --target offscreen_check. Passed from a fresh build.
  • ctest --preset dev --no-tests=error -R '^pixel_aot_warp$' --output-on-failure against the test-only change. Failed at instruction 17 on the first s_buffer_load_dword, as reproduced by the standalone Python test.
  • ctest --preset dev --no-tests=error -R '^pixel_aot_(warp|hardware)$' --output-on-failure. Both regression targets passed on WARP 10.0.26100.9818 and RTX 5080 driver 32.0.16.1692. Neither adapter skipped the test. The debug layer was unavailable. The neighboring-word control produced its first mismatch at (0, 0) on both adapters, where green expected 0.625 and got 0.
  • python -B tests/pixel_aot_check.py binary $asm $objcopy $llvm. The Windows LLVM 15.0.7 binaries passed the synthetic envelope and instruction round trip. The local assembler wrapper runs clang -cc1as -triple amdgcn--amdpal -target-cpu gfx1013 -filetype obj <source> -o <object>, with matching llvm-objcopy.exe and LLVM-C.dll. Ubuntu CI uses llvm-mc-15.
  • python -B tests/docs_links_check.py, ctest --preset dev --no-tests=error -R '^docs_links$' --output-on-failure and git diff --check. Passed. The link check verified 64 links in 10 files.

Evidence and follow-up

The MIT-licensed fixture uses original assembly and the existing synthetic texture and constant buffer. It reads the words at byte offsets 0, 8 and 252 with two sets of values. The CPU reference supplies the readback color. Controls cover the wrong offset, misalignment, resource provenance, an overwritten descriptor, and read or write attempts before the corresponding wait.

Read-only inspection of one archived pixel program identified a word load from a ready descriptor with an aligned immediate offset. That observation motivated the new fixture. The title's execution masks and coordinate dependencies need separate work. Experiment and reproduction commands

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 the experiment documentation for the new supported instruction.
  • I did not include game files, dumps, distribution links or secrets.

This contribution was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6533803285 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/277). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T20:08:52Z. --- ## Change Lower gfx1013 `s_buffer_load_dword` for reads from the existing four-SGPR constant-buffer binding. The translator validates the descriptor's provenance and readiness, accepts dword-aligned immediate offsets within the 256-byte desktop binding and waits for LGKM completion before scalar consumption. The destination can overwrite a consumed descriptor word, so a subsequent read through that descriptor is rejected. The shared interface is `tools/pixel_aot.py::lower`. The scalar ALU work in #257 consumes values from the existing four-word reader. Partial VM waits in #176 and outstanding VGPR destination checks in #273 concern texture samples. This change stays within constant-buffer loads and scalar LGKM readiness. ## Verification Commit `a284cb6f3f782c170a73fcf1747c581b354f20fa` on upstream `496fc28aafe3755637ee394b6404044457dfe292`. - `cmake --preset dev` in the Visual Studio x64 environment with the local venv set as `INTAKE_PYTHON`, followed by `cmake --build --preset dev --target offscreen_check`. Passed from a fresh build. - `ctest --preset dev --no-tests=error -R '^pixel_aot_warp$' --output-on-failure` against the test-only change. Failed at instruction 17 on the first `s_buffer_load_dword`, as reproduced by the standalone Python test. - `ctest --preset dev --no-tests=error -R '^pixel_aot_(warp|hardware)$' --output-on-failure`. Both regression targets passed on WARP 10.0.26100.9818 and RTX 5080 driver 32.0.16.1692. Neither adapter skipped the test. The debug layer was unavailable. The neighboring-word control produced its first mismatch at (0, 0) on both adapters, where green expected 0.625 and got 0. - `python -B tests/pixel_aot_check.py binary $asm $objcopy $llvm`. The Windows LLVM 15.0.7 binaries passed the synthetic envelope and instruction round trip. The local assembler wrapper runs `clang -cc1as -triple amdgcn--amdpal -target-cpu gfx1013 -filetype obj <source> -o <object>`, with matching `llvm-objcopy.exe` and `LLVM-C.dll`. Ubuntu CI uses `llvm-mc-15`. - `python -B tests/docs_links_check.py`, `ctest --preset dev --no-tests=error -R '^docs_links$' --output-on-failure` and `git diff --check`. Passed. The link check verified 64 links in 10 files. ## Evidence and follow-up The MIT-licensed fixture uses original assembly and the existing synthetic texture and constant buffer. It reads the words at byte offsets 0, 8 and 252 with two sets of values. The CPU reference supplies the readback color. Controls cover the wrong offset, misalignment, resource provenance, an overwritten descriptor, and read or write attempts before the corresponding wait. Read-only inspection of one archived pixel program identified a word load from a ready descriptor with an aligned immediate offset. That observation motivated the new fixture. The title's execution masks and coordinate dependencies need separate work. [Experiment and reproduction commands](docs/experiments.md#offline-pixel-shader-recompilation) ## 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 the experiment documentation for the new supported instruction. - [x] I did not include game files, dumps, distribution links or secrets. This contribution was AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:42:11 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:47:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T20:08:59Z.


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-21T20:13:16.222498Z a284cb6 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:7068540577 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/277#issuecomment-7068540577). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T20:08:59Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"a284cb6f3f782c170a73fcf1747c581b354f20fa","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-21T20:13:16.222498Z">2026-11-21T20:13:16.222498Z</relative-time> | `a284cb6` | 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>
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!273
No description provided.