Skip to content

shader, docs: fill GFX10 decoder gaps - #68

Merged
simnJS merged 4 commits into
MiamiGame:mainfrom
PrivacyOnion:shader/gfx10-decoder-gaps
Nov 25, 2026
Merged

simnJS merged 4 commits into
MiamiGame:mainfrom
PrivacyOnion:shader/gfx10-decoder-gaps

Conversation

@PrivacyOnion

@PrivacyOnion PrivacyOnion commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Fill the nine GFX10 decoder gaps found by the LLVM MC corpus and add the four packed coarse-gradient offset opcodes identified in review. The e64 f32 interpolations share the VINTRP names and retain their VOP3 operands and modifiers. The image and signed packed dot instructions use their existing MIMG and VOP3P layouts.

The four non-comparison packed coarse-gradient samples use the existing SampleGrad path, including the clamp and offset variants. The host chooses a mip level per lane. This agrees with GFX10's per-quad selection when the gradients agree across the quad. Comparison forms with explicit gradients keep the SM 6.6 diagnostic. The new interpolation, gather and signed dot forms still need DXIL lowering.

Fixes: none. This covers the decoder gaps in #64. The legacy MAD/MAC question stays open.
Depends on: none. #52 has landed; this PR removes the nine KNOWN_DECODER_GAPS pins it fixes (tests/gfx10_conformance.rs), so the conformance test now passes with none. The two legacy-name pins still apply.

Area

xtp-shader GFX10 decoding, disassembly and DXIL image lowering. The README documents the decoder and translation coverage.

Tests

  • cargo xtask pr-check passes on my machine with --skip test
  • New or changed behaviour has tests that need no game files, or I explain below why it cannot
  • Ran on a title: no

cargo xtask pr-check --base upstream/main --title "shader, docs: fill GFX10 decoder gaps" --skip test passed formatting, both Clippy configurations, asset policy, and commit and title conventions.

cargo test -p xtp-shader --lib passed 479 tests with 41 ignored, and cargo test -p xtp-shader --test gfx10_conformance passes with no decoder gap pins. Translation tests compare the emitted DXIL of each non-comparison coarse form to its fine-gradient equivalent with both address widths. Decoder tests cover the offset encodings and operand counts. All four comparison forms retain the explicit-gradient diagnostic.

Provenance

  • I wrote all of this change myself for XTP, or it only moves code already in XTP.
  • Some of it comes from elsewhere. Each source, its licence and the files concerned are listed here, and every licence is compatible with GPL-3.0-or-later:
    • llvm-project llvmorg-19.1.7 (Apache-2.0 WITH LLVM-exception), llvm/test/MC/AMDGPU/{gfx10_asm_vop3.s,gfx10_asm_mimg.s,gfx1011_dlops.s}. The opcode numbers and mnemonics supply VOP3P 0x018 and MIMG 0x061 and 0x0e8..=0x0eb in gfx10/opcodes.rs. Numeric fixtures are in gfx10/mod.rs, emit/input_tests.rs and emit/lower/tests.rs, all under crates/xtp-shader/src/. I cross-checked the images against shader, xtask, docs: add a reduced GFX10 conformance corpus #52's LLVM corpus shard.
    • MIMG 0x0ec..=0x0ef (image_sample_*cd*_o_g16) are the GFX10 opcodes in LLVM's llvm/lib/Target/AMDGPU/MIMGInstructions.td at the same tag. The gfx10/mod.rs fixtures for these entries combine the packed samples and coarse offset layouts from the same LLVM MC source. The translation tests use synthetic shader programs.
    • Mesa mesa-22.3.0, src/amd/compiler/aco_opcodes.py (MIT), supplies the rest of the pre-existing gfx10/opcodes.rs tables and retains its notice there.

AI assistance: AI coding tools wrote this change and its tests, mainly OpenAI Codex.

Checklist

  • No game data, keys, console SDK code or headers, and nothing that circumvents DRM (asset policy)
  • No code copied from xcl or AnyPS5 (references only: read them to understand, write your own)
  • I agree to license this contribution under GPL-3.0-or-later
  • Title and every commit follow <area>: <summary>; one topic; under 400 changed lines, or the reason is above
  • Docs updated where behaviour, commands or variables changed (README, docs/)

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Other open pull requests change the same files. Check that they do not do the same work, and agree with their authors on which lands first: the other one will then need a rebase.

Pull request Files changed by both
#48 README.md
#65 crates/xtp-shader/src/emit/image_tests.rs, crates/xtp-shader/src/emit/input_tests.rs

This comment is kept up to date automatically and removed when the overlap ends.

@github-actions github-actions Bot added area/shader touches crates/xtp-shader area/docs docs/, Markdown overlap another open PR changes the same files size/M 100 to 399 changed lines labels Nov 25, 2026

@simnJS simnJS 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.

Thanks, this is clean and well tested. Every new opcode matches LLVM 19.1.7 and AMD's RDNA2 spec, and nothing that decodes today changes. A few small points:

  1. README.md is touched too, so the title should be shader, docs: fill GFX10 decoder gaps.
  2. The header of gfx10/opcodes.rs says the tables are generated from Mesa. Please note that the new rows come from LLVM (Apache-2.0 WITH LLVM-exception).
  3. In emit/lower/image.rs:378-381, _cd_g16 is refused because the coarse form picks one level per quad. Main already lowers image_sample_cd through SampleGrad and accepts that difference, so please lower _cd_g16 the same way, or explain why it should differ.
  4. Optional: 0x0ec–0x0ef (*_cd*_o_g16) are valid GFX10 opcodes too.

Heads-up: #52 adds a stale-pin check (gfx10_conformance.rs:217). Whichever of this PR and #52 lands second will need to remove the pins it covers.

@PrivacyOnion PrivacyOnion changed the title shader: fill GFX10 decoder gaps shader, docs: fill GFX10 decoder gaps Nov 25, 2026
@PrivacyOnion

Copy link
Copy Markdown
Contributor Author
  1. The revised title is shader, docs: fill GFX10 decoder gaps. The README now describes which packed coarse-gradient forms translate.
  2. The opcode table header and PR provenance now credit LLVM MC 19.1.7 and retain the Mesa attribution. They also record how the four packed offset entries were identified.
  3. The non-comparison _cd_g16 forms now use SampleGrad, like image_sample_cd. The host selects a mip level per lane, so it agrees when the quad's gradients agree. The comparison forms keep the existing SM 6.6 diagnostic for explicit gradients. Translation tests cover both outcomes.
  4. Added 0x0ec..=0x0ef. Decoder tests use encodings derived from the LLVM MC fixtures, and translation tests cover the offset and clamp forms.

The nine KNOWN_DECODER_GAPS entries that #52 adds become stale once both changes are present. I will remove them in whichever change lands second. The two legacy-name pins still apply.

@simnJS

simnJS commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Thanks, all four points are addressed, and comparing the output with _d*_g16 is a good test. #52 just landed, so this PR is the second one: please remove the nine KNOWN_DECODER_GAPS pins it fixes (gfx10_conformance.rs), or the stale-pin check will fail. Then I'll approve and merge.

Two non-blocking nits:

  • Please keep the shortcut: prefix at image.rs:973 so it stays searchable.
  • For 0x0ec–0x0ef, citing LLVM's MIMGInstructions.td or AMD's RDNA2 spec would be firmer than "identified in review".

With the conformance corpus on main, the nine names this change decodes
would fail its stale-pin check. Also keep the shortcut: prefix on the
coarse-form comment and cite LLVM's MIMG table for 0x0ec..=0x0ef.
@PrivacyOnion

Copy link
Copy Markdown
Contributor Author

Thanks. Merged main (with #52) and removed the nine KNOWN_DECODER_GAPS pins this PR fixes; gfx10_conformance passes with the list empty, and cargo test -p xtp-shader --lib passes (479). Both nits done: the shortcut: prefix is back on the coarse-form comment in image.rs, and the opcodes.rs header and the description now cite LLVM's MIMGInstructions.td at llvmorg-19.1.7 for 0x0ec..=0x0ef.

@simnJS simnJS 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.

Thanks, everything is in:

  • all nine pins are gone and both legacy pins stay;
  • shortcut: is back;
  • 0x0ec–0x0ef cite MIMGInstructions.td.

The only red check, gpu-debug-layer, fails in an xtp-gpu test this PR doesn't touch (a_placed_slot_follows_its_memory_when_unmapped, green on main). I'm rerunning it and will merge once it's green.

@simnJS
simnJS merged commit abe3f40 into MiamiGame:main Nov 25, 2026
18 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs docs/, Markdown area/shader touches crates/xtp-shader overlap another open PR changes the same files size/M 100 to 399 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants