startup: refuse a modifier for handlers that do not model one #1771

Merged
triggered02 merged 2 commits from upstream-pr/1778 into main 2026-11-26 01:31:36 +00:00
triggered02 commented 2026-11-24 18:29:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T18:29:30Z.


Fixes #1771. The systematic fix for the class that produced five separate review findings (set_vf op_sel, op_v_cndmask_b32 clamp/mul:2, compare() modifiers, the handlers here, and the interpolation source modifiers found while reviewing this PR).

Problem

Several handlers take the modifier list and never read it, so a modifier their encoding can carry was dropped from the emitted HLSL:

v_mov_b32_e64 v1, v2 clamp               -> v1 = v2;            (clamp dropped)
v_cvt_pkrtz_f16_f32_e64 v1, v2, v3 op_sel:[0,0,1]
                                         -> v1 = f32tof16(F(v2)) | (f32tof16(F(v3)) << 16);   (op_sel dropped)
v_interp_mov_f32_e64 v1, p10, attr0.x clamp
                                         -> v1 = i.fparam0.x;  (clamp dropped)

The interpolations also carry modifiers inside the operand text, which no modifier-list guard can see: v_interp_p1_f32_e64 v1, |v2|, attr0.x silently interpolated the unmodified source because the handler never reads that operand.

Fix

A module-level set names the handlers whose encoding can carry a modifier but whose lowering does not model it, and the dispatch refuses the modifier before the handler runs:

MODIFIER_FREE_HANDLERS = frozenset((
    'op_v_mov_b32', 'op_v_cvt_pkrtz_f16_f32',
    'op_v_interp_p1_f32', 'op_v_interp_p2_f32', 'op_v_interp_mov_f32',
))
...
if handler:
    if mods and handler.__name__ in MODIFIER_FREE_HANDLERS:
        raise Unsupported('%s with %s' % (base, mods))
    return handler(ops, mods)

The two p1/p2 handlers additionally refuse an abs/neg printed on their data-source operand, since that one arrives as operand text rather than as a modifier list.

Scalar-ALU handlers are deliberately absent: their encoding has no modifier field, so nothing can reach them with one; adding them would be noise that cannot be exercised. The test asserts none is in the set.

Test

startup_gfx2hlsl_modifier_free builds VOP1/VOP2/VOP3A encodings from the checked-in decoder's layout, decodes them, then translates. For the interpolations it uses their real operand profile (attr in w1[5:0], channel w1[7:6], data source w1[16:9], abs at w0[9], neg at w1[30]) — an earlier revision of this PR used the generic [V2, 0] layout, which is invalid for those forms and only exercised decoder refusal.

Seventeen checks: the declared set, plain forms translating, each modifier refused per handler, abs/neg on the interpolation data source refused, the attribute channel read from the operand, and no scalar handler in the set.

dev:     12/12 startup_gfx2hlsl* + startup_translator passed
release: startup_gfx2hlsl_modifier_free Passed 0.14 s

Fail-first: removing the dispatch guard fails a clamp on the flat interpolation is refused; dropping a handler from the set fails a mul:2 on the move is refused; removing the p1/p2 source check fails an absolutely-modified p2 source is refused.

What this does not establish

  • That the hardware ignores these modifier bits; the safe side is to refuse, and that is what this does rather than claiming they are no-ops.
  • Anything about executable-backed tests: the dev tree here has no built binaries, so only the Python-level ctests were run.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6588683065 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1778). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T18:29:30Z. --- Fixes #1771. The systematic fix for the class that produced five separate review findings (`set_vf` `op_sel`, `op_v_cndmask_b32` `clamp`/`mul:2`, `compare()` modifiers, the handlers here, and the interpolation source modifiers found while reviewing this PR). ## Problem Several handlers take the modifier list and never read it, so a modifier their encoding can carry was dropped from the emitted HLSL: ``` v_mov_b32_e64 v1, v2 clamp -> v1 = v2; (clamp dropped) v_cvt_pkrtz_f16_f32_e64 v1, v2, v3 op_sel:[0,0,1] -> v1 = f32tof16(F(v2)) | (f32tof16(F(v3)) << 16); (op_sel dropped) v_interp_mov_f32_e64 v1, p10, attr0.x clamp -> v1 = i.fparam0.x; (clamp dropped) ``` The interpolations also carry modifiers **inside the operand text**, which no modifier-list guard can see: `v_interp_p1_f32_e64 v1, |v2|, attr0.x` silently interpolated the unmodified source because the handler never reads that operand. ## Fix A module-level set names the handlers whose encoding can carry a modifier but whose lowering does not model it, and the dispatch refuses the modifier before the handler runs: ```python MODIFIER_FREE_HANDLERS = frozenset(( 'op_v_mov_b32', 'op_v_cvt_pkrtz_f16_f32', 'op_v_interp_p1_f32', 'op_v_interp_p2_f32', 'op_v_interp_mov_f32', )) ... if handler: if mods and handler.__name__ in MODIFIER_FREE_HANDLERS: raise Unsupported('%s with %s' % (base, mods)) return handler(ops, mods) ``` The two p1/p2 handlers additionally refuse an `abs`/`neg` printed on their data-source operand, since that one arrives as operand text rather than as a modifier list. **Scalar-ALU handlers are deliberately absent:** their encoding has no modifier field, so nothing can reach them with one; adding them would be noise that cannot be exercised. The test asserts none is in the set. ## Test `startup_gfx2hlsl_modifier_free` builds VOP1/VOP2/VOP3A encodings from the checked-in decoder's layout, decodes them, then translates. For the interpolations it uses their real operand profile (`attr` in `w1[5:0]`, channel `w1[7:6]`, data source `w1[16:9]`, `abs` at `w0[9]`, `neg` at `w1[30]`) — an earlier revision of this PR used the generic `[V2, 0]` layout, which is invalid for those forms and only exercised decoder refusal. Seventeen checks: the declared set, plain forms translating, each modifier refused per handler, `abs`/`neg` on the interpolation data source refused, the attribute channel read from the operand, and no scalar handler in the set. ``` dev: 12/12 startup_gfx2hlsl* + startup_translator passed release: startup_gfx2hlsl_modifier_free Passed 0.14 s ``` Fail-first: removing the dispatch guard fails *a clamp on the flat interpolation is refused*; dropping a handler from the set fails *a mul:2 on the move is refused*; removing the p1/p2 source check fails *an absolutely-modified p2 source is refused*. ## What this does not establish - That the hardware ignores these modifier bits; the safe side is to refuse, and that is what this does rather than claiming they are no-ops. - Anything about executable-backed tests: the dev tree here has no built binaries, so only the Python-level ctests were run. AI-assisted (Claude Code).
chatgpt-codex-connector[bot commented 2026-11-24 19:01:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T18:33:10Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f8b962f935

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6045112270 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1778#pullrequestreview-6045112270). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T18:33:10Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `f8b962f935` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
tedin7 commented 2026-11-24 19:01:28 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Reviewed at f8b962f93504146bd48466fca293906b9f7a5618.

No P1/P2 defects found in local verification. MODIFIER_FREE_HANDLERS (op_v_mov_b32, op_v_cvt_pkrtz_f16_f32, op_v_interp_p1_f32, op_v_interp_p2_f32, op_v_interp_mov_f32) covers the vector/interpolation handlers in tools/startup/gfx2hlsl.py that accept mods without reading it, and Stage.one rejects non-empty mods with Unsupported before dispatch while leaving scalar-ALU handlers (whose encodings carry no modifier field) unaffected.

Local Verification

  • Linux checks:
    • python3 /root/.local/state/xbox2windows/pipeline/x2w_pipe.py prep-verify 1778 --dir /tmp/rev-sm2-rexb/1778 --json (git_diff_check, docs_links_check, bidi_controls_check, py_compile: all ok)
    • /root/.local/share/x2w-rev-venv/bin/python -B /tmp/rev-sm2-rexb/1778/tests/startup_gfx2hlsl_modifier_free_check.py: PASS
    • All tests/startup_gfx2hlsl*_check.py scripts (9/9): PASS
  • Win2025 Debug (--preset dev) & Release /O2 (--preset release):
    • python3 /root/.local/state/xbox2windows/pipeline/x2w_pipe.py win2025 1778 --regex '^(startup_gfx2hlsl_modifier_free|startup_gfx2hlsl_bit_alu_controls|startup_gfx2hlsl_cndmask_neg|startup_gfx2hlsl_operand_count|startup_gfx2hlsl_sdwa|startup_gfx2hlsl_sdwa_cvt|startup_gfx2hlsl_smem_offset|startup_gfx2hlsl_vcvt_omod|startup_translator)$' --py-checks tests/startup_gfx2hlsl_modifier_free_check.py
    • Debug (--preset dev): 9/9 passed (0.84s), Windows Python check ok (0.15s)
    • Release /O2 (--preset release): 9/9 passed (0.82s)
  • Mutation test:
    • Commented out 'op_v_mov_b32' in MODIFIER_FREE_HANDLERS in tools/startup/gfx2hlsl.py and ran /root/.local/share/x2w-rev-venv/bin/python -B /tmp/rev-sm2-rexb/1778/tests/startup_gfx2hlsl_modifier_free_check.py: FAIL (rc=1 on the declared modifier-free handlers are exactly these five, a clamp on the move is refused, a mul:2 on the move is refused), then restored with git checkout -- ..

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6045198141 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1778#pullrequestreview-6045198141). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T18:39:33Z. **Review:** COMMENTED --- Reviewed at `f8b962f93504146bd48466fca293906b9f7a5618`. No P1/P2 defects found in local verification. `MODIFIER_FREE_HANDLERS` (`op_v_mov_b32`, `op_v_cvt_pkrtz_f16_f32`, `op_v_interp_p1_f32`, `op_v_interp_p2_f32`, `op_v_interp_mov_f32`) covers the vector/interpolation handlers in `tools/startup/gfx2hlsl.py` that accept `mods` without reading it, and `Stage.one` rejects non-empty `mods` with `Unsupported` before dispatch while leaving scalar-ALU handlers (whose encodings carry no modifier field) unaffected. ### Local Verification - **Linux checks**: - `python3 /root/.local/state/xbox2windows/pipeline/x2w_pipe.py prep-verify 1778 --dir /tmp/rev-sm2-rexb/1778 --json` (`git_diff_check`, `docs_links_check`, `bidi_controls_check`, `py_compile`: all ok) - `/root/.local/share/x2w-rev-venv/bin/python -B /tmp/rev-sm2-rexb/1778/tests/startup_gfx2hlsl_modifier_free_check.py`: **PASS** - All `tests/startup_gfx2hlsl*_check.py` scripts (9/9): **PASS** - **Win2025 Debug (`--preset dev`) & Release `/O2` (`--preset release`)**: - `python3 /root/.local/state/xbox2windows/pipeline/x2w_pipe.py win2025 1778 --regex '^(startup_gfx2hlsl_modifier_free|startup_gfx2hlsl_bit_alu_controls|startup_gfx2hlsl_cndmask_neg|startup_gfx2hlsl_operand_count|startup_gfx2hlsl_sdwa|startup_gfx2hlsl_sdwa_cvt|startup_gfx2hlsl_smem_offset|startup_gfx2hlsl_vcvt_omod|startup_translator)$' --py-checks tests/startup_gfx2hlsl_modifier_free_check.py` - Debug (`--preset dev`): **9/9 passed** (`0.84s`), Windows Python check ok (`0.15s`) - Release `/O2` (`--preset release`): **9/9 passed** (`0.82s`) - **Mutation test**: - Commented out `'op_v_mov_b32'` in `MODIFIER_FREE_HANDLERS` in `tools/startup/gfx2hlsl.py` and ran `/root/.local/share/x2w-rev-venv/bin/python -B /tmp/rev-sm2-rexb/1778/tests/startup_gfx2hlsl_modifier_free_check.py`: **FAIL** (`rc=1` on `the declared modifier-free handlers are exactly these five`, `a clamp on the move is refused`, `a mul:2 on the move is refused`), then restored with `git checkout -- .`. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-24 19:01:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T18:29:43Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T18:33:12.783740Z f8b962f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7140723932 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1778#issuecomment-7140723932). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T18:29:43Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"f8b962f93504146bd48466fca293906b9f7a5618","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T18:33:12.783740Z">2026-11-24T18:33:12.783740Z</relative-time> | `f8b962f` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
triggered02 commented 2026-11-24 19:01:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T18:38:36Z.


Fixed in 00479dc9. You are right on both counts, and the second one matters more than the first.

The finding: the p1/p2 forms have their own VOP3 operand profile — data source in w1[16:9], abs at w0[9], neg at w1[30] — and the decoder prints those modifiers inside the operand text (|v2|, -v2) rather than as a modifier list, so the dispatch guard passes and the handlers, which never read that operand, silently produced the unmodified interpolation:

v_interp_p1_f32_e64 v1, |v2|, attr0.x  -> attrs {0: {'linear'}}, no line   (modifier dropped)
v_interp_p2_f32_e64 v1, |v2|, attr0.x  -> v1 = U(i.param0.x);              (modifier dropped)

Both handlers now refuse a modified data source (interpolation source modifier |v2|).

My fixture was the worse mistake: the earlier p1/p2 checks used the generic [V2, 0] layout, which is invalid for these forms, so they only proved the decoder rejects a malformed word — exactly the "hand-written assembly that never exercises the path" trap. The test now builds the real profile (attr in w1[5:0], channel w1[7:6], source w1[16:9]) and checks:

a plain p1 interpolation translates
a plain p2 interpolation translates        -> v1 = U(i.param0.x);
the attribute channel is read from the operand -> v1 = U(i.param1.y);
an absolutely-modified p1 source is refused
a negated p1 source is refused
an absolutely-modified p2 source is refused
a clamp on the p1 interpolation is refused   (that one arrives through mods)

17 checks pass, dev startup_gfx2hlsl* + startup_translator 12/12, and fail-first removing the refusal fails at an absolutely-modified p2 source is refused.

Thanks for catching the invalid fixture — a passing test built on a word the assembler would never emit is worse than no test, and this is the second time that shape has hidden a gap in my work.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7140932210 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1778#issuecomment-7140932210). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T18:38:36Z. --- Fixed in `00479dc9`. You are right on both counts, and the second one matters more than the first. **The finding:** the p1/p2 forms have their own VOP3 operand profile — data source in `w1[16:9]`, `abs` at `w0[9]`, `neg` at `w1[30]` — and the decoder prints those modifiers **inside the operand text** (`|v2|`, `-v2`) rather than as a modifier list, so the dispatch guard passes and the handlers, which never read that operand, silently produced the unmodified interpolation: ``` v_interp_p1_f32_e64 v1, |v2|, attr0.x -> attrs {0: {'linear'}}, no line (modifier dropped) v_interp_p2_f32_e64 v1, |v2|, attr0.x -> v1 = U(i.param0.x); (modifier dropped) ``` Both handlers now refuse a modified data source (`interpolation source modifier |v2|`). **My fixture was the worse mistake:** the earlier p1/p2 checks used the generic `[V2, 0]` layout, which is invalid for these forms, so they only proved the decoder rejects a malformed word — exactly the "hand-written assembly that never exercises the path" trap. The test now builds the real profile (`attr` in `w1[5:0]`, channel `w1[7:6]`, source `w1[16:9]`) and checks: ``` a plain p1 interpolation translates a plain p2 interpolation translates -> v1 = U(i.param0.x); the attribute channel is read from the operand -> v1 = U(i.param1.y); an absolutely-modified p1 source is refused a negated p1 source is refused an absolutely-modified p2 source is refused a clamp on the p1 interpolation is refused (that one arrives through mods) ``` 17 checks pass, dev `startup_gfx2hlsl*` + `startup_translator` 12/12, and fail-first removing the refusal fails at `an absolutely-modified p2 source is refused`. Thanks for catching the invalid fixture — a passing test built on a word the assembler would never emit is worse than no test, and this is the second time that shape has hidden a gap in my work. AI-assisted (Claude Code).
chatgpt-codex-connector[bot commented 2026-11-24 19:01:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T18:33:10Z.

Code review location: tools/startup/gfx2hlsl.py; line 388

@@ -374,6 +385,8 @@ def one(self, name, asm):
             return self.export(asm)
         handler = getattr(self, 'op_' + base, None)
         if handler:
+            if mods and handler.__name__ in MODIFIER_FREE_HANDLERS:

P2 Badge Reject source modifiers on valid P1/P2 forms

For a valid gfx10 VOP3 P1/P2 instruction, _decode_interp_f32_e64 renders source abs/neg in the operand, so parse() leaves mods empty and this guard passes; op_v_interp_p1_f32 and op_v_interp_p2_f32 then ignore ops[1] and lower the instruction as if the source were unmodified. The new P1/P2 checks use the generic [V2, 0] VOP3 layout, which is invalid for these interpolation forms and only tests decoder failure. Reject or handle source modifiers, and test a valid interpolation encoding.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4684726740 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1778#discussion_r4684726740). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T18:33:10Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 388 ~~~~diff @@ -374,6 +385,8 @@ def one(self, name, asm): return self.export(asm) handler = getattr(self, 'op_' + base, None) if handler: + if mods and handler.__name__ in MODIFIER_FREE_HANDLERS: ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Reject source modifiers on valid P1/P2 forms** For a valid gfx10 VOP3 P1/P2 instruction, `_decode_interp_f32_e64` renders source `abs`/`neg` in the operand, so `parse()` leaves `mods` empty and this guard passes; `op_v_interp_p1_f32` and `op_v_interp_p2_f32` then ignore `ops[1]` and lower the instruction as if the source were unmodified. The new P1/P2 checks use the generic `[V2, 0]` VOP3 layout, which is invalid for these interpolation forms and only tests decoder failure. Reject or handle source modifiers, and test a valid interpolation encoding. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
roansystemlabs commented 2026-11-24 21:01:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-24T20:18:24Z.


Small note on the fixture: encode_vop3a(VOP3A_INTERP_MOV, 1, [0, 0]) sets src1 = 0, which the decoder prints as p10, not p0, so the "plain flat interpolation" control pins the P10 selector as accepted. p0 is src1 = 2. The selector itself being ignored is a separate gap; I've opened #1890 for it so this PR can stay about modifiers.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7143339139 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1778#issuecomment-7143339139). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-24T20:18:24Z. --- Small note on the fixture: `encode_vop3a(VOP3A_INTERP_MOV, 1, [0, 0])` sets src1 = 0, which the decoder prints as `p10`, not `p0`, so the "plain flat interpolation" control pins the P10 selector as accepted. `p0` is src1 = 2. The selector itself being ignored is a separate gap; I've opened #1890 for it so this PR can stay about modifiers. AI-assisted.
ChazY11 commented 2026-11-24 21:01:22 +00:00 (Migrated from github.com)

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


Ran it; the guard, the list and the self-check all fail when broken

At the PR head, device-free:

out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_modifier_free_check.py
no scalar handler is declared modifier-free: ok
PASS      exit 0

Three mutations to tools/startup/gfx2hlsl.py, each reverted:

mutation result
op_v_mov_b32 removed from MODIFIER_FREE_HANDLERS caught
if mods and handler.__name__ in MODIFIER_FREE_HANDLERS: → if False: caught
a SALU handler (op_s_mov_b32) added to the set caught

The third is the one I would not have expected a fixture to catch: the set is a hand-maintained list, and a later contributor
dropping a SALU name into it would be silently wrong (SALU encodings carry no modifier field, so the refusal could never fire
for a real instruction). The check derives the SALU handler names and refuses to see them in the set, which turns a
list-maintenance mistake into a failure.

Why this shape is right for the class

#1771 was one bug in five places (set_vf op_sel, op_v_cndmask_b32 clamp/mul, compare() modifiers, these handlers,
and the interpolation modifiers). A per-handler guard would have to be remembered each time; the single
if mods and handler.__name__ in MODIFIER_FREE_HANDLERS at the dispatch point makes the default "refuse unless the handler
opts in", and the fixture fails if the list and the handlers disagree.

One consequence worth stating in the description: a handler that does model a modifier must not be in the set, so adding
support for clamp on v_mov_b32 later means removing the name. That is the intended workflow, but nothing forces the two
edits to happen together beyond this check.

Scope

Three files (gfx2hlsl.py +19/-0, one new check, CMakeLists.txt +3), no draw mode, no hardware. The docs/experiments.md
row follows the same shape as its neighbours.

Verdict

Reviewed. Every part of the mechanism is pinned by a mutation, including the list's self-consistency. No objections.

Notes

  • AI-assisted review.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7143690911 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1778#issuecomment-7143690911). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T20:32:00Z. --- ## Ran it; the guard, the list and the self-check all fail when broken At the PR head, device-free: ```powershell out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_modifier_free_check.py no scalar handler is declared modifier-free: ok PASS exit 0 ``` Three mutations to `tools/startup/gfx2hlsl.py`, each reverted: | mutation | result | |---|---| | `op_v_mov_b32` removed from `MODIFIER_FREE_HANDLERS` | **caught** | | `if mods and handler.__name__ in MODIFIER_FREE_HANDLERS:` → `if False:` | **caught** | | a SALU handler (`op_s_mov_b32`) added to the set | **caught** | The third is the one I would not have expected a fixture to catch: the set is a hand-maintained list, and a later contributor dropping a SALU name into it would be silently wrong (SALU encodings carry no modifier field, so the refusal could never fire for a real instruction). The check derives the SALU handler names and refuses to see them in the set, which turns a list-maintenance mistake into a failure. ## Why this shape is right for the class `#1771` was one bug in five places (`set_vf` `op_sel`, `op_v_cndmask_b32` clamp/mul, `compare()` modifiers, these handlers, and the interpolation modifiers). A per-handler guard would have to be remembered each time; the single `if mods and handler.__name__ in MODIFIER_FREE_HANDLERS` at the dispatch point makes the default "refuse unless the handler opts in", and the fixture fails if the list and the handlers disagree. One consequence worth stating in the description: a handler that *does* model a modifier must not be in the set, so adding support for `clamp` on `v_mov_b32` later means removing the name. That is the intended workflow, but nothing forces the two edits to happen together beyond this check. ## Scope Three files (`gfx2hlsl.py` +19/-0, one new check, `CMakeLists.txt` +3), no draw mode, no hardware. The `docs/experiments.md` row follows the same shape as its neighbours. ## Verdict Reviewed. Every part of the mechanism is pinned by a mutation, including the list's self-consistency. No objections. ## Notes - AI-assisted review.
tedin7 commented 2026-11-25 13:01:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:53:36Z.


@triggered02 could you rebase this branch onto current main and force-push?

GitHub reports head 00479dc9 as conflicting with main, so it cannot be merged as is.

Files that conflict with current main (cf97bee1):

  • CMakeLists.txt
  • tools/startup/gfx2hlsl.py

Commands run locally:

git fetch origin main pull/1778/head
git merge-tree --write-tree --name-only origin/main FETCH_HEAD
gh pr view 1778 --json mergeable   # CONFLICTING

Once it is rebased and CI is green it will be re-checked right away.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7163002024 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1778#issuecomment-7163002024). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T12:53:36Z. --- @triggered02 could you rebase this branch onto current `main` and force-push? GitHub reports head `00479dc9` as conflicting with `main`, so it cannot be merged as is. Files that conflict with current `main` (`cf97bee1`): - `CMakeLists.txt` - `tools/startup/gfx2hlsl.py` Commands run locally: ``` git fetch origin main pull/1778/head git merge-tree --write-tree --name-only origin/main FETCH_HEAD gh pr view 1778 --json mergeable # CONFLICTING ``` Once it is rebased and CI is green it will be re-checked right away. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 14:04:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:32:52Z.

Review: COMMENTED


Review of head 7a72fab0fe42780f7a4c3f063582c880610e9a2d.

Summary: The change is correct in intent. The modifier refusal for v_mov_b32, v_cvt_pkrtz_f16_f32 and the interpolation handlers is sound, and the new test kills my mutations. One existing test now fails, so this is not mergeable as is.

P1: existing test regresses

  • tests/startup_gfx2hlsl_readfirstlane_uniform_check.py:111: modified move overwrite refused: MISMATCH "v_mov_b32 with ['clamp']". The case v_mov_b32_e32 v7, s2 clamp is still refused, but now by the dispatch guard (tools/startup/gfx2hlsl.py:691) before the readfirstlane code runs. The test expects the readfirstlane refusal text, so it reports 1 failure.
  • This test passes on origin/main (0 failed). The PR registers a new CTest but does not update this one.
  • Fix: add 'modified move overwrite': "v_mov_b32 with ['clamp']" to the EARLIER map (next to the existing op_sel overwrite entry, just after the REFUSED list). If the case was meant to reach the readfirstlane path, use a modifier that is not refused earlier.

P2: none.

Nits

  • tools/startup/gfx2hlsl.py:308-315: MODIFIER_FREE_HANDLERS is followed directly by def smem_mods with no blank lines, and the two blank lines before class Stage (line 340) were removed. This breaks PEP8 spacing (E302/E305).

Checked and fine

  • The guard sits before handler(ops, mods), so it covers every handler in the set. handler.__name__ matches the declared names.
  • The p1/p2 abs/neg refusal on ops[1] is needed because the decoder prints it inside the operand, not as a mod.
  • Title is neutral. No clean-room problems seen. No CI checks are reported for the branch.

Commands run locally (worktree at the head SHA)

  • python3 -B tests/startup_gfx2hlsl_modifier_free_check.py -> PASS
  • all tests/startup_gfx2hlsl_*_check.py (31 files) -> 1 FAIL: startup_gfx2hlsl_readfirstlane_uniform_check.py (passes on origin/main)
  • python3 tests/docs_links_check.py -> ok (18 files, 395 links)
  • python3 tests/bidi_controls_check.py -> ok
  • git diff --check origin/main...HEAD -> clean
  • Mutation 1: removed op_v_cvt_pkrtz_f16_f32 from the set -> new test fails (MISMATCH)
  • Mutation 2: disabled the dispatch guard -> new test fails (6 MISMATCH)
  • Mutation 3: disabled the p1/p2 source-modifier check -> new test fails (3 MISMATCH)
  • Windows WARP run: not needed. The change only adds refusals in Python and emits no new HLSL.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6058545091 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1778#pullrequestreview-6058545091). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T13:32:52Z. **Review:** COMMENTED --- Review of head `7a72fab0fe42780f7a4c3f063582c880610e9a2d`. **Summary:** The change is correct in intent. The modifier refusal for `v_mov_b32`, `v_cvt_pkrtz_f16_f32` and the interpolation handlers is sound, and the new test kills my mutations. One existing test now fails, so this is not mergeable as is. **P1: existing test regresses** - `tests/startup_gfx2hlsl_readfirstlane_uniform_check.py:111`: `modified move overwrite refused: MISMATCH "v_mov_b32 with ['clamp']"`. The case `v_mov_b32_e32 v7, s2 clamp` is still refused, but now by the dispatch guard (`tools/startup/gfx2hlsl.py:691`) before the readfirstlane code runs. The test expects the readfirstlane refusal text, so it reports 1 failure. - This test passes on `origin/main` (0 failed). The PR registers a new CTest but does not update this one. - Fix: add `'modified move overwrite': "v_mov_b32 with ['clamp']"` to the `EARLIER` map (next to the existing `op_sel overwrite` entry, just after the `REFUSED` list). If the case was meant to reach the readfirstlane path, use a modifier that is not refused earlier. **P2: none.** **Nits** - `tools/startup/gfx2hlsl.py:308-315`: `MODIFIER_FREE_HANDLERS` is followed directly by `def smem_mods` with no blank lines, and the two blank lines before `class Stage` (line 340) were removed. This breaks PEP8 spacing (E302/E305). **Checked and fine** - The guard sits before `handler(ops, mods)`, so it covers every handler in the set. `handler.__name__` matches the declared names. - The p1/p2 abs/neg refusal on `ops[1]` is needed because the decoder prints it inside the operand, not as a mod. - Title is neutral. No clean-room problems seen. No CI checks are reported for the branch. **Commands run locally (worktree at the head SHA)** - `python3 -B tests/startup_gfx2hlsl_modifier_free_check.py` -> PASS - all `tests/startup_gfx2hlsl_*_check.py` (31 files) -> 1 FAIL: `startup_gfx2hlsl_readfirstlane_uniform_check.py` (passes on `origin/main`) - `python3 tests/docs_links_check.py` -> ok (18 files, 395 links) - `python3 tests/bidi_controls_check.py` -> ok - `git diff --check origin/main...HEAD` -> clean - Mutation 1: removed `op_v_cvt_pkrtz_f16_f32` from the set -> new test fails (MISMATCH) - Mutation 2: disabled the dispatch guard -> new test fails (6 MISMATCH) - Mutation 3: disabled the p1/p2 source-modifier check -> new test fails (3 MISMATCH) - Windows WARP run: not needed. The change only adds refusals in Python and emits no new HLSL. AI-assisted; commands listed were executed locally.
triggered02 commented 2026-11-25 14:05:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-25T13:24:14Z.


Rebased onto current main and force-pushed.

  • #1821 (src_scc): merged main in, resolved the CMakeLists.txt registration conflict keeping both sides, head is 5dc597c1. startup_gfx2hlsl_src_scc and startup_translator pass.
  • #1778 (modifier-free): head 7a72fab0. Merging main surfaced a real behaviour change — v_interp_mov_f32 now decodes the parameter selector as p10, p20, p0 and refuses p10/p20 because they need per-vertex attribute values. My test used the old p0 encoding, which now decodes as p10, so it failed. Fixed the fixture (src1 = 2 for p0) and added checks that p10 and p20 are refused rather than read as p0. startup_gfx2hlsl_modifier_free and startup_translator pass.
  • #1722 (1D sampling): head b96eb6b7; the only conflict was an older docs/experiments.md paragraph you had since rewritten, so I kept main's version of it and dropped my wording-only change there. startup_gfx2hlsl_image_1d, startup_image_sample_l and startup_translator pass.

Two of the five I closed rather than rebased, because their content is already on main or duplicated:

  • #1856 (binary16 class compare): main already has the class16 helper, the v_cmp_class_f16/v_cmpx_class_f16 dispatch and tests/startup_gfx2hlsl_cmp_class_f16_check.py, so the branch was integrated directly and the PR was redundant.
  • #1793 (v_mul_hi_u32): duplicated by #1747, which is earlier and carries binary/draw modes with a hardware draw under fxc and dxc. I commented there with the two things worth porting from mine (the instruction-byte construction note and the edge-case list) and deferred to that PR.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7163726358 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1778#issuecomment-7163726358). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-25T13:24:14Z. --- Rebased onto current `main` and force-pushed. - `#1821` (`src_scc`): merged `main` in, resolved the `CMakeLists.txt` registration conflict keeping both sides, head is `5dc597c1`. `startup_gfx2hlsl_src_scc` and `startup_translator` pass. - `#1778` (modifier-free): head `7a72fab0`. Merging `main` surfaced a real behaviour change — `v_interp_mov_f32` now decodes the parameter selector as `p10, p20, p0` and refuses `p10`/`p20` because they need per-vertex attribute values. My test used the old `p0` encoding, which now decodes as `p10`, so it failed. Fixed the fixture (`src1 = 2` for `p0`) and added checks that `p10` and `p20` are refused rather than read as `p0`. `startup_gfx2hlsl_modifier_free` and `startup_translator` pass. - `#1722` (1D sampling): head `b96eb6b7`; the only conflict was an older `docs/experiments.md` paragraph you had since rewritten, so I kept `main`'s version of it and dropped my wording-only change there. `startup_gfx2hlsl_image_1d`, `startup_image_sample_l` and `startup_translator` pass. Two of the five I closed rather than rebased, because their content is already on `main` or duplicated: - **#1856** (binary16 class compare): `main` already has the `class16` helper, the `v_cmp_class_f16`/`v_cmpx_class_f16` dispatch and `tests/startup_gfx2hlsl_cmp_class_f16_check.py`, so the branch was integrated directly and the PR was redundant. - **#1793** (`v_mul_hi_u32`): duplicated by #1747, which is earlier and carries `binary`/`draw` modes with a hardware draw under fxc and dxc. I commented there with the two things worth porting from mine (the instruction-byte construction note and the edge-case list) and deferred to that PR. AI-assisted (Claude Code).
tedin7 commented 2026-11-25 14:05:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:24:46Z.


@triggered02 could you rebase this branch onto current main and force-push?

GitHub reports head 7a72fab0 as conflicting with main, so it cannot be merged as is.

Files that conflict with current main (214ed093):

  • CMakeLists.txt
  • docs/experiments.md
  • tools/startup/gfx2hlsl.py

Commands run locally:

git fetch origin main pull/1778/head
git merge-tree --write-tree --name-only origin/main FETCH_HEAD
gh pr view 1778 --json mergeable   # CONFLICTING

Once it is rebased and CI is green it will be re-checked right away.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7163739427 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1778#issuecomment-7163739427). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T13:24:46Z. --- @triggered02 could you rebase this branch onto current `main` and force-push? GitHub reports head `7a72fab0` as conflicting with `main`, so it cannot be merged as is. Files that conflict with current `main` (`214ed093`): - `CMakeLists.txt` - `docs/experiments.md` - `tools/startup/gfx2hlsl.py` Commands run locally: ``` git fetch origin main pull/1778/head git merge-tree --write-tree --name-only origin/main FETCH_HEAD gh pr view 1778 --json mergeable # CONFLICTING ``` Once it is rebased and CI is green it will be re-checked right away. AI-assisted; commands listed were executed locally.
triggered02 commented 2026-11-25 17:01:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-25T16:20:35Z.


Re-created on origin/main (7092683a) as a single clean commit and addressed both items from your review on 7a72fab0:

  1. Fixed P1 (tests/startup_gfx2hlsl_readfirstlane_uniform_check.py): added 'modified move overwrite': "v_mov_b32 with ['clamp']" to EARLIER next to 'op_sel overwrite', since the dispatch guard now refuses v_mov_b32 with clamp before the readfirstlane uniform check runs.
  2. Fixed PEP8 spacing nit (tools/startup/gfx2hlsl.py): two blank lines around MODIFIER_FREE_HANDLERS and before class Stage:.

Measured checks

  • tests/startup_gfx2hlsl_modifier_free_check.py: 20/20 checks ok, PASS.
  • tests/startup_gfx2hlsl_readfirstlane_uniform_check.py: 0 failed.
  • All 62 tests/startup_gfx2hlsl_*_check.py scripts + tests/startup_translator_check.py: 62/62 + startup_translator passed.
  • tests/docs_links_check.py (464 links), tests/bidi_controls_check.py (1,724 files), git diff --check origin/main: clean.
  • Fail-first mutations (removing op_v_cvt_pkrtz_f16_f32 from MODIFIER_FREE_HANDLERS, disabling the dispatch guard, and disabling the op_v_interp_p1_f32/op_v_interp_p2_f32 operand-modifier check) all fail startup_gfx2hlsl_modifier_free_check.py (exit 1).

Not established

  • Only Python translator checks and startup_translator ran on this head (no C++ changes; no Windows CTest executable run on this worktree).

AI-assisted (Gemini).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7167805752 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1778#issuecomment-7167805752). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-25T16:20:35Z. --- Re-created on `origin/main` (`7092683a`) as a single clean commit and addressed both items from your review on `7a72fab0`: 1. **Fixed P1 (`tests/startup_gfx2hlsl_readfirstlane_uniform_check.py`):** added `'modified move overwrite': "v_mov_b32 with ['clamp']"` to `EARLIER` next to `'op_sel overwrite'`, since the dispatch guard now refuses `v_mov_b32` with `clamp` before the readfirstlane uniform check runs. 2. **Fixed PEP8 spacing nit (`tools/startup/gfx2hlsl.py`):** two blank lines around `MODIFIER_FREE_HANDLERS` and before `class Stage:`. ### Measured checks - `tests/startup_gfx2hlsl_modifier_free_check.py`: 20/20 checks `ok`, `PASS`. - `tests/startup_gfx2hlsl_readfirstlane_uniform_check.py`: 0 failed. - All 62 `tests/startup_gfx2hlsl_*_check.py` scripts + `tests/startup_translator_check.py`: 62/62 + `startup_translator` passed. - `tests/docs_links_check.py` (464 links), `tests/bidi_controls_check.py` (1,724 files), `git diff --check origin/main`: clean. - Fail-first mutations (removing `op_v_cvt_pkrtz_f16_f32` from `MODIFIER_FREE_HANDLERS`, disabling the dispatch guard, and disabling the `op_v_interp_p1_f32`/`op_v_interp_p2_f32` operand-modifier check) all fail `startup_gfx2hlsl_modifier_free_check.py` (exit 1). ### Not established - Only Python translator checks and `startup_translator` ran on this head (no C++ changes; no Windows CTest executable run on this worktree). AI-assisted (Gemini).
upstream-sync closed this pull request 2026-11-26 02:04:44 +00:00
R0Y00 commented 2026-11-26 02:04:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T01:31:26Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6067351179 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1778#pullrequestreview-6067351179). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-26T01:31:26Z. **Review:** COMMENTED --- _No description provided._
R0Y00 commented 2026-11-26 02:05:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T01:27:43Z.


I integrated current main in 664d9996. The merged readfirstlane check keeps the new modified-move refusal and the existing lane-mask, VCC and EXEC refusals. The modifier, uniformity, recompute and handler-arity checks passed locally, and the documentation check verified 510 links.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7179795067 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1778#issuecomment-7179795067). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-26T01:27:43Z. --- I integrated current main in `664d9996`. The merged `readfirstlane` check keeps the new modified-move refusal and the existing lane-mask, VCC and EXEC refusals. The modifier, uniformity, recompute and handler-arity checks passed locally, and the documentation check verified 510 links.
R0Y00 commented 2026-11-26 02:05:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T01:31:26Z.

Code review location: tools/startup/gfx2hlsl.py; line 388

@@ -374,6 +385,8 @@ def one(self, name, asm):
             return self.export(asm)
         handler = getattr(self, 'op_' + base, None)
         if handler:
+            if mods and handler.__name__ in MODIFIER_FREE_HANDLERS:

Verified on 664d9996. The fixture now uses the dedicated VOP3 P1/P2 layout and runs plain interpolation before the source-modifier negatives. Both handlers refuse the decoded source abs/neg spellings before producing HLSL. The updated controls and the existing readfirstlane regressions passed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4702894671 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1778#discussion_r4702894671). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-26T01:31:26Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 388 ~~~~diff @@ -374,6 +385,8 @@ def one(self, name, asm): return self.export(asm) handler = getattr(self, 'op_' + base, None) if handler: + if mods and handler.__name__ in MODIFIER_FREE_HANDLERS: ~~~~ --- Verified on 664d9996. The fixture now uses the dedicated VOP3 P1/P2 layout and runs plain interpolation before the source-modifier negatives. Both handlers refuse the decoded source abs/neg spellings before producing HLSL. The updated controls and the existing readfirstlane regressions passed.
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!1771
No description provided.