shader: reject arithmetic writes to pending sample registers #269

Merged
Vonsek merged 1 commit from upstream-pr/273 into main 2026-11-21 20:26:27 +00:00
Vonsek commented 2026-11-21 19:57:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T19:57:59Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6533692222 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/273). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T19:57:59Z. --- ## 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.
upstream-sync closed this pull request 2026-11-24 06:42:10 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:47:57 +00:00 (Migrated from github.com)

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


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7068407785 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/273#issuecomment-7068407785). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T19:58:08Z. --- <!-- 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>
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!269
No description provided.