Repository navigation
startup: print the VINTRP interp_mov selector and refuse p10/p20 - #1926
Conversation
The VINTRP v_interp_mov_f32 vsrc field is the parameter selector. The decoder printed it as a VGPR; it now prints p10, p20 or p0 as LLVM does, and any other value is a four-byte unsupported record (LLVM prints invalid_param_<n> and its assembler accepts none). gfx2hlsl read every selector as the flat P0 copy. It now lowers only p0 and refuses p10 and p20 by name in both encodings: they need per-vertex attribute values, which the FXC path does not have. The flat-parameter check replaces its first read with each selector in both encodings; its binary mode checks the words with llvm-mc. The decoder gets LLVM 15 golden vectors, a round trip and refusal checks. Fixes R0Y00#1890.
tedin7
left a comment
There was a problem hiding this comment.
Review of head 91f6bf6 (startup: print the VINTRP interp_mov selector and refuse p10/p20).
Commands run locally on the PR head, with results:
git merge-tree --write-tree --name-only origin/main HEAD: clean, no conflicts.gh pr checks 1926: Linux Python checks, gfx1013 fixtures and Windows build/test pass. The /O2 job and the chart publish job are skipped.git diff --check origin/main...HEAD: clean.python3 tests/bidi_controls_check.py: pass.python3 tests/docs_links_check.py: pass.python3 tests/rdna2_tools_check.py: OK, with 19 tests skipped on this host (the llvm-mc cases did not run here).python3 tests/startup_flat_param_check.py: pass.- No C++/CMake change, so the win2025 run was not needed.
Mutation (reverted with git checkout -- . after each):
- In
tools/startup/gfx2hlsl.py, I disabled theops[1] != 'p0'refusal.startup_flat_param_check.pyfailed:v_interp_mov_f32_e32 v0, p10, attr0.xwas lowered asi.fparam0.x. Killed. - In
tools/disasm_rdna2.py, I changedvsrc >= len(VINTRP_MOV_PARAMS)to>.rdna2_tools_check.pyfailed (1 error). Killed.
Reading of the diff: the decoder change, the refusal in the translator and the docs agree with each other. An out-of-range selector becomes a 4-byte _unsupported record, so the decoder stays in sync. The v_interp_mov_f32_e32 name is unchanged for valid selectors, so tools/pixel_cb_read.py and tools/scan_unsupported_shaders.py still match it.
Findings:
- P1: none.
- P2: none.
- P3:
tests/rdna2_tools_check.pyskips 19 tests here, so the llvm-mc cross-check of the new selector words depends on the CI runner having llvm-mc. CI passes, so this is only a note. - P3:
tools/pixel_cb_read.py:24listsv_interp_mov_f32_e32but not the newv_interp_mov_f32_e32_unsupportedrecord. This is harmless as long as a shader with an invalid selector is rejected earlier. It is not checked in this PR.
AI-assisted; commands listed were executed locally.
Ran both checks, broke the change three ways, and verified the e64 claim you only assertedWindows 11 build 26300.9974, device-free: out/pe-env/Scripts/python.exe -B tests/rdna2_tools_check.py # exit 0
out/pe-env/Scripts/python.exe -B tests/startup_flat_param_check.py # exit 0Mutations, each reverted and re-run:
The golden vectors are the right construction: The one claim without a test: e64 with an out-of-range selectorThe description says "the VOP3 spelling already refused src1 >= 3 the same way", but the added tests only cover the e32 path. So the claim holds: out-of-range selectors become an 8-byte unsupported record, and the next instruction keeps its offset — the
VerdictReviewed. The decoder change is narrow, the scc of the p1/p2 forms is preserved (their Notes
|
Fixes #1890.
Change
This is the change proposed in #1890 and claimed in #1890 (comment). It touches the VINTRP branch of
tools/disasm_rdna2.py,op_v_interp_mov_f32intools/startup/gfx2hlsl.py, the checks intests/rdna2_tools_check.pyandtests/startup_flat_param_check.py, and two docs paragraphs.v_interp_mov_f32_e32printed its selector field as a VGPR (v0,v1,v2). It now printsp10,p20orp0, as LLVM does and as the VOP3 (_e64) spelling already did. Any other value of the field (LLVM printsinvalid_param_<n>, and llvm-mc accepts no such selector) becomes a four-bytev_interp_mov_f32_e32_unsupportedrecord, so the next instruction keeps its offset. The ISA reads only VSRC[1:0] (RDNA 2 ISA, 30 November 2020: Table 53, "For OP==v_interp_mov_f32: 0=P10, 1=P20, 2=P0", printed page 93; Table 93, "VDST = (P0, P10 or P20 selected by VSRC[1:0])", page 269; the archived copy linked in pixel_aot: non-packed 16-bit integer VOP3 ops – high-half behaviour before lowering #669, SHA-25622aec03f2706dba2e148ffde1f3a25d5cdd42c71a96f95240aeb48d995d44795), so 4-255 would alias on hardware; no assembler emits them and LLVM printsinvalid_param_<n>, so they are refused rather than masked. The VOP3 spelling already refused src1 >= 3 the same way.v_interp_p1_f32_e32andv_interp_p2_f32_e32keep their VGPR operand in the same field.op_v_interp_mov_f32read every selector as the flat P0 copy. It now lowers onlyp0, in both encodings, and refusesp10(P1 - P0) andp20(P2 - P0) with the selector in the reason, e.g.v_interp_mov_f32 parameter selector p10: only p0 is lowered. Lowering them would need per-vertex attribute values (GetAttributeAtVertex, SM 6.1), which the FXC path does not have, so they are not translated.clamp,mul:2, ...) are left to startup: refuse a modifier for handlers that do not model one #1778, which is still open; this change does not touch them.Interaction with #1778. Its plain-form control
encode_vop3a(VOP3A_INTERP_MOV, 1, [0, 0])sets src1 = 0, which isp10;p0is src1 = 2 (noted on #1778). With both changes merged that control raisesUnsupported: v_interp_mov_f32 parameter selector p10: only p0 is lowered. On this branch merged with #1778 at00479dc9, with[0, 2]in that control and in the clamp control next to it, all 17 of its checks pass, andtests/startup_flat_param_check.pystill passes. #1778 already conflicts withmainintools/startup/gfx2hlsl.py(next tosmem_modsfrom #1881) and inCMakeLists.txt; this branch adds no conflict of its own there. Whichever lands second needs the one-line fixture change; if #1778 lands first, I will rebase on it, make that change here and rerun the checks.Verification
Commit
91f6bf69, rebased ontomainat6d0a7885. Windows 11 Home build 26200, MSVC 19.44 (VS 2022 Build Tools,vcvars64 -vcvars_ver=14.44), Ninja, DXC from Windows SDK 10.0.26100.0, Python 3.12, D3D12 debug layer enabled.p0lowered in both encodings to the same pixel stage as before;p10,p20refused in both encodings with the selector in the reason; selector 3 refused00000001,00000002,7fc00001,80000001; FXC float4 control fails as expected (00000000,00000000,7fc00001,00000000);debug_errors=0 debug_warnings=03/3 passed in each of the four runs on
91f6bf69, no capability skips.ctest --preset dev/release --no-tests=error -R '^rdna2_tools_check$'passed on91f6bf69.ctest --preset dev --no-tests=error -R '^startup_'on the same change one base earlier (8ca8a421ona6514901;mainthen changedtools/startup/gfx2hlsl.pyagain, outside this handler): 276 tests, 272 passed and 4 skipped by their skip return code (startup_view_heap_warp,startup_gamesave_submit_system,startup_gamesave_read_async_system,startup_logical_view_warp), 485 s. The threestartup_gfx2hlsl_bit_alu_*tests in that set read their inputs withp0and pass.Decoder against LLVM 15.0.7, reported separately from the GPU runs. Locally I have LLVM 15.0.7 as the clang 15 integrated assembler,
llvm-objdump,llvm-objcopyandLLVM-C.dll, not a standalonellvm-mc; a small wrapper turnsllvm-mc -show-encodinginto clang 15 +llvm-objdump15 for thebinarymode below.llvm-objdump -d --mcpu=gfx101315.0.7 on a source-built object withp10,p20,p0in both encodings, the four e32 golden vectors,clampon e64, the p1/p2 forms and three invalid e32 selectors (3, 128, 255 as.long): the decoder prints the same text for all 14 valid instructions and an unsupported record for the threeinvalid_param_<n>words (0 mismatches). Onmainthe same comparison gives 10 mismatches: every e32v_interp_mov_f32printed a VGPR.llvm-objdump: every VINTRPvsrcvalue 0-255 for the three ops,p0over every attribute and channel, and the e64 form with src1 0-7 over four attributes, 1057 words. On this branch 0 mismatches (784 identical texts, 273 words refused by both); onmain512 (259 printing a VGPR for the selector, 253invalid_param_<n>words not refused).tests/rdna2_tools_check.py: e32 golden vectors (p10,p20,p0,attr63.w), an LLVM round trip of those vectors (assembled bytes, LLVM-C disassembly and decoder text all equal), and selectors 3, 128 and 255 as four-byte unsupported records followed bys_endpgm.tests/startup_flat_param_check.py: the first read of the pixel stage is replaced with each selector in both encodings (six source lines, words checked by thebinarymode with llvm-mc). The decoded text must be the source line;p0must give the same pixel stage HLSL as the unmodified fixture;p10andp20must raiseUnsupportedwith the selector name; a VINTRP selector of 3 must be refused.Fail-first, each on a copy of the tree:
gfx2hlslguard removed:startup_flat_param_check.pyfails withtranslated v_interp_mov_f32_e32 v0, p10, attr0.x as ['v0 = i.fparam0.x;']; all six selector lines then translate to the flat copy.startup_flat_param_check.pyfails at the fixture itself, because the e32p0prints asv2and is refused.main'stools/: both files fail the same way.Also run:
tests/docs_links_check.py,tests/bidi_controls_check.py,git diff --check: all pass.git merge-treeof8ca8a421(ona6514901) against the 79 open PRs (of 103) that touch any of the six files: no conflict thatmaindoes not already have. Searching the added lines of those PRs forv_interp_mov, VINTRP words andp10/p20, only #1778 uses a selector other thanp0.Evidence and follow-up
The fixtures are original, written for these tests in LLVM 15 spelling and assembled from source; MIT, like the repository. No game files, dumps or captured shaders.
Not covered:
rdna2_tools_check.pywith LLVM andstartup_flat_param_check.py binary) was not run on a fork; locally the assembler was clang 15 and-show-encodingcame fromllvm-objdump15.p10/p20(per-vertex attributes on an SM 6.1 path) is not attempted here.Checklist
docs/startup-runtime.md,docs/experiments.md).AI-assisted.