shader: reject arithmetic writes to pending sample registers #273

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

@⁠Vonsek on GitHub · 2026-11-21 19:57 UTC · original
Vonsek:codex/pixel-alu-destination-wait → main · +11 −1 · 3 files · 1 commits · merged 2026-11-21 20:26 UTC

Change

The straight-line pixel translator now rejects a floating-point arithmetic instruction that writes a VGPR still owned by an outstanding texture sample. An early write could replace the tracked sample component and make a later pre-wait read appear valid. Arithmetic may still write an unrelated destination before the wait or reuse the sampled destination after s_waitcnt vmcnt(0).

This applies to the existing floating-point arithmetic path. #176 tracks source readiness across partial waits, #232 adds integer instructions, and #258 and #270 guard their respective proposed opcodes. None is a prerequisite. The offline pixel shader experiment describes the updated constraint.

Verification

Tested commit cc19c0b548c3d49d889d78c87937f8b64b4a7067 on base 7233cecc0efea32e0dba55c3d2e66227b09b8a86. Windows build 26200, Visual Studio 2022 x64, local venv with requirements-dev.txt.

  • In Developer PowerShell via . ./tools/dev.ps1, ran cmake --preset dev and cmake --build --preset dev --target offscreen_check in a fresh worktree. Both passed.
  • ctest --preset dev --no-tests=error -R '^pixel_aot_(warp|hardware)$' --output-on-failure. With only the regression test added, both test commands failed at the early overwrite with AssertionError: translate accepted invalid input. With the guard added, both passed. Repeated on the committed head with -V. Microsoft Basic Render Driver 10.0.26100.9818 and NVIDIA GeForce RTX 5080 driver 32.0.16.1692, debug layers unavailable, zero skips.
  • python -B tests/pixel_aot_check.py binary $asm $objcopy $llvm passed with LLVM 15.0.7. On Windows, $asm is a wrapper invoking clang -cc1as -triple amdgcn--amdpal -target-cpu gfx1013 -filetype obj <source> -o <object>, and the other paths select the corresponding llvm-objcopy.exe and LLVM-C.dll.
  • ctest --preset dev --no-tests=error -R '^docs_links$' --output-on-failure passed. git diff --check upstream/main HEAD passed.

Evidence and follow-up

The regression uses the repository's MIT-licensed synthetic shader. The sample writes v12:v15. A floor writing v13 before the VM wait must be rejected. Moving the write to free register v24 preserves the sampled green export. Moving the original write after the wait exports the arithmetic result. These are offline translation checks. The WARP and hardware draws exercise the accepted desktop fixture suite; native scheduling of an unsynchronized instruction pair was outside the measurement.

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.

This contribution was AI-assisted.

**@⁠Vonsek** on GitHub · 2026-11-21 19:57 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/273) `Vonsek:codex/pixel-alu-destination-wait` → `main` · +11 −1 · 3 files · 1 commits · merged 2026-11-21 20:26 UTC ## Change The straight-line pixel translator now rejects a floating-point arithmetic instruction that writes a VGPR still owned by an outstanding texture sample. An early write could replace the tracked sample component and make a later pre-wait read appear valid. Arithmetic may still write an unrelated destination before the wait or reuse the sampled destination after `s_waitcnt vmcnt(0)`. This applies to the existing floating-point arithmetic path. #176 tracks source readiness across partial waits, #232 adds integer instructions, and #258 and #270 guard their respective proposed opcodes. None is a prerequisite. The [offline pixel shader experiment](https://github.com/Vonsek/Xbox2Windows/blob/cc19c0b548c3d49d889d78c87937f8b64b4a7067/docs/experiments.md#offline-pixel-shader-recompilation) describes the updated constraint. ## Verification Tested commit `cc19c0b548c3d49d889d78c87937f8b64b4a7067` on base `7233cecc0efea32e0dba55c3d2e66227b09b8a86`. Windows build 26200, Visual Studio 2022 x64, local venv with `requirements-dev.txt`. - In Developer PowerShell via `. ./tools/dev.ps1`, ran `cmake --preset dev` and `cmake --build --preset dev --target offscreen_check` in a fresh worktree. Both passed. - `ctest --preset dev --no-tests=error -R '^pixel_aot_(warp|hardware)$' --output-on-failure`. With only the regression test added, both test commands failed at the early overwrite with `AssertionError: translate accepted invalid input`. With the guard added, both passed. Repeated on the committed head with `-V`. Microsoft Basic Render Driver 10.0.26100.9818 and NVIDIA GeForce RTX 5080 driver 32.0.16.1692, debug layers unavailable, zero skips. - `python -B tests/pixel_aot_check.py binary $asm $objcopy $llvm` passed with LLVM 15.0.7. On Windows, `$asm` is a wrapper invoking `clang -cc1as -triple amdgcn--amdpal -target-cpu gfx1013 -filetype obj <source> -o <object>`, and the other paths select the corresponding `llvm-objcopy.exe` and `LLVM-C.dll`. - `ctest --preset dev --no-tests=error -R '^docs_links$' --output-on-failure` passed. `git diff --check upstream/main HEAD` passed. ## Evidence and follow-up The regression uses the repository's MIT-licensed synthetic shader. The sample writes `v12:v15`. A floor writing `v13` before the VM wait must be rejected. Moving the write to free register `v24` preserves the sampled green export. Moving the original write after the wait exports the arithmetic result. These are offline translation checks. The WARP and hardware draws exercise the accepted desktop fixture suite; native scheduling of an unsynchronized instruction pair was outside the measurement. ## 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. This contribution was AI-assisted.
A floating-point write can replace the tracked sample component before vmcnt(0) retires it. Check the same destination set used by register moves so an early overwrite cannot hide an unresolved result.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:39:17 +00:00
github manually merged commit cc19c0b548 into gh-pr/273/base 2026-11-26 21:39:19 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-21 19:58 UTC · original · edited 2026-11-21 20:00 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:00:34.762055Z cc19c0b 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 19:58 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/273#issuecomment-7068407785) · edited 2026-11-21 20:00 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"cc19c0b548c3d49d889d78c87937f8b64b4a7067","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:00:34.762055Z">2026-11-21T20:00:34.762055Z</relative-time> | `cc19c0b` | 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.