Skip to content

startup: print the VINTRP interp_mov selector and refuse p10/p20 - #1926

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
roansystemlabs:shader/1890-interp-mov-selector
Nov 24, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
roansystemlabs:shader/1890-interp-mov-selector

Conversation

@roansystemlabs

Copy link
Copy Markdown
Contributor

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_f32 in tools/startup/gfx2hlsl.py, the checks in tests/rdna2_tools_check.py and tests/startup_flat_param_check.py, and two docs paragraphs.

  • Decoder. The 32-bit VINTRP v_interp_mov_f32_e32 printed its selector field as a VGPR (v0, v1, v2). It now prints p10, p20 or p0, as LLVM does and as the VOP3 (_e64) spelling already did. Any other value of the field (LLVM prints invalid_param_<n>, and llvm-mc accepts no such selector) becomes a four-byte v_interp_mov_f32_e32_unsupported record, 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-256 22aec03f2706dba2e148ffde1f3a25d5cdd42c71a96f95240aeb48d995d44795), so 4-255 would alias on hardware; no assembler emits them and LLVM prints invalid_param_<n>, so they are refused rather than masked. The VOP3 spelling already refused src1 >= 3 the same way. v_interp_p1_f32_e32 and v_interp_p2_f32_e32 keep their VGPR operand in the same field.
  • gfx2hlsl. op_v_interp_mov_f32 read every selector as the flat P0 copy. It now lowers only p0, in both encodings, and refuses p10 (P1 - P0) and p20 (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.
  • Output modifiers on the same handler (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 is p10; p0 is src1 = 2 (noted on #1778). With both changes merged that control raises Unsupported: v_interp_mov_f32 parameter selector p10: only p0 is lowered. On this branch merged with #1778 at 00479dc9, with [0, 2] in that control and in the clamp control next to it, all 17 of its checks pass, and tests/startup_flat_param_check.py still passes. #1778 already conflicts with main in tools/startup/gfx2hlsl.py (next to smem_mods from #1881) and in CMakeLists.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 onto main at 6d0a7885. 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.

ctest --preset dev --no-tests=error -R '^startup_flat_param_' -V       # twice
ctest --preset release --no-tests=error -R '^startup_flat_param_' -V   # twice
Backend Adapter / driver Result (every run)
controls - p0 lowered in both encodings to the same pixel stage as before; p10, p20 refused in both encodings with the selector in the reason; selector 3 refused
WARP Microsoft Basic Render Driver 10.0.26100.9818 FXC and DXC translated pairs 00000001,00000002,7fc00001,80000001; FXC float4 control fails as expected (00000000,00000000,7fc00001,00000000); debug_errors=0 debug_warnings=0
hardware NVIDIA GeForce RTX 3070, 32.0.16.2101 same lines

3/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 on 91f6bf69.

ctest --preset dev --no-tests=error -R '^startup_' on the same change one base earlier (8ca8a421 on a6514901; main then changed tools/startup/gfx2hlsl.py again, 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 three startup_gfx2hlsl_bit_alu_* tests in that set read their inputs with p0 and 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-objcopy and LLVM-C.dll, not a standalone llvm-mc; a small wrapper turns llvm-mc -show-encoding into clang 15 + llvm-objdump 15 for the binary mode below.

$env:LLVM_LIB='LLVM-C.dll'; $env:LLVM_MC='<llvm-mc 15>'; $env:LLVM_OBJCOPY='<llvm-objcopy 15>'
python -B tests/rdna2_tools_check.py                          # 151 tests, OK (1 skip: the LLVM 19-only MUBUF check)
python -B tests/startup_flat_param_check.py binary <llvm-mc 15>   # fixture words match llvm-mc
python -B tests/startup_flat_param_check.py                   # exit 0
  • llvm-objdump -d --mcpu=gfx1013 15.0.7 on a source-built object with p10, p20, p0 in both encodings, the four e32 golden vectors, clamp on 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 three invalid_param_<n> words (0 mismatches). On main the same comparison gives 10 mismatches: every e32 v_interp_mov_f32 printed a VGPR.
  • A wider sweep against the same llvm-objdump: every VINTRP vsrc value 0-255 for the three ops, p0 over 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); on main 512 (259 printing a VGPR for the selector, 253 invalid_param_<n> words not refused).
  • New in 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 by s_endpgm.
  • New in 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 the binary mode with llvm-mc). The decoded text must be the source line; p0 must give the same pixel stage HLSL as the unmodified fixture; p10 and p20 must raise Unsupported with the selector name; a VINTRP selector of 3 must be refused.

Fail-first, each on a copy of the tree:

  • gfx2hlsl guard removed: startup_flat_param_check.py fails with translated v_interp_mov_f32_e32 v0, p10, attr0.x as ['v0 = i.fparam0.x;']; all six selector lines then translate to the flat copy.
  • Decoder change removed (guard kept): the 8 new decoder checks fail (4 golden vectors, the round trip, 3 refusals), and startup_flat_param_check.py fails at the fixture itself, because the e32 p0 prints as v2 and is refused.
  • The new tests with main's tools/: 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-tree of 8ca8a421 (on a6514901) against the 79 open PRs (of 103) that touch any of the six files: no conflict that main does not already have. Searching the added lines of those PRs for v_interp_mov, VINTRP words and p10/p20, only #1778 uses a selector other than p0.

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:

  • The Ubuntu LLVM 15 job (which already runs rdna2_tools_check.py with LLVM and startup_flat_param_check.py binary) was not run on a fork; locally the assembler was clang 15 and -show-encoding came from llvm-objdump 15.
  • AMD and Intel desktop adapters; only WARP and one NVIDIA adapter were run.
  • Xbox hardware.
  • Lowering p10/p20 (per-vertex attributes on an SM 6.1 path) is not attempted here.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed (docs/startup-runtime.md, docs/experiments.md).
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

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 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):

  1. In tools/startup/gfx2hlsl.py, I disabled the ops[1] != 'p0' refusal. startup_flat_param_check.py failed: v_interp_mov_f32_e32 v0, p10, attr0.x was lowered as i.fparam0.x. Killed.
  2. In tools/disasm_rdna2.py, I changed vsrc >= len(VINTRP_MOV_PARAMS) to >. rdna2_tools_check.py failed (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.py skips 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:24 lists v_interp_mov_f32_e32 but not the new v_interp_mov_f32_e32_unsupported record. 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.

@ChazY11

ChazY11 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Ran both checks, broke the change three ways, and verified the e64 claim you only asserted

Windows 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 0

Mutations, each reverted and re-run:

mutation test result
decoder prints v{vsrc} again instead of the selector name rdna2_tools_check caught
the vsrc >= len(VINTRP_MOV_PARAMS) refusal disabled rdna2_tools_check caught
if ops[1] != 'p0': in op_v_interp_mov_f32 disabled startup_flat_param_check caught

The golden vectors are the right construction: 000006c8, 01050ac8, 020a0ec8 say nothing about the decoder's internals,
and the LLVM round trip is guarded by LLVM_LIB so it skips instead of passing vacuously.

The one claim without a test: e64 with an out-of-range selector

The description says "the VOP3 spelling already refused src1 >= 3 the same way", but the added tests only cover the e32 path.
I checked it on your branch by taking the golden e64 word 010002d6 (v_interp_mov_f32_e64 v1, p10, attr0.x) and setting the
selector field:

sel=0    -> v_interp_mov_f32_e64 v1, p10, attr0.x        length 8
sel=2    -> v_interp_mov_f32_e64 v1, p0, attr0.x         length 8
sel=3    -> v_interp_mov_f32_e64_unsupported             length 8
sel=4    -> v_interp_mov_f32_e64_unsupported             length 8
sel=511  -> v_interp_mov_f32_e64_unsupported             length 8

So the claim holds: out-of-range selectors become an 8-byte unsupported record, and the next instruction keeps its offset — the
same shape as your 4-byte e32 case. Two notes:

  • The comment on that record reads v_interp_mov_f32_e64 word with modifier bits that gfx1013 llvm-mc rejects. For the
    selector case the cause is the parameter field, not modifier bits; a reader debugging a real selector 216 will chase the wrong
    thing. Worth making the comment generic, or emitting the selector in it as the e32 path does.
  • Since that behaviour is now load-bearing for the "refuse rather than mask" decision, one e64 sub-case in
    test_vintrp_interp_mov_selector_out_of_range_is_refused would pin it. Right now it is true but untested on this branch.

Verdict

Reviewed. The decoder change is narrow, the scc of the p1/p2 forms is preserved (their 020004c8 case), and the translator
refusal carries the selector in the reason. Mergeable as is; the two notes above are about what a later reader will trip on.

Notes

  • AI-assisted review.

@R0Y00
R0Y00 merged commit 6098b73 into R0Y00:main Nov 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

startup: gfx2hlsl translates v_interp_mov_f32 p10/p20 as the flat P0 value

4 participants