shader: lower single-word constant buffer reads #277

Manually merged
github merged 1 commit from gh-pr/277/head into gh-pr/277/base 2026-11-26 21:39:33 +00:00
Owner

@⁠Vonsek on GitHub · 2026-11-21 20:08 UTC · original
Vonsek:codex/pixel-scalar-buffer-dword → main · +67 −5 · 3 files · 1 commits · merged 2026-11-21 20:26 UTC

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.

**@⁠Vonsek** on GitHub · 2026-11-21 20:08 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/277) `Vonsek:codex/pixel-scalar-buffer-dword` → `main` · +67 −5 · 3 files · 1 commits · merged 2026-11-21 20:26 UTC ## 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.
Pixel shaders can fetch an individual constant from a bound buffer before using it in vector arithmetic. Keep each scalar read within the established descriptor and wait contract.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:39:31 +00:00
github manually merged commit a284cb6f3f into gh-pr/277/base 2026-11-26 21:39:33 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-21 20:08 UTC · original · edited 2026-11-21 20:13 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-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.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-21 20:08 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/277#issuecomment-7068540577) · edited 2026-11-21 20:13 UTC <!-- 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>
This discussion has been locked. Commenting is limited to contributors.
No description provided.