test: pin the gather offset refusal and its signed decode #1803

Merged
ChazY11 merged 1 commit from upstream-pr/1810 into main 2026-11-24 19:20:01 +00:00
ChazY11 commented 2026-11-24 19:03:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T19:03:58Z.


Follow-up to #1773, which promised this case once it landed.

What

def gather_offset(bits):
    if bits is None or bits & ~0x3f3f: raise ValueError("Gather requires a static packed XY offset")
    x, y = bits & 63, (bits >> 8) & 63
    return (x ^ 32) - 32, (y ^ 32) - 32

No check reached the refusal — replacing it with pass left pixel_aot_check green — and nothing asserted the decode
itself, so a wrong sign centre would only show up in a drawn comparison.

Change

Three refusals and three decodes, appended to the function #1773 added:

for bad in (None, 0x40, 0x4040): ... expect "static packed XY offset"
assert pixel_aot.gather_offset(0x0101) == (1, 1)
assert pixel_aot.gather_offset(0x1f3f) == (-1, 31)     # 0x3f in X, 0x1f in Y
assert pixel_aot.gather_offset(0x203f) == (-1, -32)    # 0x20 in Y is the other end

The two ends matter: 0x1f is the largest positive offset and 0x20 the smallest negative, so a decode that truncates or
centres on 31 instead of 32 fails one of them.

Tested

out/pe-env/Scripts/python.exe -B tests/pixel_aot_check.py        # exit 0

Negative controls, each reverted:

refusal -> pass                          FAIL
(x ^ 32) - 32  ->  (x ^ 31) - 31         FAIL
reverted                                 exit 0

Note on my own arithmetic

My first version asserted gather_offset(0x203f) == (-1, 31). It is (-1, -32); 0x20 centres to −32, and the run told me
so before the commit. Both ends are asserted now, which is what would have caught my error in the first place.

Notes

  • AI-assisted.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6589273104 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1810). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T19:03:58Z. --- Follow-up to #1773, which promised this case once it landed. ## What ```python def gather_offset(bits): if bits is None or bits & ~0x3f3f: raise ValueError("Gather requires a static packed XY offset") x, y = bits & 63, (bits >> 8) & 63 return (x ^ 32) - 32, (y ^ 32) - 32 ``` No check reached the refusal — replacing it with `pass` left `pixel_aot_check` green — and nothing asserted the decode itself, so a wrong sign centre would only show up in a drawn comparison. ## Change Three refusals and three decodes, appended to the function #1773 added: ```python for bad in (None, 0x40, 0x4040): ... expect "static packed XY offset" assert pixel_aot.gather_offset(0x0101) == (1, 1) assert pixel_aot.gather_offset(0x1f3f) == (-1, 31) # 0x3f in X, 0x1f in Y assert pixel_aot.gather_offset(0x203f) == (-1, -32) # 0x20 in Y is the other end ``` The two ends matter: `0x1f` is the largest positive offset and `0x20` the smallest negative, so a decode that truncates or centres on 31 instead of 32 fails one of them. ## Tested ```powershell out/pe-env/Scripts/python.exe -B tests/pixel_aot_check.py # exit 0 ``` Negative controls, each reverted: ```text refusal -> pass FAIL (x ^ 32) - 32 -> (x ^ 31) - 31 FAIL reverted exit 0 ``` ## Note on my own arithmetic My first version asserted `gather_offset(0x203f) == (-1, 31)`. It is `(-1, -32)`; `0x20` centres to −32, and the run told me so before the commit. Both ends are asserted now, which is what would have caught my error in the first place. ## Notes - AI-assisted.
upstream-sync closed this pull request 2026-11-24 20:00:43 +00:00
tedin7 commented 2026-11-24 20:00:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:18:46Z.

Review: COMMENTED


Verified PR #1810 at commit f48a9a8b67cc1075eac66a5eada461f77b1ffc19 (tests/pixel_aot_check.py).

Summary

  • Checked the new pixel_aot.gather_offset refusal and signed 6-bit decode assertions in check_sampler_descriptor_refusals() (tests/pixel_aot_check.py):
    • Refuses None, 0x40, and 0x4040 with ValueError matching "static packed XY offset".
    • Verifies signed 6-bit decode centred on 32 across positive and both signed boundary endpoints: 0x0101 -> (1, 1), 0x1f3f -> (-1, 31), and 0x203f -> (-1, -32).
  • Clean-room neutrality and formatting verified; no defects found.

Linux checks

  • git diff --check origin/main...HEAD -> exit 0
  • python -B tests/bidi_controls_check.py -> exit 0 (1313 tracked files, no bidirectional controls)
  • python -B tests/pixel_aot_check.py -> exit 0

Local mutation checks (reverted cleanly after verification)

  1. Bypassed the bits is None or bits & ~0x3f3f refusal in tools/pixel_aot.py -> python -B tests/pixel_aot_check.py failed (rc=1, AssertionError: gather offset None was accepted).
  2. Changed the signed decode centre in tools/pixel_aot.py from (x ^ 32) - 32, (y ^ 32) - 32 to (x ^ 31) - 31, (y ^ 31) - 31 -> python -B tests/pixel_aot_check.py failed (rc=1, AssertionError: (-1, -1)).
  3. Restored tools/pixel_aot.py and re-ran python -B tests/pixel_aot_check.py -> exit 0.

Windows Server 2025 verification (Build 26100, MSVC 14.44.35207 + D3D12 WARP)

  • tests/pixel_aot_check.py -> exit 0 (11.8s)
  • Debug (--preset dev): ctest --preset dev -R '^pixel_aot_gather_warp$' --parallel 6 --no-tests=error --output-on-failure -> 1/1 passed (6.23s)
  • Release /O2 (--preset release): ctest --preset release -R '^pixel_aot_gather_warp$' --parallel 6 --no-tests=error --output-on-failure -> 1/1 passed (5.98s)

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6045775989 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1810#pullrequestreview-6045775989). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T19:18:46Z. **Review:** COMMENTED --- Verified PR #1810 at commit `f48a9a8b67cc1075eac66a5eada461f77b1ffc19` (`tests/pixel_aot_check.py`). ### Summary - Checked the new `pixel_aot.gather_offset` refusal and signed 6-bit decode assertions in `check_sampler_descriptor_refusals()` (`tests/pixel_aot_check.py`): - Refuses `None`, `0x40`, and `0x4040` with `ValueError` matching `"static packed XY offset"`. - Verifies signed 6-bit decode centred on 32 across positive and both signed boundary endpoints: `0x0101 -> (1, 1)`, `0x1f3f -> (-1, 31)`, and `0x203f -> (-1, -32)`. - Clean-room neutrality and formatting verified; no defects found. ### Linux checks - `git diff --check origin/main...HEAD` -> exit `0` - `python -B tests/bidi_controls_check.py` -> exit `0` (1313 tracked files, no bidirectional controls) - `python -B tests/pixel_aot_check.py` -> exit `0` ### Local mutation checks (reverted cleanly after verification) 1. Bypassed the `bits is None or bits & ~0x3f3f` refusal in `tools/pixel_aot.py` -> `python -B tests/pixel_aot_check.py` failed (`rc=1`, `AssertionError: gather offset None was accepted`). 2. Changed the signed decode centre in `tools/pixel_aot.py` from `(x ^ 32) - 32, (y ^ 32) - 32` to `(x ^ 31) - 31, (y ^ 31) - 31` -> `python -B tests/pixel_aot_check.py` failed (`rc=1`, `AssertionError: (-1, -1)`). 3. Restored `tools/pixel_aot.py` and re-ran `python -B tests/pixel_aot_check.py` -> exit `0`. ### Windows Server 2025 verification (Build 26100, MSVC 14.44.35207 + D3D12 WARP) - `tests/pixel_aot_check.py` -> exit `0` (`11.8s`) - **Debug (`--preset dev`)**: `ctest --preset dev -R '^pixel_aot_gather_warp$' --parallel 6 --no-tests=error --output-on-failure` -> **1/1 passed** (`6.23s`) - **Release `/O2` (`--preset release`)**: `ctest --preset release -R '^pixel_aot_gather_warp$' --parallel 6 --no-tests=error --output-on-failure` -> **1/1 passed** (`5.98s`) AI-assisted; commands listed were executed locally.
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!1803
No description provided.