test: refuse a comparison sample without one dim and dmask #1878

Manually merged
github merged 1 commit from gh-pr/1878/head into gh-pr/1878/base 2026-11-26 23:39:40 +00:00
Owner

@⁠ChazY11 on GitHub · 2026-11-24 19:59 UTC · original
ChazY11:test/image-compare-modifiers → main · +26 −0 · 1 files · 1 commits · merged 2026-11-24 20:08 UTC

What

First case from #1877. image_compare refuses a comparison sample whose modifier list does not carry exactly one dim: and
one dmask::

if len(dims) != 1 or len(masks) != 1:
    raise Unsupported('%s without exactly one dim and dmask' % base)

Replacing that raise with pass left startup_image_3d, startup_image_2d_array, startup_image_load_mip and
startup_image_sample_l green, so nothing exercised it.

Change

A device-free case in startup_image_2d_array_check.py's controls:

for mods in (['dim:SQ_RSRC_IMG_2D'], ['dmask:0x1'],
             ['dim:SQ_RSRC_IMG_2D', 'dim:SQ_RSRC_IMG_2D', 'dmask:0x1']):
    ...  expect Unsupported('image_sample_c without exactly one dim and dmask')

# and the legal list must get past the guard:
stage.image_compare([...], ['dim:SQ_RSRC_IMG_2D', 'dmask:0x1'], 'c')
    -> must NOT raise the dim/dmask message (a bare stage stops later instead)

The three bad lists cover "no dim", "no dmask" and "two dims". The last block is the control that stops the case from passing
because the guard raises on everything.

Tested

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

Negative controls, each reverted:

raise -> pass                                  exit 1
len(...) != 1 or len(...) != 1   ->   < 1       exit 1
reverted                                        exit 0

The second control matters: it keeps the equality of "exactly one" under test, not merely "at least one".

Scope

One test file, one new function called from controls(). Refs #1877; the other two sites in that issue (the sample_l
address-register count and the non-constant sampler) are untouched.

Notes

  • AI-assisted.
**@⁠ChazY11** on GitHub · 2026-11-24 19:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1878) `ChazY11:test/image-compare-modifiers` → `main` · +26 −0 · 1 files · 1 commits · merged 2026-11-24 20:08 UTC ## What First case from #1877. `image_compare` refuses a comparison sample whose modifier list does not carry exactly one `dim:` and one `dmask:`: ```python if len(dims) != 1 or len(masks) != 1: raise Unsupported('%s without exactly one dim and dmask' % base) ``` Replacing that `raise` with `pass` left `startup_image_3d`, `startup_image_2d_array`, `startup_image_load_mip` and `startup_image_sample_l` green, so nothing exercised it. ## Change A device-free case in `startup_image_2d_array_check.py`'s controls: ```python for mods in (['dim:SQ_RSRC_IMG_2D'], ['dmask:0x1'], ['dim:SQ_RSRC_IMG_2D', 'dim:SQ_RSRC_IMG_2D', 'dmask:0x1']): ... expect Unsupported('image_sample_c without exactly one dim and dmask') # and the legal list must get past the guard: stage.image_compare([...], ['dim:SQ_RSRC_IMG_2D', 'dmask:0x1'], 'c') -> must NOT raise the dim/dmask message (a bare stage stops later instead) ``` The three bad lists cover "no dim", "no dmask" and "two dims". The last block is the control that stops the case from passing because the guard raises on everything. ## Tested ```powershell out/pe-env/Scripts/python.exe -B tests/startup_image_2d_array_check.py # exit 0 ``` Negative controls, each reverted: ```text raise -> pass exit 1 len(...) != 1 or len(...) != 1 -> < 1 exit 1 reverted exit 0 ``` The second control matters: it keeps the *equality* of "exactly one" under test, not merely "at least one". ## Scope One test file, one new function called from `controls()`. Refs #1877; the other two sites in that issue (the `sample_l` address-register count and the non-constant sampler) are untouched. ## Notes - AI-assisted.
The guard in image_compare was unreachable: replacing it with pass left the
four image checks green. Call it on a bare stage for three bad modifier lists
and require the named refusal, plus a legal list that must get past the guard.

Refs #1877.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:39:38 +00:00
github manually merged commit 0c32ee1642 into gh-pr/1878/base 2026-11-26 23:39:40 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 20:01 UTC · original · reviewed

Reviewed head 0c32ee1642. Test-only change: one new check, check_compare_modifiers, in tests/startup_image_2d_array_check.py, wired into controls().

What it pins: Stage.image_compare in tools/startup/gfx2hlsl.py must refuse an image_sample_c with no dmask, no dim, or a repeated dim, using the exact message image_sample_c without exactly one dim and dmask. A legal modifier list is also checked to reach a different failure, so the guard is not just raising for everything. This is real refusal logic, not wording or a duplicate of an existing check.

Commands run locally (Linux, head 0c32ee1642):

  • git diff --check origin/main...HEAD: clean, rc=0
  • python -B tests/docs_links_check.py: rc=0 (18 files, 376 links)
  • python -B tests/bidi_controls_check.py: rc=0 (1326 files)
  • python -B tests/startup_image_2d_array_check.py: rc=0

Mutations on tools/startup/gfx2hlsl.py (each reverted with git checkout -- ., tree clean after):

  1. Replaced if len(dims) != 1 or len(masks) != 1: with if False:. The check exits rc=1 (the missing dmask now reaches masks[0] and fails with IndexError).
  2. Replaced it with if len(dims) > 1 or len(masks) > 1: (allows zero). The check exits rc=1 for the same reason.

Minor, non-blocking: the new function is followed by one blank line before def mip_words, where the rest of the file uses two. The last block swallows AttributeError by design and only asserts the message is not the guard message.

No blocking findings.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-24 20:01 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1878#pullrequestreview-6046441281) · **reviewed** Reviewed head 0c32ee16427ff855d3224074ee76f69ddfd7ace7. Test-only change: one new check, `check_compare_modifiers`, in `tests/startup_image_2d_array_check.py`, wired into `controls()`. What it pins: `Stage.image_compare` in `tools/startup/gfx2hlsl.py` must refuse an `image_sample_c` with no dmask, no dim, or a repeated dim, using the exact message `image_sample_c without exactly one dim and dmask`. A legal modifier list is also checked to reach a different failure, so the guard is not just raising for everything. This is real refusal logic, not wording or a duplicate of an existing check. Commands run locally (Linux, head 0c32ee16427ff855d3224074ee76f69ddfd7ace7): - `git diff --check origin/main...HEAD`: clean, rc=0 - `python -B tests/docs_links_check.py`: rc=0 (18 files, 376 links) - `python -B tests/bidi_controls_check.py`: rc=0 (1326 files) - `python -B tests/startup_image_2d_array_check.py`: rc=0 Mutations on `tools/startup/gfx2hlsl.py` (each reverted with `git checkout -- .`, tree clean after): 1. Replaced `if len(dims) != 1 or len(masks) != 1:` with `if False:`. The check exits rc=1 (the missing dmask now reaches `masks[0]` and fails with IndexError). 2. Replaced it with `if len(dims) > 1 or len(masks) > 1:` (allows zero). The check exits rc=1 for the same reason. Minor, non-blocking: the new function is followed by one blank line before `def mip_words`, where the rest of the file uses two. The last block swallows AttributeError by design and only asserts the message is not the guard message. No blocking findings. AI-assisted; commands listed were executed locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.