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

Merged
ChazY11 merged 1 commit from upstream-pr/1878 into main 2026-11-24 20:08:33 +00:00
ChazY11 commented 2026-11-24 19:59:52 +00:00 (Migrated from github.com)

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


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.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6590271737 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1878). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T19:59:52Z. --- ## 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.
upstream-sync closed this pull request 2026-11-24 21:01:04 +00:00
tedin7 commented 2026-11-24 21:01:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T20:01:34Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6046441281 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1878#pullrequestreview-6046441281). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T20:01:34Z. **Review:** COMMENTED --- 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.
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!1871
No description provided.