Pin compute_store's PSV, group, literal, offset, clause and wait bounds #958

Merged
Leyukaka merged 2 commits from upstream-pr/965 into main 2026-11-23 19:22:42 +00:00
Leyukaka commented 2026-11-23 19:06:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-23T19:06:36Z.


Change

This closes eight gaps in the test coverage of tools/compute_store_aot.py. Each was a one-line mutation that passed controls() in tests/compute_store_check.py on main. Only that test file changes; the translator does not.

New check Mutation it covers
PSV runtime info with declared size 47 is rejected minimum size lowered to 47
PSV runtime info with stage 4 (domain) is rejected stage check also accepting 4
Thread group (1, 1, 0) is rejected Z lower bound lowered to 0
s_clause 0x3f lowers like s_clause 0x1 s_clause limit tightened to < 0x3f
Scalar move of -2147483649 is rejected (Invalid scalar immediate) scalar lower bound one below -(1 << 31)
Vector move of 0x100000000 is rejected (Invalid literal move) vector upper bound one above 0xffffffff
Store at offset:4096 is rejected (Unverified raw UAV store) store offset limit raised to 4096
s_waitcnt lgkmcnt(0) vmcnt(1) in place of the read's vmcnt(0) is rejected (Unsupported compute instruction: s_waitcnt lgkmcnt(0) vmcnt(1)) that combined wait accepted as a completed vector load

The bounds follow the encodings: s_clause holds a 6-bit length minus one, the MUBUF offset is 12-bit unsigned, literals are 32-bit, and PSV runtime info 2 is 48 bytes, with the stage byte at byte 28 of the PSV0 part, after its 4-byte size (5 is compute, 4 is domain). The new cases are pure Python. Each names the diagnostic it expects, except the thread-group case, which joins the existing must_reject list, and the s_clause case, which compares HLSL. The two PSV cases share one message.

Verification

On 672ac62 (branch on 185ffbe), Windows 11 build 26300, MSVC 14.44.35207, Python 3.14:

ctest --preset dev --no-tests=error -R "^compute_store|compute_to_pixel" -j 6

All 16 tests pass. The eight _hardware tests ran on an NVIDIA GeForce RTX 5080 (driver 32.0.16.2101) and none was skipped.

Each mutation was applied to tools/compute_store_aot.py one at a time and controls() was run with the main and the branch versions of compute_store_check.py. With the unmutated translator both pass. On main, controls() passed under all eight mutations; on this branch it fails under each of them.

The eight edits to tools/compute_store_aot.py:

  1. 48 <= size <= len(psv) - 4 -> 47 <= size <= len(psv) - 4
  2. or psv[28] != 5 -> or psv[28] not in (4, 5)
  3. 1 <= z <= 64 -> 0 <= z <= 64
  4. if int(m[1], 0) > 0x3f: -> if int(m[1], 0) >= 0x3f:
  5. scalar immediate check -(1 << 31) <= value -> -(1 << 31) - 1 <= value
  6. literal move check value <= 0xffffffff -> value <= 0x100000000
  7. offset > 4095 -> offset > 4096 in the raw UAV store check
  8. "s_waitcnt vmcnt(0)"): -> "s_waitcnt vmcnt(0)", "s_waitcnt lgkmcnt(0) vmcnt(1)"):

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. (No change needed.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6566754928 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/965). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-23T19:06:36Z. --- ## Change This closes eight gaps in the test coverage of `tools/compute_store_aot.py`. Each was a one-line mutation that passed `controls()` in `tests/compute_store_check.py` on `main`. Only that test file changes; the translator does not. | New check | Mutation it covers | |---|---| | PSV runtime info with declared size 47 is rejected | minimum size lowered to 47 | | PSV runtime info with stage 4 (domain) is rejected | stage check also accepting 4 | | Thread group `(1, 1, 0)` is rejected | Z lower bound lowered to 0 | | `s_clause 0x3f` lowers like `s_clause 0x1` | `s_clause` limit tightened to `< 0x3f` | | Scalar move of `-2147483649` is rejected (`Invalid scalar immediate`) | scalar lower bound one below `-(1 << 31)` | | Vector move of `0x100000000` is rejected (`Invalid literal move`) | vector upper bound one above `0xffffffff` | | Store at `offset:4096` is rejected (`Unverified raw UAV store`) | store offset limit raised to 4096 | | `s_waitcnt lgkmcnt(0) vmcnt(1)` in place of the read's `vmcnt(0)` is rejected (`Unsupported compute instruction: s_waitcnt lgkmcnt(0) vmcnt(1)`) | that combined wait accepted as a completed vector load | The bounds follow the encodings: `s_clause` holds a 6-bit length minus one, the MUBUF offset is 12-bit unsigned, literals are 32-bit, and PSV runtime info 2 is 48 bytes, with the stage byte at byte 28 of the PSV0 part, after its 4-byte size (5 is compute, 4 is domain). The new cases are pure Python. Each names the diagnostic it expects, except the thread-group case, which joins the existing `must_reject` list, and the `s_clause` case, which compares HLSL. The two PSV cases share one message. ## Verification On `672ac62` (branch on `185ffbe`), Windows 11 build 26300, MSVC 14.44.35207, Python 3.14: ```text ctest --preset dev --no-tests=error -R "^compute_store|compute_to_pixel" -j 6 ``` All 16 tests pass. The eight `_hardware` tests ran on an NVIDIA GeForce RTX 5080 (driver 32.0.16.2101) and none was skipped. Each mutation was applied to `tools/compute_store_aot.py` one at a time and `controls()` was run with the `main` and the branch versions of `compute_store_check.py`. With the unmutated translator both pass. On `main`, `controls()` passed under all eight mutations; on this branch it fails under each of them. The eight edits to `tools/compute_store_aot.py`: 1. `48 <= size <= len(psv) - 4` -> `47 <= size <= len(psv) - 4` 2. ` or psv[28] != 5` -> ` or psv[28] not in (4, 5)` 3. `1 <= z <= 64` -> `0 <= z <= 64` 4. `if int(m[1], 0) > 0x3f:` -> `if int(m[1], 0) >= 0x3f:` 5. scalar immediate check `-(1 << 31) <= value` -> `-(1 << 31) - 1 <= value` 6. literal move check `value <= 0xffffffff` -> `value <= 0x100000000` 7. `offset > 4095` -> `offset > 4096` in the raw UAV store check 8. `"s_waitcnt vmcnt(0)"):` -> `"s_waitcnt vmcnt(0)", "s_waitcnt lgkmcnt(0) vmcnt(1)"):` ## 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. - [ ] I updated README/docs when a capability or build requirement changed. (No change needed.) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:45:37 +00:00
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!958
No description provided.