Skip to content

RDNA2 decoder: correct FMA modifiers, image atomics and target-specific legacy MAD - #2786

Draft
kacper-serewis wants to merge 17 commits into
ItsNotRexed:mainfrom
kacper-serewis:shader/direct-decode-mix-slc
Draft

kacper-serewis wants to merge 17 commits into
ItsNotRexed:mainfrom
kacper-serewis:shader/direct-decode-mix-slc

Conversation

@kacper-serewis

@kacper-serewis kacper-serewis commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Depends on: #2038

BUILD-784 and BUILD-806. Current coordination claim. Integration parent 402ef8ce combines main 4c52ce27 with #2038 998128ec. Compare 402ef8ce to tested head 2e594cf1 for the four fixes.

Each mixed-precision FMA source carries its own negate/absolute flags. MIMG SLC comes from the first instruction word, independently of the sampler index. Both corrections have hand-written synthetic regression tests.

CPU-only full retail differential on the earlier #2038 base c329207f: 26,503 listings, 44,398,977 instructions at matching PCs. The two changes removed 59,094 and 36,610 exact opcode/operand/modifier disagreements respectively. Counts describe agreement with LLVM 21.1.8 listings, not GPU execution.

Independent synthetic LLVM 21.1.8 comparisons on Windows, integration parent 402ef8ce → PR head 2e594cf1. Across the three mixed FMA opcodes and all 64 source sign/absolute combinations per opcode, exact matches rose from 3/192 to 192/192. Sampling with 25 sampler indices crossed with both SLC states rose from 25/50 to 50/50, atomic width and GLC from 4/8 to 8/8, and target-specific legacy MAD/FMA from 1/5 to 5/5.

On the tested head, 12 of 13 decoder tests passed. Fixture parity stopped at ps_sdwa_f16_const.asm on both heads. LLVM prints a 12-byte literal encoding for the 8-byte SDWA inline constant. The dependency’s dedicated inline-constant operand test passed. Shader disassembly (19), stage resume (44), rdna2spirv decode (24), startup (2), text line endings (3), docs links (6), mixed-FMA semantics (15), printed encodings (7), and compileall passed. AI-assisted Windows CPU validation. No GPU, driver or game files used for this update. Corpus comparisons below are historical.

Historical validation on 08096726: MIMG atomic VDATA width now follows dmask (all 2,485 image_atomic_umax occurrences agree with LLVM, including 954 previously wrong), and legacy MAD versus FMA follows the selected GPU target (24,765 corrected mnemonics in 6,059 listings). These are CPU comparisons.

On the previous stack, 4da8851 to 0809672, exact opcode, ordered operand and modifier matches rose from 43,886,911 to 44,008,334 across 44,398,977 equal-PC pairs in 26,503 listings. The 121,423 gains comprise 59,094 mixed-FMA corrections, 36,610 MIMG SLC corrections, 954 atomic register-width corrections and 24,765 target-specific MAD/FMA selections. All 523,693 mixed-FMA instructions matched LLVM on fields, PC and encoded bytes. The full metric compares parsed fields at equal PCs. Both revisions had 1,313 equal-PC pairs with differing encoded bytes outside mixed FMA. Both reached the expected end of every listing. The run loaded verified Git blobs from separate directories. AI-assisted Windows CPU comparison with cached LLVM 21.1.8 listings.

…negatives as decimal

Addresses review feedback on PR ItsNotRexed#2038 (@borislisandro):
- Sign-extend SOPP branch simm16 offsets with _s16(simm16) so backward branches decode
  as negative integers (e.g. -4, -20) matching shader_ir/llvm-mc 21/22 instead of 0xfffc.
- Format negative immediates (< 0) as decimal rather than broken '0x-...' hex.
- Clarify module docstring (shader_ir-compatible .s text) and update unit tests
  (normalizing SOPP branch immediates mod 16-bit for LLVM 18 vs 21/22 parity).
@kacper-serewis kacper-serewis changed the title RDNA2 decoder: preserve mixed FMA source modifiers and read MIMG SLC independently RDNA2 decoder: correct FMA modifiers, image atomics and target-specific legacy MAD Nov 22, 2026
@padhossein

Copy link
Copy Markdown
Contributor

Independent decoder modifier matrix (2b2f85bf). With LLVM 21.1.8 gfx1013 I assembled all 64 combinations of plain/negated/absolute/negated-absolute source operands for each of the three FMA mix forms. The decoder went from 3/192 on stack parent 4da88513 to 192/192. An independent MIMG sweep of 25 sampler indices crossed with both SLC bit states went from 25/50 to 50/50. The LLVM-enabled suite still reports only the known ps_sdwa_f16_const inline-constant failure, which I also reproduced on the stack parent.

Synthetic inputs only. AI-assisted (Codex).

@kacper-serewis kacper-serewis left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

BUILD-784 / BUILD-806. Depends on: #2038. AI-assisted integration e74cef0 includes prerequisite a8c1473. LLVM 21.1.8 synthetic comparisons matched 192/192 mixed FMA, 50/50 sampler+SLC, 8/8 atomic and 5/5 target-dependent legacy cases. The three targeted suites passed 13/13, 20/20 and 24/24. Across 26,503 cached listings all 987,873 targeted instruction occurrences matched the LLVM encoding, opcode, ordered operands and modifiers. Full-stream PC alignment was outside this check. CPU only.

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.

3 participants