test: pin two integer-op refusals in the translator #1773

Merged
ChazY11 merged 1 commit from upstream-pr/1780 into main 2026-11-24 18:46:57 +00:00
ChazY11 commented 2026-11-24 18:31:58 +00:00 (Migrated from github.com)

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


What

Two operations in tools/startup/gfx2hlsl.py refuse an input they cannot model, and no check reached either raise:

def op_v_cvt_i32_f32(self, ops, mods):
    if mods: raise Unsupported('v_cvt_i32_f32 with modifiers')

def op_v_readfirstlane_b32(self, ops, mods):
    if (mods or self.has_branches or not self.exec_known or not dst or dst[0] != 's' or
            not src or src[0] != 'v' or src[1] not in self.uniform_v):
        raise Unsupported('v_readfirstlane_b32 requires a proven uniform source')

Replacing either raise with pass left all eleven startup_gfx2hlsl_* checks green.

Change

A new device-free check that calls both operations directly on a bare Stage and requires the refusal, with a legal
three-argument form so the assertions cannot pass by refusing everything:

refused(lambda: stage().op_v_cvt_i32_f32(['v1', 'v2'], ['clamp']), 'v_cvt_i32_f32 with modifiers')
refused(lambda: stage().op_v_readfirstlane_b32(['s1', 'v2'], []),
        'v_readfirstlane_b32 requires a proven uniform source')
refused(lambda: stage(uniform_v={2}).op_v_readfirstlane_b32(['s1', 'v2'], ['clamp']),
        'v_readfirstlane_b32 requires a proven uniform source')

The third case is the one that separates the two clauses: with the source proven uniform, the modifier alone still
refuses, so a future edit that only checks uniformity is caught.

Registered as startup_gfx2hlsl_op_refusals with TIMEOUT 60 next to the other gfx2hlsl checks.

Tested

cmake --preset dev
ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_' -v
100% tests passed, 0 tests failed out of 11      (startup_gfx2hlsl_op_refusals Passed 0.26 s)

Negative controls, each reverted:

cvt raise -> pass                        startup_gfx2hlsl_op_refusals FAILED
readfirstlane condition -> if False:     startup_gfx2hlsl_op_refusals FAILED
reverted                                 passed

Also noted while probing

Six other refusals in the same file are unreached by every check I ran — SDWA UNUSED_SEXT, an unknown modifier %s,
mask from descriptor data, v_readfirstlane's siblings, unverified pixel input enable/address combination, and
mask from descriptor data's neighbours. I did not write cases for them: each needs a specific word pattern rather than a
direct call, and I would be guessing at what the decoder can be fed. This PR is only the two that take a direct call.

Notes

  • AI-assisted.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6588722614 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1780). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T18:31:58Z. --- ## What Two operations in `tools/startup/gfx2hlsl.py` refuse an input they cannot model, and no check reached either raise: ```python def op_v_cvt_i32_f32(self, ops, mods): if mods: raise Unsupported('v_cvt_i32_f32 with modifiers') def op_v_readfirstlane_b32(self, ops, mods): if (mods or self.has_branches or not self.exec_known or not dst or dst[0] != 's' or not src or src[0] != 'v' or src[1] not in self.uniform_v): raise Unsupported('v_readfirstlane_b32 requires a proven uniform source') ``` Replacing either `raise` with `pass` left all eleven `startup_gfx2hlsl_*` checks green. ## Change A new device-free check that calls both operations directly on a bare `Stage` and requires the refusal, with a legal three-argument form so the assertions cannot pass by refusing everything: ```python refused(lambda: stage().op_v_cvt_i32_f32(['v1', 'v2'], ['clamp']), 'v_cvt_i32_f32 with modifiers') refused(lambda: stage().op_v_readfirstlane_b32(['s1', 'v2'], []), 'v_readfirstlane_b32 requires a proven uniform source') refused(lambda: stage(uniform_v={2}).op_v_readfirstlane_b32(['s1', 'v2'], ['clamp']), 'v_readfirstlane_b32 requires a proven uniform source') ``` The third case is the one that separates the two clauses: with the source *proven uniform*, the modifier alone still refuses, so a future edit that only checks uniformity is caught. Registered as `startup_gfx2hlsl_op_refusals` with `TIMEOUT 60` next to the other `gfx2hlsl` checks. ## Tested ```powershell cmake --preset dev ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_' -v ``` ```text 100% tests passed, 0 tests failed out of 11 (startup_gfx2hlsl_op_refusals Passed 0.26 s) ``` Negative controls, each reverted: ```text cvt raise -> pass startup_gfx2hlsl_op_refusals FAILED readfirstlane condition -> if False: startup_gfx2hlsl_op_refusals FAILED reverted passed ``` ## Also noted while probing Six other refusals in the same file are unreached by every check I ran — `SDWA UNUSED_SEXT`, an unknown `modifier %s`, `mask from descriptor data`, `v_readfirstlane`'s siblings, `unverified pixel input enable/address combination`, and `mask from descriptor data`'s neighbours. I did not write cases for them: each needs a specific word pattern rather than a direct call, and I would be guessing at what the decoder can be fed. This PR is only the two that take a direct call. ## Notes - AI-assisted.
upstream-sync closed this pull request 2026-11-24 19:01:29 +00:00
tedin7 commented 2026-11-24 19:01:29 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Verified commit 58a796ce6380278b58a4ae60f25374e915dc92ef — no defects found.

Checks run locally (Linux)

  • git diff --check origin/main...HEAD — passed
  • python -B tests/bidi_controls_check.py — passed (1304 tracked files)
  • python -B tests/startup_gfx2hlsl_op_refusals_check.py — passed (gfx2hlsl op refusals: 3 cases passed)

Mutation controls (reverted cleanly after each)

  1. Replaced raise Unsupported('v_cvt_i32_f32 with modifiers') with pass in tools/startup/gfx2hlsl.py -> tests/startup_gfx2hlsl_op_refusals_check.py failed (exit 1).
  2. Replaced raise Unsupported('v_readfirstlane_b32 requires a proven uniform source') with pass -> failed (exit 1).
  3. Removed mods or from the op_v_readfirstlane_b32 guard -> failed on the uniform-source-with-modifier case (exit 1).

Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)

  • Debug (--preset dev): ctest --preset dev -R '^startup_gfx2hlsl_op_refusals$' --parallel 6 --no-tests=error --output-on-failure — 1/1 passed (0.15s)
  • Release /O2 (--preset release): ctest --preset release -R '^startup_gfx2hlsl_op_refusals$' --parallel 6 --no-tests=error --output-on-failure — 1/1 passed (0.14s)

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6045264940 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1780#pullrequestreview-6045264940). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T18:44:22Z. **Review:** COMMENTED --- Verified commit `58a796ce6380278b58a4ae60f25374e915dc92ef` — no defects found. ### Checks run locally (Linux) - `git diff --check origin/main...HEAD` — passed - `python -B tests/bidi_controls_check.py` — passed (1304 tracked files) - `python -B tests/startup_gfx2hlsl_op_refusals_check.py` — passed (`gfx2hlsl op refusals: 3 cases passed`) ### Mutation controls (reverted cleanly after each) 1. Replaced `raise Unsupported('v_cvt_i32_f32 with modifiers')` with `pass` in `tools/startup/gfx2hlsl.py` -> `tests/startup_gfx2hlsl_op_refusals_check.py` failed (exit 1). 2. Replaced `raise Unsupported('v_readfirstlane_b32 requires a proven uniform source')` with `pass` -> failed (exit 1). 3. Removed `mods or` from the `op_v_readfirstlane_b32` guard -> failed on the uniform-source-with-modifier case (exit 1). ### Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) - **Debug (`--preset dev`)**: `ctest --preset dev -R '^startup_gfx2hlsl_op_refusals$' --parallel 6 --no-tests=error --output-on-failure` — **1/1 passed** (`0.15s`) - **Release `/O2` (`--preset release`)**: `ctest --preset release -R '^startup_gfx2hlsl_op_refusals$' --parallel 6 --no-tests=error --output-on-failure` — **1/1 passed** (`0.14s`) 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!1773
No description provided.