test: refuse image_sample_l with the wrong address count #1872

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

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T20:00:56Z.


What

Second case from #1877. image_sample_l takes the coordinates and then the explicit level, so the address dwords are three
for a 2D image and four for a volume or a 2D array:

if len(cs) != (4 if three else 3):
    raise Unsupported('image_sample_l with %d address registers' % len(cs))

Replacing that raise with pass left startup_image_3d, startup_image_2d_array, startup_image_load_mip and
startup_image_sample_l green. The refusal is decided from the operands and the modifier list alone — self.pipe is only
touched after it — so a bare stage reaches it:

def call(coords):
    bare = G.Stage.__new__(G.Stage)
    bare.image(['v5', coords, 's0'], ['dim:SQ_RSRC_IMG_2D', 'dmask:0x1'], 'l')

Change

check_address_count() in startup_image_sample_l_check.py:

  • [v1, v2] → image_sample_l with 2 address registers
  • [v1, v2, v3, v4] → image_sample_l with 4 address registers
  • [v1, v2, v3] → must get past the guard (the bare stage then stops where it needs a pipeline)

The third case is the control against a fixture that passes because the guard refuses everything.

Tested

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

Negative controls, each reverted:

raise -> pass                        exit 1
(4 if three else 3) -> (5 if three ...)   exit 1
reverted                             exit 0

The second one is the interesting one: it changes only the volume/array expectation, so the case is pinned to the exact
pair (3, 4) rather than to "some count".

Scope

One test file, one new function called from controls(). Refs #1877; the non-constant sampler site from that issue is still
open.

Notes

  • AI-assisted.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6590290459 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1879). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T20:00:56Z. --- ## What Second case from #1877. `image_sample_l` takes the coordinates and then the explicit level, so the address dwords are three for a 2D image and four for a volume or a 2D array: ```python if len(cs) != (4 if three else 3): raise Unsupported('image_sample_l with %d address registers' % len(cs)) ``` Replacing that `raise` with `pass` left `startup_image_3d`, `startup_image_2d_array`, `startup_image_load_mip` and `startup_image_sample_l` green. The refusal is decided from the operands and the modifier list alone — `self.pipe` is only touched after it — so a bare stage reaches it: ```python def call(coords): bare = G.Stage.__new__(G.Stage) bare.image(['v5', coords, 's0'], ['dim:SQ_RSRC_IMG_2D', 'dmask:0x1'], 'l') ``` ## Change `check_address_count()` in `startup_image_sample_l_check.py`: - `[v1, v2]` → `image_sample_l with 2 address registers` - `[v1, v2, v3, v4]` → `image_sample_l with 4 address registers` - `[v1, v2, v3]` → must get **past** the guard (the bare stage then stops where it needs a pipeline) The third case is the control against a fixture that passes because the guard refuses everything. ## Tested ```powershell out/pe-env/Scripts/python.exe -B tests/startup_image_sample_l_check.py # exit 0 ``` Negative controls, each reverted: ```text raise -> pass exit 1 (4 if three else 3) -> (5 if three ...) exit 1 reverted exit 0 ``` The second one is the interesting one: it changes only the *volume/array* expectation, so the case is pinned to the exact pair (3, 4) rather than to "some count". ## Scope One test file, one new function called from `controls()`. Refs #1877; the non-constant sampler site from that issue is still open. ## Notes - AI-assisted.
upstream-sync closed this pull request 2026-11-24 21:01:04 +00:00
tedin7 commented 2026-11-24 21:01:05 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Reviewed head f8b39a5b633aba401bc60e247ec1ae905799e8f6. No P1/P2 findings.

The new check_address_count runs Stage.image on a bare stage with a 2D image_sample_l. It asserts that 2 and 4 address registers are refused with the exact message image_sample_l with N address registers. It also checks that a legal count of 3 gets past that guard. This matches the len(cs) != (4 if three else 3) check in tools/startup/gfx2hlsl.py, which runs from the operands and modifiers alone, before self.pipe is used. The test is test-only, calls the code under test rather than a copy of its logic, and uses no outside material. controls() calls it first.

Linux commands run in a clean worktree:

  • git diff --check origin/main...HEAD -> rc 0
  • python -B tests/docs_links_check.py -> rc 0
  • python -B tests/bidi_controls_check.py -> rc 0
  • python -B tests/startup_image_sample_l_check.py -> rc 0

Mutations in tools/startup/gfx2hlsl.py (each reverted with git checkout -- .; startup_image_sample_l_check.py run each time):

  1. Address-count guard disabled -> FAILS (rc 1).
  2. 2D case expects 4 registers -> FAILS (rc 1).
  3. Refusal message reworded -> FAILS (rc 1, assertion on the exact text).
  4. Every dimension expects 3 registers -> FAILS (rc 1, caught by another 3D control in the same file).

Notes, not blocking:

  • When the guard is disabled, the failure is an AttributeError on pipe rather than the test's own "accepted N address registers" message. It is still a failure, and the message only matters for debugging.
  • The 3D and 2D-array counts are covered by other cases in the file, not by this new test.
  • There is one blank line before def controls() where two are conventional. This has no effect.

This is a review comment only, not an approval.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6046533514 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1879#pullrequestreview-6046533514). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T20:08:10Z. **Review:** COMMENTED --- Reviewed head `f8b39a5b633aba401bc60e247ec1ae905799e8f6`. No P1/P2 findings. The new `check_address_count` runs `Stage.image` on a bare stage with a 2D `image_sample_l`. It asserts that 2 and 4 address registers are refused with the exact message `image_sample_l with N address registers`. It also checks that a legal count of 3 gets past that guard. This matches the `len(cs) != (4 if three else 3)` check in `tools/startup/gfx2hlsl.py`, which runs from the operands and modifiers alone, before `self.pipe` is used. The test is test-only, calls the code under test rather than a copy of its logic, and uses no outside material. `controls()` calls it first. Linux commands run in a clean worktree: - `git diff --check origin/main...HEAD` -> rc 0 - `python -B tests/docs_links_check.py` -> rc 0 - `python -B tests/bidi_controls_check.py` -> rc 0 - `python -B tests/startup_image_sample_l_check.py` -> rc 0 Mutations in `tools/startup/gfx2hlsl.py` (each reverted with `git checkout -- .`; `startup_image_sample_l_check.py` run each time): 1. Address-count guard disabled -> FAILS (rc 1). 2. 2D case expects 4 registers -> FAILS (rc 1). 3. Refusal message reworded -> FAILS (rc 1, assertion on the exact text). 4. Every dimension expects 3 registers -> FAILS (rc 1, caught by another 3D control in the same file). Notes, not blocking: - When the guard is disabled, the failure is an `AttributeError` on `pipe` rather than the test's own "accepted N address registers" message. It is still a failure, and the message only matters for debugging. - The 3D and 2D-array counts are covered by other cases in the file, not by this new test. - There is one blank line before `def controls()` where two are conventional. This has no effect. This is a review comment only, not an approval. 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!1872
No description provided.