test: pin the two sampler-descriptor refusals #1766

Merged
ChazY11 merged 1 commit from upstream-pr/1773 into main 2026-11-24 18:56:17 +00:00
ChazY11 commented 2026-11-24 18:20:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T18:20:42Z.


What

Two decoder profiles in tools/pixel_aot.py refuse a field they cannot model:

def check_gather_sampler(words, mips, *, comparison):
    if (...): raise ValueError("Unsupported gather sampler: requires normalized clamp, bilinear XY, point mip ...")

def comparison_sampler_state(words):
    if mip == 3 or w2 >> 28: raise ValueError("Unsupported mip filter or word 2 bits 28-31")

No check reached either raise. Replacing each with pass left all three checks that cover this module green:

raise -> pass   pixel_aot_check green, form_coverage_check green, rdna2_tools_check green

Change

One function, called from check_controls, that calls both with legal words first and then with one illegal field:

pixel_aot.check_gather_sampler((0x12, 0, 0x04500000, 0), 1, comparison=False)      # accepted
for words in ((0x13, 0, 0x04500000, 0),        # clamp mode off
              (0x12, 0x800, 0x04500000, 0),     # word 1 bit 11, outside the MIN_LOD field
              (0x12, 0, 0x04500001, 0)):        # word 2 bias bit
    ... expect ValueError mentioning "Unsupported gather sampler"

and for the comparison profile, legal words (point filter with TRUNC_COORD, which is the pair the translator
accepts) then mip = 3 and word 2 bit 28, both of which must raise the mip-filter message.

Tested

out/pe-env/Scripts/python.exe -B tests/pixel_aot_check.py          # exit 0
with the cases, raises intact        exit 0
gather raise -> pass                 FAIL
mip-filter raise -> pass             FAIL
reverted                             exit 0

Two things I got wrong while writing it

Worth recording because they are the reason the assertions look the way they do:

  • word 1 = 0x1000 is inside the permitted MIN_LOD field (0x00fff000), so the gather profile accepts it. The
    refusal needs a bit outside that field; bit 11 does it.
  • a point filter with TRUNC_COORD clear is refused by a later check ("point filtering requires TRUNC_COORD 1"), so the
    "legal" comparison words have to set word 0 bit 27. The case fails loudly if either assumption drifts.

Scope

One test file, no behaviour change. check_controls now runs these two before the heavier task list; they cost
microseconds.

Notes

  • AI-assisted.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6588533968 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1773). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T18:20:42Z. --- ## What Two decoder profiles in `tools/pixel_aot.py` refuse a field they cannot model: ```python def check_gather_sampler(words, mips, *, comparison): if (...): raise ValueError("Unsupported gather sampler: requires normalized clamp, bilinear XY, point mip ...") def comparison_sampler_state(words): if mip == 3 or w2 >> 28: raise ValueError("Unsupported mip filter or word 2 bits 28-31") ``` No check reached either raise. Replacing each with `pass` left all three checks that cover this module green: ```text raise -> pass pixel_aot_check green, form_coverage_check green, rdna2_tools_check green ``` ## Change One function, called from `check_controls`, that calls both with legal words first and then with one illegal field: ```python pixel_aot.check_gather_sampler((0x12, 0, 0x04500000, 0), 1, comparison=False) # accepted for words in ((0x13, 0, 0x04500000, 0), # clamp mode off (0x12, 0x800, 0x04500000, 0), # word 1 bit 11, outside the MIN_LOD field (0x12, 0, 0x04500001, 0)): # word 2 bias bit ... expect ValueError mentioning "Unsupported gather sampler" ``` and for the comparison profile, legal words (point filter with `TRUNC_COORD`, which is the pair the translator accepts) then `mip = 3` and `word 2 bit 28`, both of which must raise the mip-filter message. ## Tested ```powershell out/pe-env/Scripts/python.exe -B tests/pixel_aot_check.py # exit 0 ``` ```text with the cases, raises intact exit 0 gather raise -> pass FAIL mip-filter raise -> pass FAIL reverted exit 0 ``` ## Two things I got wrong while writing it Worth recording because they are the reason the assertions look the way they do: - `word 1 = 0x1000` is **inside** the permitted MIN_LOD field (`0x00fff000`), so the gather profile accepts it. The refusal needs a bit outside that field; bit 11 does it. - a point filter with `TRUNC_COORD` clear is refused by a later check ("point filtering requires TRUNC_COORD 1"), so the "legal" comparison words have to set word 0 bit 27. The case fails loudly if either assumption drifts. ## Scope One test file, no behaviour change. `check_controls` now runs these two before the heavier task list; they cost microseconds. ## Notes - AI-assisted.
upstream-sync closed this pull request 2026-11-24 19:01:25 +00:00
tedin7 commented 2026-11-24 19:01:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T18:55:48Z.

Review: COMMENTED


Reviewed at commit a5997c1e17c1dbae2346d021404d1f469cd0d883 (tests/pixel_aot_check.py).

Code Review

  • check_sampler_descriptor_refusals() is invoked from check_controls() and pins both sampler-descriptor refusal profiles in tools/pixel_aot.py:
    • check_gather_sampler(): accepts the legal baseline (0x12, 0, 0x04500000, 0) and asserts ValueError("Unsupported gather sampler...") on illegal word 0 (0x13), word 1 (0x800), and word 2 (0x04500001).
    • comparison_sampler_state(): accepts the legal point-filter + TRUNC_COORD=1 baseline and asserts ValueError("Unsupported mip filter...") on mip=3 and word 2 bit 28 (1 << 28).
  • Clean-room verified; 0 P1 / 0 P2 findings.

Verification

  • Linux:
    • git diff --check origin/main...HEAD: pass
    • /root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py: pass (Checked 1302 tracked source, script and build/CI files: no bidirectional controls.)
    • /root/.local/share/x2w-rev-venv/bin/python -B tests/pixel_aot_check.py: pass
    • /root/.local/share/x2w-rev-venv/bin/python -B tests/form_coverage_check.py: pass (form coverage checks passed)
  • Win2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev, ctest --preset dev -R '^(pixel_aot_gather_warp|pixel_aot_compare_sample_warp|rdna2_tools_check)$' --parallel 6 --no-tests=error --output-on-failure): 3/3 passed (6.91s: pixel_aot_compare_sample_warp 6.44s, pixel_aot_gather_warp 6.73s, rdna2_tools_check 6.80s)
    • Release /O2 (--preset release, ctest --preset release -R '^(pixel_aot_gather_warp|pixel_aot_compare_sample_warp|rdna2_tools_check)$' --parallel 6 --no-tests=error --output-on-failure): 3/3 passed (6.94s: pixel_aot_compare_sample_warp 6.29s, pixel_aot_gather_warp 6.50s, rdna2_tools_check 6.85s)
    • Windows Python checks: tests/pixel_aot_check.py ok (9.5s), tests/form_coverage_check.py ok (18.0s)
  • Local mutation checks (reverted after verification):
    1. Replacing raise ValueError("Unsupported gather sampler...") with pass in tools/pixel_aot.py: tests/pixel_aot_check.py failed with AssertionError: gather sampler (19, 0, 72351744, 0) was accepted (exit code 1).
    2. Replacing raise ValueError("Unsupported mip filter or word 2 bits 28-31") with pass in tools/pixel_aot.py: tests/pixel_aot_check.py failed with AssertionError: comparison sampler (134217746, 0, 201326592, 0) was accepted (exit code 1).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6045422693 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1773#pullrequestreview-6045422693). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T18:55:48Z. **Review:** COMMENTED --- Reviewed at commit `a5997c1e17c1dbae2346d021404d1f469cd0d883` (`tests/pixel_aot_check.py`). ### Code Review - `check_sampler_descriptor_refusals()` is invoked from `check_controls()` and pins both sampler-descriptor refusal profiles in `tools/pixel_aot.py`: - `check_gather_sampler()`: accepts the legal baseline `(0x12, 0, 0x04500000, 0)` and asserts `ValueError("Unsupported gather sampler...")` on illegal word 0 (`0x13`), word 1 (`0x800`), and word 2 (`0x04500001`). - `comparison_sampler_state()`: accepts the legal point-filter + `TRUNC_COORD=1` baseline and asserts `ValueError("Unsupported mip filter...")` on `mip=3` and word 2 bit 28 (`1 << 28`). - Clean-room verified; 0 P1 / 0 P2 findings. ### Verification - **Linux**: - `git diff --check origin/main...HEAD`: pass - `/root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py`: pass (`Checked 1302 tracked source, script and build/CI files: no bidirectional controls.`) - `/root/.local/share/x2w-rev-venv/bin/python -B tests/pixel_aot_check.py`: pass - `/root/.local/share/x2w-rev-venv/bin/python -B tests/form_coverage_check.py`: pass (`form coverage checks passed`) - **Win2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)**: - Debug (`--preset dev`, `ctest --preset dev -R '^(pixel_aot_gather_warp|pixel_aot_compare_sample_warp|rdna2_tools_check)$' --parallel 6 --no-tests=error --output-on-failure`): **3/3 passed** (`6.91s`: `pixel_aot_compare_sample_warp` `6.44s`, `pixel_aot_gather_warp` `6.73s`, `rdna2_tools_check` `6.80s`) - Release `/O2` (`--preset release`, `ctest --preset release -R '^(pixel_aot_gather_warp|pixel_aot_compare_sample_warp|rdna2_tools_check)$' --parallel 6 --no-tests=error --output-on-failure`): **3/3 passed** (`6.94s`: `pixel_aot_compare_sample_warp` `6.29s`, `pixel_aot_gather_warp` `6.50s`, `rdna2_tools_check` `6.85s`) - Windows Python checks: `tests/pixel_aot_check.py` ok (`9.5s`), `tests/form_coverage_check.py` ok (`18.0s`) - **Local mutation checks** (reverted after verification): 1. Replacing `raise ValueError("Unsupported gather sampler...")` with `pass` in `tools/pixel_aot.py`: `tests/pixel_aot_check.py` failed with `AssertionError: gather sampler (19, 0, 72351744, 0) was accepted` (exit code 1). 2. Replacing `raise ValueError("Unsupported mip filter or word 2 bits 28-31")` with `pass` in `tools/pixel_aot.py`: `tests/pixel_aot_check.py` failed with `AssertionError: comparison sampler (134217746, 0, 201326592, 0) was accepted` (exit code 1). AI-assisted; commands listed were executed locally.
ChazY11 commented 2026-11-24 19:01:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T18:23:06Z.


Same probe, applied to the rest of tools/pixel_aot.py, so the next case does not have to rediscover it. Each refusal was replaced with pass and the two checks that cover this module were run:

gather_offset: "Gather requires a static packed XY offset"     pixel_aot green, form_coverage green   -> unreached
multi-exit control flow: "Unverified multi-exit ..."            pixel_aot green, form_coverage green   -> unreached
record name: "Invalid length-prefixed record name"              pixel_aot green, form_coverage green   -> unreached
binary16 integer inline constant                                both red                               -> reached
32-bit scalar operand                                           both red                               -> reached

So the two refusals this PR pins are not the only unreached ones. gather_offset is the easy next one — it is a pure
function of one bit field:

def gather_offset(bits):
    if bits is None or bits & ~0x3f3f: raise ValueError("Gather requires a static packed XY offset")

gather_offset(None) and a value with a bit outside 0x3f3f should both raise, and a legal value should decode to the
signed pair. I can send that as its own PR once this one lands, rather than stacking a second change on the same file
while it is under review.

The other two — the multi-exit control-flow message and the record-name message — I am not attempting: both need a
malformed container or shader record, and I would be guessing at what the decoder can be fed rather than testing a
behaviour.

  • AI-assisted.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7140569640 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1773#issuecomment-7140569640). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T18:23:06Z. --- Same probe, applied to the rest of `tools/pixel_aot.py`, so the next case does not have to rediscover it. Each refusal was replaced with `pass` and the two checks that cover this module were run: ```text gather_offset: "Gather requires a static packed XY offset" pixel_aot green, form_coverage green -> unreached multi-exit control flow: "Unverified multi-exit ..." pixel_aot green, form_coverage green -> unreached record name: "Invalid length-prefixed record name" pixel_aot green, form_coverage green -> unreached binary16 integer inline constant both red -> reached 32-bit scalar operand both red -> reached ``` So the two refusals this PR pins are not the only unreached ones. `gather_offset` is the easy next one — it is a pure function of one bit field: ```python def gather_offset(bits): if bits is None or bits & ~0x3f3f: raise ValueError("Gather requires a static packed XY offset") ``` `gather_offset(None)` and a value with a bit outside `0x3f3f` should both raise, and a legal value should decode to the signed pair. I can send that as its own PR once this one lands, rather than stacking a second change on the same file while it is under review. The other two — the multi-exit control-flow message and the record-name message — I am not attempting: both need a malformed container or shader record, and I would be guessing at what the decoder can be fed rather than testing a behaviour. - AI-assisted.
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!1766
No description provided.