startup: accept output modifiers on float-result conversions #1700
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1707"
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-24T17:29:45Z.
Fixes #1705. Third group from the loading-screen refusal census (#870): 5 of 29 shaders.
Change
The float-result conversions sat in the uint-result table, whose dispatch refused every modifier before looking at the instruction, so
v_cvt_f32_i32_e64 v1, v1 mul:2did not translate even thoughset_vf()already implements those modifiers.They are now their own table (
VEC_U_TO_F) holding the float expression, dispatched through the float path:Boundaries kept: only
clamp,mul:2,mul:4,div:2are accepted —op_seland source modifiers are refused rather than silently ignored (which would change the operand), and a uint-result conversion (v_cvt_f16_f32) keeps refusing output modifiers.Test
startup_gfx2hlsl_vcvt_omodbuilds VOP1-as-VOP3 encodings from the checked-in decoder's layout (0b110101prefix, opcode0x180 + n, omodw1[28:27], clampw0[15], negw1[31:29]), decodes them, then translates — no game-derived bytes.Fail-first: removing the
VEC_U_TO_Fdispatch fails the test withUnsupported: v_cvt_f32_i32.Census A/B (local, aggregates only)
With the change, refusals grouped as
v_cvt_f32_i32go 16 → 0 in the annotated re-run, and the affected shaders now progress to the next refusal in their stream —export target mrtz,v_cvt_f32_u32_sdwa, negative operands, and the exportoffform that #1674 tracks. That is forward motion, not new failures: every group that appears after the change is one the shader previously never reached.What this does not establish
op_sel/abs/negon conversions stay refused, and the SDWA variants of these conversions are their own slice.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T17:33:42Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
ceccbcaeceℹ️ 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-24T17:35:12Z.
Review: COMMENTED
Review of head
ceccbcaece12b41f03938379d28b5e24906a7e5a. Verdict: 0 P1, 1 P2 (clamp together with an output modifier), plus test gaps.Linux limits. Linux x86_64,
llvm-mc-19, Python 3.14. No Windows, no DXC, no GPU. Python-level translation only; nothing was compiled to DXIL or drawn.What I ran
python3 -B tests/startup_gfx2hlsl_vcvt_omod_check.py: PASS.git diff --check,docs_links_check,bidi_controls_check: clean.llvm-mc-19 -mcpu=gfx1030assembledv_cvt_f32_i32_e64 ... mul:2 / clamp / clamp mul:2,v_cvt_f32_u32_e64 mul:2,v_cvt_f32_f16_e64 mul:2,v_cvt_f32_ubyte1_e64 div:2,v_cvt_f16_f32_e64 mul:2. The opcodes (0x185, 0x186, 0x18b, 0x18a) and omod bits (mul:2 = 1, div:2 = 3) match the bytes the PR'sencode_vop1_e64builds, so the constructed fixtures are real encodings.tools/startup/gfx2hlsl.py(restored withgit checkout -- .):v_cvt_f32_f16textf16tof32({0})->f16tof32({0} >> 16): FAILED, as intended.v_cvt_f32_ubyte1shift 8 -> 16: PASSED, not caught.v_cvt_f32_ubyte3shift 24 -> 16: PASSED, not caught.if any(m not in (...))replaced byif False: PASSED, not caught (anop_selwould then fall intoset_vf, which silently ignores it).v_cvt_f32_u32lowered asfloat(int(x))(signed): PASSED, not caught.P2:
clampwith an output modifier is applied in the wrong order. Forv_cvt_f32_i32_e64 v1, v1 clamp mul:2the translator emitsv1 = U((saturate(float(int(v1)))) * 2.0);(and* 0.5fordiv:2), i.e. clamp first, then scale. As I read the RDNA 2 ISA reference, the output modifier scales the result first and clamp saturates after it, so this should besaturate((float(int(v1))) * 2.0). For an input of 1 the hardware gives 1.0 and this lowering gives 2.0. The order comes fromStage.set_vf, which walks the modifiers in the order the decoder prints them (clamp mul:2); that is pre-existing for theVEC_Foperations, but this PR is what makes the combination reachable for the seven conversions, and no case in the new test combines the two. Suggest applying omod first, then clamp, inset_vf, with a case forclamp mul:2andclamp div:2.Test gaps (not blocking)
v_cvt_f32_ubyte0..3have no case, so a wrong shift or mask there is not detected;v_cvt_f32_u32is checked only for the* 2.0wrapper, not its text.Unsupported operand '-v1'); no case passesop_selor another modifier to a float-result conversion, so dropping the guard goes unnoticed.Not approving (comment only).
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:50:32Z.
Review: COMMENTED
Review of head
d7346d7e32(comment only, not an approval).Verdict: 1 P1, 1 P2. Update: the head moved from
ceccbcaetod7346d7e("apply the output modifier before the clamp") while I was reviewing. That commit changes onlyset_vf()(scale first, saturate last) and one test; both findings below still hold at the new head.sdwa()still hasif base not in VEC_U:(line 401), the conversions are only inVEC_U_TO_F, andset_vf()still haselif m.startswith('op_sel'): pass. The two test files pass at the new head. The SDWA reproduction and the mutation list below were run atceccbcae; I did not repeat them at the new head.P1: the SDWA forms of the moved conversions stop translating (tools/startup/gfx2hlsl.py,
sdwa()near line 392 andVEC_U_TO_Fnear line 1052)v_cvt_f32_u32,v_cvt_f32_i32,v_cvt_f32_ubyte0..3andv_cvt_f32_f16are inVEC_U(base lines 1046-1050). This PR moves them toVEC_U_TO_F.sdwa()at line 392 only accepts names inVEC_U(if base not in VEC_U: raise Unsupported('SDWA form of ...')) and never looks at the new table.v_cvt_f32_u32withsrc0_sel:WORD_0,v_cvt_f32_i32withsrc0_sel:BYTE_0,v_cvt_f32_f16withsrc0_sel:WORD_0,v_cvt_f32_ubyte0withsrc0_sel:BYTE_1. All four translate on the base (e.g.v1 = U(float(int(((v2 >> 0u) & 0xffu))));) and all four are refused at this head withUnsupported('SDWA form of v_cvt_f32_i32')and the matching messages.startup_gfx2hlsl_sdwa_checkonly checks float SDWA is refused, andstartup_gfx2hlsl_vcvt_omod_checkhas no SDWA case. Fix: letsdwa()also acceptVEC_U_TO_F(wrapping inU(...)) and add a test that translates an SDWA conversion.P2: the
op_selrefusal is claimed but unguarded. The code comment and PR body sayop_selis refused;set_vf()ignores it silently, and the test covers only source negation (neg0=1), which is refused anyway becauseu()cannot parse-v1. Mutation D below confirms nothing guards it. Addrefused()cases forop_sel:[1,0]andabs.Run
python3 -B tests/startup_gfx2hlsl_vcvt_omod_check.py,startup_gfx2hlsl_sdwa_check.py,bit_alu,capture,smem_offset: pass. docs_links_check (17 files, 364 links) and bidi_controls_check: pass.div:2from the allowed tuple is caught;v_cvt_f32_i32text changed tofloat({0})is caught. NOT caught:v_cvt_f32_ubyte1shift 8 -> 9,v_cvt_f32_ubyte3shift 24 -> 23,v_cvt_f32_u32->float(int({0})), and replacing the modifier check withif False:(the P2).Non-blocking
v_cvt_f32_ubyte0..3,_e32spellings, orclampcombined withmul, and builds words from the decoder's own layout.VEC_Uonly in docs and tests; #1708's conversion draw test may need updating after this merges.Not run: ctest, the DXC/FXC/D3D12 draw tests, the PR's release numbers and the census figures.
Linux limits: no Windows, MSVC, DXC or D3D12 device here; LLVM 19 only. Anything that needs them was not run.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T17:29:58Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
ceccbcaℹ️ 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-24T17:39:06Z.
Correct — fixed in
d7346d7e.The order was following the disassembler's text, which prints
clampbefore the omod, soset_vf()saturated and then multiplied. It now accumulates the scale, applies it, and saturates last:Single-modifier output is byte-identical to before (
* 2.0,* 4.0,* 0.5), so this does not change the cases the PR already covered. The helper is shared by the other float operations, so a VOP3 float op carrying both modifiers was getting the same wrong order before this — that path is now correct too, not just conversions.The test adds the two combined cases; swapping the blocks back fails it:
All 7
startup_gfx2hlsltests pass in dev and the new test passes in release. Thanks for catching it — the allow-list was the visible change but the operation order was the thing that would have silently disagreed with the hardware.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T17:50:38Z.
Independently verified
d7346d7ewith a source-built flat-parameter pixel draw for v_cvt_f32_f16 clamp div:2. FXC and DXC both produced 3f800000,3f000000,00000000,3e000000 from half inputs 2, 1, -2, 0.25 on RTX 4060 Laptop (32.0.16.1656) and WARP (10.0.26100.9818). A clamp-before-scale mutation read 3f000000 in the first lane on all four runs and failed the comparison. The debug layer was enabled with zero errors and warnings. Please keep the #1708 draw coverage separate; its old blanket refusal for this float-result modifier will need to be adjusted once this lands.Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T17:54:45Z.
Thanks — the P1 is real and it is a regression I introduced, so it gets a follow-up rather than a note: #1730.
sdwa()now acceptsVEC_U_TO_Fas well, wrapping the float result inU(...)before the destination selection writes its bit pattern, so the four forms you reproduced translate again:The test builds the SDWA encodings (
SRC0 = 249marks the form, control word in the next dword) and decodes them before translating, covers the destination selections andUNUSED_PRESERVE, keeps the uint-result conversion on the uint path, and fails if the new branch is removed. All 9startup_gfx2hlsltests pass in dev and the new one in release.Your P2 (
op_selclaimed refused but silently ignored byset_vf) is not bundled into that fix: makingset_vfraise touches every float path that uses it, so it needs a sweep of the existing tests rather than a ride-along on a regression fix. It is queued as its own slice, along with the unexercisedv_cvt_f32_ubyte*shifts you noted.I should have run
startup_gfx2hlsl_sdwa_checkagainst the change rather than only the new test — the SDWA path was exactly the caller I did not check.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T17:33:42Z.
Code review location:
tools/startup/gfx2hlsl.py; line 366When a VOP3 conversion has both
clampand an OMOD, this allow-list accepts the pair andset_vf()applies the decodedclamp mul:2order left-to-right, emitting2 * saturate(result). RDNA applies the OMOD before the final clamp, so converting1withmul:2 clampshould yield1rather than2; lower the pair in hardware order or reject combined modifiers.Useful? React with 👍 / 👎.