test: refuse a gather destination that runs past v255 #1946

Merged
ChazY11 merged 1 commit from upstream-pr/1953 into main 2026-11-24 22:10:17 +00:00
ChazY11 commented 2026-11-24 22:05:03 +00:00 (Migrated from github.com)

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


What

op_image_gather4_lz requires four contiguous destination registers:

if not dst or dst[0] != 'v' or dst[2] - dst[1] != 3 or dst[2] > 255:
    raise Unsupported('%s requires four destination registers' % name)

The fixture in #1927 covers the address-register and nsa cases but not this one, so the guard is unpinned. Two bases that
decode to a destination running past the file make it observable:

dst=0x04  image_gather4_lz v[4:7],   v[0:1], ...   accepted, emits v4..v7
dst=0xfe  image_gather4_lz v[254:257], v[0:1], ... refused: four destination registers
dst=0xff  image_gather4_lz v[255:258], v[0:1], ... refused: four destination registers

Change

tests/startup_image_gather_lz_check.py only: shader() gains a dst=4 parameter (the base sits in bits 8–15 of the second
dword, which the existing high masking already leaves clear), and two refusal cases next to the nsa one:

refused(shader(dst=0xfe), 'four destination registers')
refused(shader(dst=0xff), 'four destination registers')

No production change, no new file, no CMake change.

Tested

out/pe-env/Scripts/python.exe -B tests/startup_image_gather_lz_check.py
Four fixed-mip gather channels and unsupported encodings checked      exit 0

ctest --preset dev -R 'gather'
100% tests passed, 0 tests failed out of 4

Fail-first, with the guard reduced to if not dst or dst[0] != 'v': and reverted afterwards:

File ".../tests/startup_image_gather_lz_check.py", line 56, in refused
  raise AssertionError('Gather accepted an unsupported form: ' + reason)
AssertionError: Gather accepted an unsupported form: four destination registers
exit 1

and with the guard restored, exit 0. The accepted form emits v256/v257 under the mutation, which is what the case prevents.

Scope note

This is the second half of the follow-up I posted on #1927 (pull/1927#issuecomment-7145688618). The first half — the
check_gather_sampler(words, 1, …) argument — I retracted there: (mips - 1) << 8 is vacuous for both 1 and 0 because
w1 >> 12 is non-negative, so that mutation is equivalent and there is nothing to test.

Notes

  • AI-assisted.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6592331809 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1953). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T22:05:03Z. --- ## What `op_image_gather4_lz` requires four contiguous destination registers: ```python if not dst or dst[0] != 'v' or dst[2] - dst[1] != 3 or dst[2] > 255: raise Unsupported('%s requires four destination registers' % name) ``` The fixture in #1927 covers the address-register and `nsa` cases but not this one, so the guard is unpinned. Two bases that decode to a destination running past the file make it observable: ```text dst=0x04 image_gather4_lz v[4:7], v[0:1], ... accepted, emits v4..v7 dst=0xfe image_gather4_lz v[254:257], v[0:1], ... refused: four destination registers dst=0xff image_gather4_lz v[255:258], v[0:1], ... refused: four destination registers ``` ## Change `tests/startup_image_gather_lz_check.py` only: `shader()` gains a `dst=4` parameter (the base sits in bits 8–15 of the second dword, which the existing `high` masking already leaves clear), and two refusal cases next to the `nsa` one: ```python refused(shader(dst=0xfe), 'four destination registers') refused(shader(dst=0xff), 'four destination registers') ``` No production change, no new file, no CMake change. ## Tested ```powershell out/pe-env/Scripts/python.exe -B tests/startup_image_gather_lz_check.py Four fixed-mip gather channels and unsupported encodings checked exit 0 ctest --preset dev -R 'gather' 100% tests passed, 0 tests failed out of 4 ``` **Fail-first**, with the guard reduced to `if not dst or dst[0] != 'v':` and reverted afterwards: ```text File ".../tests/startup_image_gather_lz_check.py", line 56, in refused raise AssertionError('Gather accepted an unsupported form: ' + reason) AssertionError: Gather accepted an unsupported form: four destination registers exit 1 ``` and with the guard restored, `exit 0`. The accepted form emits `v256`/`v257` under the mutation, which is what the case prevents. ## Scope note This is the second half of the follow-up I posted on #1927 (`pull/1927#issuecomment-7145688618`). The first half — the `check_gather_sampler(words, 1, …)` argument — I retracted there: `(mips - 1) << 8` is vacuous for both `1` and `0` because `w1 >> 12` is non-negative, so that mutation is equivalent and there is nothing to test. ## Notes - AI-assisted.
upstream-sync closed this pull request 2026-11-24 23:03:13 +00:00
tedin7 commented 2026-11-24 23:03:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T22:09:45Z.

Review: COMMENTED


Review of head fd9999528c442187519f9396a0da9e92be6ad2f4.

The change touches only tests/startup_image_gather_lz_check.py. It adds a dst parameter to the shader() helper and two refusal controls: destination bases 0xfe and 0xff must be refused with "four destination registers". The default dst=4 encodes the same bytes as before (0x00c40400). No CMake change and no new files. Clean-room: no external code.

Commands executed locally:

  • git merge-tree --write-tree --name-only origin/main HEAD: clean, no conflicts
  • python3 -B tests/startup_image_gather_lz_check.py: PASS
  • python3 tests/docs_links_check.py: PASS (18 files, 386 links)
  • python3 tests/bidi_controls_check.py: PASS
  • git diff --check origin/main...HEAD: clean
  • python3 x2w_pipe.py win2025 1953 --wait 900: Debug and Release /O2, startup_image_gather_lz and startup_image_gather_lz_warp 2/2 passed in each
  • gh pr checks 1953: Windows, Linux and gfx1013 fixtures pass

Mutation killed: in tools/startup/gfx2hlsl.py I removed the or dst[2] > 255 bound from the gather destination check. The test now fails with Gather accepted an unsupported form: four destination registers. The file was restored with git checkout -- ..

P1: 0. P2: 0.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6048197501 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1953#pullrequestreview-6048197501). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T22:09:45Z. **Review:** COMMENTED --- Review of head `fd9999528c442187519f9396a0da9e92be6ad2f4`. The change touches only `tests/startup_image_gather_lz_check.py`. It adds a `dst` parameter to the `shader()` helper and two refusal controls: destination bases `0xfe` and `0xff` must be refused with "four destination registers". The default `dst=4` encodes the same bytes as before (`0x00c40400`). No CMake change and no new files. Clean-room: no external code. Commands executed locally: - `git merge-tree --write-tree --name-only origin/main HEAD`: clean, no conflicts - `python3 -B tests/startup_image_gather_lz_check.py`: PASS - `python3 tests/docs_links_check.py`: PASS (18 files, 386 links) - `python3 tests/bidi_controls_check.py`: PASS - `git diff --check origin/main...HEAD`: clean - `python3 x2w_pipe.py win2025 1953 --wait 900`: Debug and Release /O2, `startup_image_gather_lz` and `startup_image_gather_lz_warp` 2/2 passed in each - `gh pr checks 1953`: Windows, Linux and gfx1013 fixtures pass Mutation killed: in `tools/startup/gfx2hlsl.py` I removed the `or dst[2] > 255` bound from the gather destination check. The test now fails with `Gather accepted an unsupported form: four destination registers`. The file was restored with `git checkout -- .`. P1: 0. P2: 0. 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!1946
No description provided.