startup: refuse a modifier for handlers that do not model one #1771
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1778"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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_vfop_sel,op_v_cndmask_b32clamp/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:
The interpolations also carry modifiers inside the operand text, which no modifier-list guard can see:
v_interp_p1_f32_e64 v1, |v2|, attr0.xsilently 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:
The two p1/p2 handlers additionally refuse an
abs/negprinted 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_freebuilds VOP1/VOP2/VOP3A encodings from the checked-in decoder's layout, decodes them, then translates. For the interpolations it uses their real operand profile (attrinw1[5:0], channelw1[7:6], data sourcew1[16:9],absatw0[9],negatw1[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/negon the interpolation data source refused, the attribute channel read from the operand, and no scalar handler in the set.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
AI-assisted (Claude Code).
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
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".
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 intools/startup/gfx2hlsl.pythat acceptmodswithout reading it, andStage.onerejects non-emptymodswithUnsupportedbefore dispatch while leaving scalar-ALU handlers (whose encodings carry no modifier field) unaffected.Local Verification
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: PASStests/startup_gfx2hlsl*_check.pyscripts (9/9): PASS--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--preset dev): 9/9 passed (0.84s), Windows Python check ok (0.15s)/O2(--preset release): 9/9 passed (0.82s)'op_v_mov_b32'inMODIFIER_FREE_HANDLERSintools/startup/gfx2hlsl.pyand ran/root/.local/share/x2w-rev-venv/bin/python -B /tmp/rev-sm2-rexb/1778/tests/startup_gfx2hlsl_modifier_free_check.py: FAIL (rc=1onthe 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 withgit checkout -- ..AI-assisted; commands listed were executed locally.
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.
f8b962fℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
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],absatw0[9],negatw1[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: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 (attrinw1[5:0], channelw1[7:6], sourcew1[16:9]) and checks:17 checks pass, dev
startup_gfx2hlsl*+startup_translator12/12, and fail-first removing the refusal fails atan 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).
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 388For a valid gfx10 VOP3 P1/P2 instruction,
_decode_interp_f32_e64renders sourceabs/negin the operand, soparse()leavesmodsempty and this guard passes;op_v_interp_p1_f32andop_v_interp_p2_f32then ignoreops[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 👍 / 👎.
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 asp10, notp0, so the "plain flat interpolation" control pins the P10 selector as accepted.p0is 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.
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:
Three mutations to
tools/startup/gfx2hlsl.py, each reverted:op_v_mov_b32removed fromMODIFIER_FREE_HANDLERSif mods and handler.__name__ in MODIFIER_FREE_HANDLERS:→if False:op_s_mov_b32) added to the setThe 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
#1771was one bug in five places (set_vfop_sel,op_v_cndmask_b32clamp/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_HANDLERSat the dispatch point makes the default "refuse unless the handleropts 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
clamponv_mov_b32later means removing the name. That is the intended workflow, but nothing forces the twoedits to happen together beyond this check.
Scope
Three files (
gfx2hlsl.py+19/-0, one new check,CMakeLists.txt+3), no draw mode, no hardware. Thedocs/experiments.mdrow 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
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:53:36Z.
@triggered02 could you rebase this branch onto current
mainand force-push?GitHub reports head
00479dc9as conflicting withmain, so it cannot be merged as is.Files that conflict with current
main(cf97bee1):CMakeLists.txttools/startup/gfx2hlsl.pyCommands run locally:
Once it is rebased and CI is green it will be re-checked right away.
AI-assisted; commands listed were executed locally.
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_f32and 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 casev_mov_b32_e32 v7, s2 clampis 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.origin/main(0 failed). The PR registers a new CTest but does not update this one.'modified move overwrite': "v_mov_b32 with ['clamp']"to theEARLIERmap (next to the existingop_sel overwriteentry, just after theREFUSEDlist). 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_HANDLERSis followed directly bydef smem_modswith no blank lines, and the two blank lines beforeclass Stage(line 340) were removed. This breaks PEP8 spacing (E302/E305).Checked and fine
handler(ops, mods), so it covers every handler in the set.handler.__name__matches the declared names.ops[1]is needed because the decoder prints it inside the operand, not as a mod.Commands run locally (worktree at the head SHA)
python3 -B tests/startup_gfx2hlsl_modifier_free_check.py-> PASStests/startup_gfx2hlsl_*_check.py(31 files) -> 1 FAIL:startup_gfx2hlsl_readfirstlane_uniform_check.py(passes onorigin/main)python3 tests/docs_links_check.py-> ok (18 files, 395 links)python3 tests/bidi_controls_check.py-> okgit diff --check origin/main...HEAD-> cleanop_v_cvt_pkrtz_f16_f32from the set -> new test fails (MISMATCH)AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-25T13:24:14Z.
Rebased onto current
mainand force-pushed.#1821(src_scc): mergedmainin, resolved theCMakeLists.txtregistration conflict keeping both sides, head is5dc597c1.startup_gfx2hlsl_src_sccandstartup_translatorpass.#1778(modifier-free): head7a72fab0. Mergingmainsurfaced a real behaviour change —v_interp_mov_f32now decodes the parameter selector asp10, p20, p0and refusesp10/p20because they need per-vertex attribute values. My test used the oldp0encoding, which now decodes asp10, so it failed. Fixed the fixture (src1 = 2forp0) and added checks thatp10andp20are refused rather than read asp0.startup_gfx2hlsl_modifier_freeandstartup_translatorpass.#1722(1D sampling): headb96eb6b7; the only conflict was an olderdocs/experiments.mdparagraph you had since rewritten, so I keptmain's version of it and dropped my wording-only change there.startup_gfx2hlsl_image_1d,startup_image_sample_landstartup_translatorpass.Two of the five I closed rather than rebased, because their content is already on
mainor duplicated:mainalready has theclass16helper, thev_cmp_class_f16/v_cmpx_class_f16dispatch andtests/startup_gfx2hlsl_cmp_class_f16_check.py, so the branch was integrated directly and the PR was redundant.v_mul_hi_u32): duplicated by #1747, which is earlier and carriesbinary/drawmodes 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).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:24:46Z.
@triggered02 could you rebase this branch onto current
mainand force-push?GitHub reports head
7a72fab0as conflicting withmain, so it cannot be merged as is.Files that conflict with current
main(214ed093):CMakeLists.txtdocs/experiments.mdtools/startup/gfx2hlsl.pyCommands run locally:
Once it is rebased and CI is green it will be re-checked right away.
AI-assisted; commands listed were executed locally.
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 on7a72fab0:tests/startup_gfx2hlsl_readfirstlane_uniform_check.py): added'modified move overwrite': "v_mov_b32 with ['clamp']"toEARLIERnext to'op_sel overwrite', since the dispatch guard now refusesv_mov_b32withclampbefore the readfirstlane uniform check runs.tools/startup/gfx2hlsl.py): two blank lines aroundMODIFIER_FREE_HANDLERSand beforeclass Stage:.Measured checks
tests/startup_gfx2hlsl_modifier_free_check.py: 20/20 checksok,PASS.tests/startup_gfx2hlsl_readfirstlane_uniform_check.py: 0 failed.tests/startup_gfx2hlsl_*_check.pyscripts +tests/startup_translator_check.py: 62/62 +startup_translatorpassed.tests/docs_links_check.py(464 links),tests/bidi_controls_check.py(1,724 files),git diff --check origin/main: clean.op_v_cvt_pkrtz_f16_f32fromMODIFIER_FREE_HANDLERS, disabling the dispatch guard, and disabling theop_v_interp_p1_f32/op_v_interp_p2_f32operand-modifier check) all failstartup_gfx2hlsl_modifier_free_check.py(exit 1).Not established
startup_translatorran on this head (no C++ changes; no Windows CTest executable run on this worktree).AI-assisted (Gemini).
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T01:31:26Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T01:27:43Z.
I integrated current main in
664d9996. The mergedreadfirstlanecheck 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.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T01:31:26Z.
Code review location:
tools/startup/gfx2hlsl.py; line 388Verified 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.