dxbc: check the decoder's per-format instruction counts #539
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/539"
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 brcly/TuxBox. Originally posted by csj0oe on 2026-11-29T21:08:18Z.
What
Sorts every decoded instruction into its instruction format — SOP1, SOP2, SOPC, SOPK, SOPP, SMRD, VOP1/2/C/3/3P, VINTRP, SDWA, DPP, MUBUF, MTBUF, MIMG, EXP, FLAT, DS — and compares the whole-program totals with the counts stated for three hand-assembled programs. Between them the programs hold at least one instruction of all 20 formats: 31 instructions, 30 of them counted.
The point is the formats a mnemonic count cannot see. A DPP row move, a DPP8 exchange and an SDWA sub-dword read are modifiers on a VOP instruction, and packed-math opcodes occupy a separate range, so
evidence/shader-instructions/records all of them under the base mnemonic (a DPP row add appears asv_add_nc_u32).Every word in the test is what a public assembler produces for the mnemonic beside it:
llvm-mc -triple=amdgcn-amd-amdhsa -mcpu=gfx1030 -show-encoding FILE.s.tools/format-stats/README.mdholds the three sources, that command and the hand count for each program, so a reviewer can reproduce the words. Nothing compiled or recorded is committed.Two counting rules are pinned by the programs rather than assumed:
v_nopis in the stream and holds no format, while ans_nopcounts as SOPP;v_readfirstlane_b32counts as VOP1.The head no-op that carries data is a longer encoding of the same
v_nop, but no public assembler emits it, so the program uses the plain form; that one case is not covered.Verification
cargo test --target x86_64-unknown-linux-gnu -p tuxbox-dxbc --features native-bindings— 117 passed.python tuxbox.py check --no-gpu— every step passes.Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T21:11:48Z.
Thanks. The format counts are a good idea, but the committed instruction words in
tools/format-stats/stats/look like console compiler output (the HLSL sources, the root signature they were compiled with, the leading data no-op and the 256-bytes_code_endpadding). That's the same problem #531 had: we can't commit output of the licensed console reference compiler.Could you build the programs' words yourself instead, the way #531 now does: hand-assembled or generated in the test, with the expected counts next to them? Then this can go in.
One more thing:
CONTRIBUTING.mdnow asks for a few open PRs at a time until they're reviewed (and the pinned #533 tracks who's working on what). Most of tonight's nine are good, but nine at once is hard to review well. Please hold new ones until these land.Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T22:03:03Z.
Thanks, this addresses it: the words now come from
llvm-mc, which anyone can run. We're putting it through the full check on both of our cards now and will merge it (as one squashed commit) if it passes.Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T22:13:37Z.
Merged as
beed153eonmain(squashed into one commit). The full check passed on an RTX 4070 Ti SUPER and a Radeon 610M. Thanks!Pull request closed