shader(gfx10): cross-validate the opcode and field tables against AMD's machine-readable ISA XML #650

Closed
opened 2026-11-28 21:37:03 +00:00 by github-bot · 3 comments
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 21:34 UTC · original

What

The gfx10 decoder (crates/victory-shader/src/gfx10/fields.rs, opcodes.rs) is hand-written. AMD publishes the RDNA2 ISA as a machine-readable XML (MIT licence, gpuopen "Machine-Readable ISA"), and XCL generates its whole RDNA2 spec from it (scripts/gen_rdna2.py: primary encodings emitted with operands, literal/SDWA/DPP/NSA variants derived at decode time exactly as hardware does, always-literal instructions flagged). A decode bug in a hand-written table becomes a wrong shader with no signal.

What this changes

An xtask command or test that parses the XML and diffs our opcode list and field encodings against it, reporting every mismatch. Not a rewrite of the decoder — a cross-check. Policy question to settle in the PR: the XML is vendored under its MIT licence or fetched at test time and never committed (cargo xtask policy is the gate).

How it was tested

  • the cross-check test itself; every mismatch it finds is a decode bug worth its own issue. No game data needed.

Sources: MacBox scripts/gen_rdna2.py, tests/data/llvm-amdgpu/ (they also carry LLVM's disassembly test data as a second corpus — gfx10_vop1/2/3, sopk, smem, mimg, mtbuf, sdwa...).

**@⁠AnastasisKon** on GitHub · 2026-11-28 21:34 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/646) ## What The gfx10 decoder (crates/victory-shader/src/gfx10/fields.rs, opcodes.rs) is hand-written. AMD publishes the RDNA2 ISA as a machine-readable XML (MIT licence, gpuopen "Machine-Readable ISA"), and XCL generates its whole RDNA2 spec from it (scripts/gen_rdna2.py: primary encodings emitted with operands, literal/SDWA/DPP/NSA variants derived at decode time exactly as hardware does, always-literal instructions flagged). A decode bug in a hand-written table becomes a wrong shader with no signal. ## What this changes An xtask command or test that parses the XML and diffs our opcode list and field encodings against it, reporting every mismatch. Not a rewrite of the decoder — a cross-check. Policy question to settle in the PR: the XML is vendored under its MIT licence or fetched at test time and never committed (cargo xtask policy is the gate). ## How it was tested - the cross-check test itself; every mismatch it finds is a decode bug worth its own issue. No game data needed. Sources: MacBox scripts/gen_rdna2.py, tests/data/llvm-amdgpu/ (they also carry LLVM's disassembly test data as a second corpus — gfx10_vop1/2/3, sopk, smem, mimg, mtbuf, sdwa...).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 21:37:03 +00:00
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-29 08:59 UTC · original

/claim

The XML is fetched (AMD's machine-readable archive, gpuopen.com/download/machine-readable-isa/latest/, MIT, release 2026-02-20): amdgpu_isa_rdna2.xml, ~11 MB. Plan: an xtask command that takes the XML's path (never committed — policy stays clean), parses its instruction list and diffs it against our gfx10 tables, reporting every mnemonic we do not decode and every name of ours the spec does not carry. Opcode-value comparison for the main encodings follows if the first cut finds the tables sound.

**@⁠AnastasisKon** on GitHub · 2026-11-29 08:59 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/646#issuecomment-7253462166) /claim The XML is fetched (AMD's machine-readable archive, gpuopen.com/download/machine-readable-isa/latest/, MIT, release 2026-02-20): amdgpu_isa_rdna2.xml, ~11 MB. Plan: an xtask command that takes the XML's path (never committed — policy stays clean), parses its instruction list and diffs it against our gfx10 tables, reporting every mnemonic we do not decode and every name of ours the spec does not carry. Opcode-value comparison for the main encodings follows if the first cut finds the tables sound.
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-29 08:59 UTC · original

Claimed by @⁠AnastasisKon. Open a draft pull request with Refs #646 in its description within 24 hours, or the claim expires.

**@⁠github-actions[bot]** on GitHub · 2026-11-29 08:59 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/646#issuecomment-7253464031) Claimed by @⁠AnastasisKon. Open a draft pull request with `Refs #646` in its description within 24 hours, or the claim expires.
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-29 09:05 UTC · original

Done — landed on the fork's main as commit 38e5b416 (shader(gfx10): cross-check the opcode tables against AMD's machine-readable ISA).

The archive: AMD's machine-readable ISA download (gpuopen.com/download/machine-readable-isa/latest/ — it serves a zip containing amdgpu_isa_rdna2.xml, MIT, release 2026-02-20, 11 MB). The policy question the issue raised is settled the clean way: fetched at test time, never committed — the test is gated on VICTORY_AMD_ISA_XML naming the XML's path, skipped without it, exactly as the repo's real-file tests are.

What it holds, measured against that release:

  • Zero mismatches. Every one of the 1120 default encodings our tables cover, the tables carry the specification's exact name at the specification's opcode. The hand-written tables are sound where they exist — the worry that a decode bug hid in them is answered.
  • 326 recorded gaps (MIMG pck and by- variants, VOP3 f16 forms and the like) — the test's KNOWN_MISSING list is exactly the gaps that remain: a new one fails until decoded or recorded, a closed one until removed. The list doubles as the coverage to-do list.
  • Our 108 names the specification does not carry are variant forms (_src2, LLVM's literal widths) at opcodes its default encodings do not cover — not errors.

Run: VICTORY_AMD_ISA_XML= cargo test -p victory-shader the_tables_match. Gate green in isolation with the real XML in the run, plus the full usual suite (native, x86_64-apple-darwin, clippy gnullvm, xtask policy, shell tests).

**@⁠AnastasisKon** on GitHub · 2026-11-29 09:05 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/646#issuecomment-7253528307) Done — landed on the fork's main as commit 38e5b416 (shader(gfx10): cross-check the opcode tables against AMD's machine-readable ISA). The archive: AMD's machine-readable ISA download (gpuopen.com/download/machine-readable-isa/latest/ — it serves a zip containing amdgpu_isa_rdna2.xml, MIT, release 2026-02-20, 11 MB). The policy question the issue raised is settled the clean way: fetched at test time, never committed — the test is gated on VICTORY_AMD_ISA_XML naming the XML's path, skipped without it, exactly as the repo's real-file tests are. What it holds, measured against that release: - **Zero mismatches.** Every one of the 1120 default encodings our tables cover, the tables carry the specification's exact name at the specification's opcode. The hand-written tables are sound where they exist — the worry that a decode bug hid in them is answered. - **326 recorded gaps** (MIMG pck and by- variants, VOP3 f16 forms and the like) — the test's KNOWN_MISSING list is exactly the gaps that remain: a new one fails until decoded or recorded, a closed one until removed. The list doubles as the coverage to-do list. - Our 108 names the specification does not carry are variant forms (_src2, LLVM's literal widths) at opcodes its default encodings do not cover — not errors. Run: VICTORY_AMD_ISA_XML=<path> cargo test -p victory-shader the_tables_match. Gate green in isolation with the real XML in the run, plus the full usual suite (native, x86_64-apple-darwin, clippy gnullvm, xtask policy, shell tests).
This discussion has been locked. Commenting is limited to contributors.
No description provided.