Skip to content

feat(shader): decode all gfx1013 reference memory forms - #21993

Open
Hampter588 wants to merge 1 commit into
boykopovar:mainfrom
Hampter588:feat/shader-gfx1013-reference-decoding
Open

Hampter588 wants to merge 1 commit into
boykopovar:mainfrom
Hampter588:feat/shader-gfx1013-reference-decoding

Conversation

@Hampter588

@Hampter588 Hampter588 commented Nov 17, 2026 •

Copy link
Copy Markdown

What

The pinned gfx1013 public reference has 76 forms with no decoder mapping. This change adds all 15 64-bit DS SRC2 forms and all 61 SMEM store/atomic forms, raising reference decoding from 1,484/1,560 (95.13%) to 1,560/1,560 (100%). DS reaches 154/154; SMEM reaches 84/84. DPP remains 200/200.

DS reuses the existing SRC2 displacement path. SMEM reuses field extraction and adds explicit SDATA inputs, GLC-controlled return destinations, descriptor and data-tuple validation, and DLC preservation for the new forms. Existing opcode values are preserved by appending new enumerators.

This is decoding coverage, not execution support. Translation remains 1,484/1,560; all newly decoded forms have no IR translation and throw. Address-derived DS SRC2 offsets still throw. The debt fragment records these limits.

Overlap / draft status: #19452 implements the same 15 DS forms and adds translation; #19479 implements the same 61 SMEM forms and adds translation. This PR is a decoder-only alternative with a complete reference-coverage regression and independent operand/encoding tests. It is not intended to be merged alongside those implementations without reconciliation. The first checklist item is deliberately unchecked because its no-overlap condition is false.

Authenticated tools/pr_overlap.py --repo boykopovar/AnyPS5 --base main --branch feat/shader-gfx1013-reference-decoding --jobs 6 completed with exit 0 after probing 1,599 open PRs. It found three sharing files or exports, successfully merged all three into its base for comparison, and reports a direct conflict with #19479 in RdnaMemoryOpDecoder.cpp. The semantic duplication with #19452 is separately disclosed above.

Encoding sources: LLVM llvmorg-19.1.0 SMInstructions.td L1155-L1340, DSInstructions.td L1526-L1555, and gfx10_asm_smem.s. SMEM operand constraints follow AMD RDNA 1 ISA sections 7.1 and 13.2.1. DS SRC2 uses the existing signed 15-bit displacement scaled by four; AMD MI100 ISA section 12.13 documents that address rule. No new instruction behavior has been measured on gfx1013 hardware.

Tested

  • Windows 11 Pro 10.0.26200, WinLibs GCC 15.2.0 Release; NVIDIA GeForce RTX 5090, NVIDIA driver 610.88; Khronos validation layer 1.4.341 (newer than pinned Vulkan-Headers 1.4.335).
  • New native regression covers all 76 forms and 45 LLVM byte-encoding fixtures, including input/output distinction, compare-swap input width versus memory width, signed offsets, cache flags, register bounds/alignment, instruction lengths, stream alignment, truncation, and reserved opcodes.
  • The new regression fails against the original main decoder and passes with this change. It also passes in the standalone MSVC C++20 build.
  • A 36,864-case DS/SMEM differential corpus preserves all 11,484 previously accepted results. The existing modifier acceptance/rejection JSON is identical to the original main decoder.
  • python -m unittest discover -s tools/tests -p test_shader_scan.py: 30 tests pass.
  • python -m unittest discover -s tools/tests -p 'test_progress*.py': 176 tests, 175 pass and one skip.
  • python tools/check_conventions.py --base origin/main and git diff --check origin/main...HEAD: pass.
  • python tools/debt_fold.py --check now fails on an unchanged upstream conflict: libressl3-20171-inventory.md and feat-libressl3-evp-pkey-new-mac-key-v2.md both change the same libSceLibreSsl3 entry. This change does not touch either fragment.

Fresh paired validation after rebasing onto main 3b7ffd7a05cba491584a6e82af164654e0cf85bf (PR head 09cc2b658dd5dae26e889f2676b31609cdc425e8):

ANYPS5_REQUIRE_VULKAN=1
ANYPS5_NO_SHADER_CACHE=1
VK_LAYER_PATH=<local validation layer 1.4.341 directory>
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation
VK_LOADER_DEBUG=layer
ctest --test-dir <build> -R '^(agc_driver_lds_src2|agc_decoder_modifiers)$' -V
  • Main: both focused tests passed; one Khronos layer insertion; no missing-layer warning; zero VUIDs.
  • PR head: both focused tests passed; one Khronos layer insertion; no missing-layer warning; zero VUIDs.
  • Both runs selected NVIDIA GeForce RTX 5090 vendor=0x10de device=0x2b85 subgroup=32 on the same machine, driver 610.88.
  • ctest --test-dir build/gpu-validation -R '^agc_decoder_reference_forms$' --output-on-failure: passes on the rebased head.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none (overlap: feat(shader): decode and translate the 64-bit DS src2 operations #19452 and feat(shader): decode and translate scalar stores and atomics #19479; alternatives, not prerequisites)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 5090, NVIDIA 610.88, Windows 11 Pro 10.0.26200; validation layer 1.4.341
  • AI-assisted: yes
All 76 originally missing reference forms and implementation order

Difficulty is for decoding, not execution: 15 DS SRC2 forms; nine SMEM stores; 24 ordinary 32-bit atomics; 24 ordinary 64-bit atomics; two 32-bit compare-swap forms; two 64-bit compare-swap forms.

DS: 15 forms

DS_ADD_SRC2_U64
DS_AND_SRC2_B64
DS_DEC_SRC2_U64
DS_INC_SRC2_U64
DS_MAX_SRC2_F64
DS_MAX_SRC2_I64
DS_MAX_SRC2_U64
DS_MIN_SRC2_F64
DS_MIN_SRC2_I64
DS_MIN_SRC2_U64
DS_OR_SRC2_B64
DS_RSUB_SRC2_U64
DS_SUB_SRC2_U64
DS_WRITE_SRC2_B64
DS_XOR_SRC2_B64

SMEM: 61 forms

S_ATOMIC_ADD
S_ATOMIC_ADD_X2
S_ATOMIC_AND
S_ATOMIC_AND_X2
S_ATOMIC_CMPSWAP
S_ATOMIC_CMPSWAP_X2
S_ATOMIC_DEC
S_ATOMIC_DEC_X2
S_ATOMIC_INC
S_ATOMIC_INC_X2
S_ATOMIC_OR
S_ATOMIC_OR_X2
S_ATOMIC_SMAX
S_ATOMIC_SMAX_X2
S_ATOMIC_SMIN
S_ATOMIC_SMIN_X2
S_ATOMIC_SUB
S_ATOMIC_SUB_X2
S_ATOMIC_SWAP
S_ATOMIC_SWAP_X2
S_ATOMIC_UMAX
S_ATOMIC_UMAX_X2
S_ATOMIC_UMIN
S_ATOMIC_UMIN_X2
S_ATOMIC_XOR
S_ATOMIC_XOR_X2
S_BUFFER_ATOMIC_ADD
S_BUFFER_ATOMIC_ADD_X2
S_BUFFER_ATOMIC_AND
S_BUFFER_ATOMIC_AND_X2
S_BUFFER_ATOMIC_CMPSWAP
S_BUFFER_ATOMIC_CMPSWAP_X2
S_BUFFER_ATOMIC_DEC
S_BUFFER_ATOMIC_DEC_X2
S_BUFFER_ATOMIC_INC
S_BUFFER_ATOMIC_INC_X2
S_BUFFER_ATOMIC_OR
S_BUFFER_ATOMIC_OR_X2
S_BUFFER_ATOMIC_SMAX
S_BUFFER_ATOMIC_SMAX_X2
S_BUFFER_ATOMIC_SMIN
S_BUFFER_ATOMIC_SMIN_X2
S_BUFFER_ATOMIC_SUB
S_BUFFER_ATOMIC_SUB_X2
S_BUFFER_ATOMIC_SWAP
S_BUFFER_ATOMIC_SWAP_X2
S_BUFFER_ATOMIC_UMAX
S_BUFFER_ATOMIC_UMAX_X2
S_BUFFER_ATOMIC_UMIN
S_BUFFER_ATOMIC_UMIN_X2
S_BUFFER_ATOMIC_XOR
S_BUFFER_ATOMIC_XOR_X2
S_BUFFER_STORE_DWORD
S_BUFFER_STORE_DWORDX2
S_BUFFER_STORE_DWORDX4
S_SCRATCH_STORE_DWORD
S_SCRATCH_STORE_DWORDX2
S_SCRATCH_STORE_DWORDX4
S_STORE_DWORD
S_STORE_DWORDX2
S_STORE_DWORDX4

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 19479 core/shader/recompiler/RdnaDecoder/src/RdnaMemoryOpDecoder.cpp L81
PR 23004 core/shader/recompiler/RdnaDecoder/src/RdnaMemoryOpDecoder.cpp L81

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 27782 core/shader/recompiler/RdnaDecoder/include/RdnaDecoder/RdnaOpcode.hpp
core/shader/recompiler/RdnaDecoder/src/RdnaMemoryOpDecoder.cpp
core/shader/recompiler/RdnaDecoder/src/RdnaOpcode.cpp

@Colewiz7

Copy link
Copy Markdown
Contributor

Head 09cc2b658d merged onto main 23786c4e4f as 21050ae42d, no conflict. Linux 7.3.4, GCC 16.2.1 Release, Mesa 26.2.6 RADV, RX 7900 XT (gfx1100) and 7800X3D iGPU (gfx1036).

No new failures and no new validation messages on either GPU.

RX 7900 XT iGPU
tests run (6300 on the 7900 XT, the 2029 GPU ones on the iGPU), new failures vs main none none
-R '^agc' (1961 tests) with the layer, new failures vs main none none
VUID- / SYNC-HAZARD lines 0 / 0 0 / 0

Layer runs used VK_LAYER_KHRONOS_validation 1.4.363.1 with VK_LOADER_DEBUG=layer and ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1; the loader inserted the layer in every run, and the set of distinct validation messages matches main.

AI-assisted: yes

@doenermitzwiebeln-ship-it

Copy link
Copy Markdown
Contributor

Hi, I've tested this branch locally under Kali Linux (x86_64).

I checked out the PR branch (test-gfx1013-decode), rebuilt the project, and ran the relevant test suites:

· python -m unittest discover -s tools/tests -p test_shader_scan.py
· python -m unittest discover -s tools/tests -p 'test_progress*.py'

All tests passed on my end, and the decoder correctly reports 1,560/1,560 (100%) for gfx1013 reference forms.

Since the author tested mainly on Windows 11, I hope this independent Linux verification is helpful for the review. Thanks!

@Mr-Fawx

Mr-Fawx commented Nov 21, 2026

Copy link
Copy Markdown

Cross-check of the decoder against LLVM's gfx1013 encodings, alongside the other open PRs for the same forms (#19479, #24729, #19452).

Method. AMD's Windows driver ships amd_comgr (LLVM's AMDGPU backend), which assembles for amdgcn-amd-amdhsa--gfx1013, the target tools/gfx1013_isa_forms.txt is taken from. I assembled every form that reference lists and main does not decode (61 SMEM, 15 DS src2), two operand variants each (152 words), plus register-plus-immediate offsets, negative offsets, vcc/vcc_lo operands, dlc, and a DS offset sweep. A standalone harness compiled each PR head's RdnaDecoder/src/*.cpp with g++ 15.2 and printed what DecodeRdnaInstruction returns for every word. This checks encodings and decoder fields against LLVM. It is not a hardware measurement: desktop RDNA 2 has none of these forms.

Words (152) main #19479 #21993 #24729 #19452
SMEM stores (18) throw decoded decoded decoded throw
S_ATOMIC (52) throw decoded decoded throw throw
S_BUFFER_ATOMIC (52) throw decoded decoded throw throw
DS src2 64-bit (30) throw throw decoded throw decoded

Every decoded opcode number matches LLVM's encoding in all four PRs.

This PR's decoded fields agree with what LLVM's assembler accepts: stores and atomics without glc have no destination, the data registers are source2, dataComponents is 2 for S_ATOMIC_CMPSWAP and 4 for S_ATOMIC_CMPSWAP_X2 (the assembler rejects s8 and s[8:9] for them), a returning atomic writes only its first data register(s), dlc is kept, a register offset plus an immediate offset both decode, the 21-bit immediate is sign-extended, and a negative s_buffer_* offset is refused, which matches the assembler rejecting one.

One disagreement, DS src2 64-bit forms with an odd offset field. Here the second address is A + 4 * offset with no rounding. #19452 rounds it down to 8 bytes, citing AMD's description as quoted in gem5 and CLRX:

ds_add_src2_u64 v1 offset:N this PR #19452
N = 1 +4 +0
N = 3 +12 +8
N = 5 +20 +16
N = 32767 -4 -8

The 32-bit forms agree (4 * N in both). Neither rule is measured: these forms are GFX10.1 only. probe_catalog.py run-ps5-linux could settle it on a PS5 running Linux.

Not checked: this PR only decodes, and nothing here translates these forms.

The 152 gfx1013 words (LLVM via amd_comgr)
s_store_dword s8, s[2:3], 0x10                   0xf4400201 0xfa000010
s_store_dword s8, s[2:3], s12 glc                0xf4410201 0x18000000
s_store_dwordx2 s[8:9], s[2:3], 0x10             0xf4440201 0xfa000010
s_store_dwordx2 s[8:9], s[2:3], s12 glc          0xf4450201 0x18000000
s_store_dwordx4 s[8:11], s[2:3], 0x10            0xf4480201 0xfa000010
s_store_dwordx4 s[8:11], s[2:3], s12 glc         0xf4490201 0x18000000
s_scratch_store_dword s8, s[2:3], 0x10           0xf4540201 0xfa000010
s_scratch_store_dword s8, s[2:3], s12 glc        0xf4550201 0x18000000
s_scratch_store_dwordx2 s[8:9], s[2:3], 0x10     0xf4580201 0xfa000010
s_scratch_store_dwordx2 s[8:9], s[2:3], s12 glc  0xf4590201 0x18000000
s_scratch_store_dwordx4 s[8:11], s[2:3], 0x10    0xf45c0201 0xfa000010
s_scratch_store_dwordx4 s[8:11], s[2:3], s12 glc 0xf45d0201 0x18000000
s_buffer_store_dword s8, s[4:7], 0x10            0xf4600202 0xfa000010
s_buffer_store_dword s8, s[4:7], s12 glc         0xf4610202 0x18000000
s_buffer_store_dwordx2 s[8:9], s[4:7], 0x10      0xf4640202 0xfa000010
s_buffer_store_dwordx2 s[8:9], s[4:7], s12 glc   0xf4650202 0x18000000
s_buffer_store_dwordx4 s[8:11], s[4:7], 0x10     0xf4680202 0xfa000010
s_buffer_store_dwordx4 s[8:11], s[4:7], s12 glc  0xf4690202 0x18000000
s_atomic_add s8, s[2:3], 0x10                    0xf6080201 0xfa000010
s_atomic_add s8, s[2:3], 0x10 glc                0xf6090201 0xfa000010
s_atomic_add_x2 s[8:9], s[2:3], 0x10             0xf6880201 0xfa000010
s_atomic_add_x2 s[8:9], s[2:3], 0x10 glc         0xf6890201 0xfa000010
s_atomic_and s8, s[2:3], 0x10                    0xf6200201 0xfa000010
s_atomic_and s8, s[2:3], 0x10 glc                0xf6210201 0xfa000010
s_atomic_and_x2 s[8:9], s[2:3], 0x10             0xf6a00201 0xfa000010
s_atomic_and_x2 s[8:9], s[2:3], 0x10 glc         0xf6a10201 0xfa000010
s_atomic_cmpswap s[8:9], s[2:3], 0x10            0xf6040201 0xfa000010
s_atomic_cmpswap s[8:9], s[2:3], 0x10 glc        0xf6050201 0xfa000010
s_atomic_cmpswap_x2 s[8:11], s[2:3], 0x10        0xf6840201 0xfa000010
s_atomic_cmpswap_x2 s[8:11], s[2:3], 0x10 glc    0xf6850201 0xfa000010
s_atomic_dec s8, s[2:3], 0x10                    0xf6300201 0xfa000010
s_atomic_dec s8, s[2:3], 0x10 glc                0xf6310201 0xfa000010
s_atomic_dec_x2 s[8:9], s[2:3], 0x10             0xf6b00201 0xfa000010
s_atomic_dec_x2 s[8:9], s[2:3], 0x10 glc         0xf6b10201 0xfa000010
s_atomic_inc s8, s[2:3], 0x10                    0xf62c0201 0xfa000010
s_atomic_inc s8, s[2:3], 0x10 glc                0xf62d0201 0xfa000010
s_atomic_inc_x2 s[8:9], s[2:3], 0x10             0xf6ac0201 0xfa000010
s_atomic_inc_x2 s[8:9], s[2:3], 0x10 glc         0xf6ad0201 0xfa000010
s_atomic_or s8, s[2:3], 0x10                     0xf6240201 0xfa000010
s_atomic_or s8, s[2:3], 0x10 glc                 0xf6250201 0xfa000010
s_atomic_or_x2 s[8:9], s[2:3], 0x10              0xf6a40201 0xfa000010
s_atomic_or_x2 s[8:9], s[2:3], 0x10 glc          0xf6a50201 0xfa000010
s_atomic_smax s8, s[2:3], 0x10                   0xf6180201 0xfa000010
s_atomic_smax s8, s[2:3], 0x10 glc               0xf6190201 0xfa000010
s_atomic_smax_x2 s[8:9], s[2:3], 0x10            0xf6980201 0xfa000010
s_atomic_smax_x2 s[8:9], s[2:3], 0x10 glc        0xf6990201 0xfa000010
s_atomic_smin s8, s[2:3], 0x10                   0xf6100201 0xfa000010
s_atomic_smin s8, s[2:3], 0x10 glc               0xf6110201 0xfa000010
s_atomic_smin_x2 s[8:9], s[2:3], 0x10            0xf6900201 0xfa000010
s_atomic_smin_x2 s[8:9], s[2:3], 0x10 glc        0xf6910201 0xfa000010
s_atomic_sub s8, s[2:3], 0x10                    0xf60c0201 0xfa000010
s_atomic_sub s8, s[2:3], 0x10 glc                0xf60d0201 0xfa000010
s_atomic_sub_x2 s[8:9], s[2:3], 0x10             0xf68c0201 0xfa000010
s_atomic_sub_x2 s[8:9], s[2:3], 0x10 glc         0xf68d0201 0xfa000010
s_atomic_swap s8, s[2:3], 0x10                   0xf6000201 0xfa000010
s_atomic_swap s8, s[2:3], 0x10 glc               0xf6010201 0xfa000010
s_atomic_swap_x2 s[8:9], s[2:3], 0x10            0xf6800201 0xfa000010
s_atomic_swap_x2 s[8:9], s[2:3], 0x10 glc        0xf6810201 0xfa000010
s_atomic_umax s8, s[2:3], 0x10                   0xf61c0201 0xfa000010
s_atomic_umax s8, s[2:3], 0x10 glc               0xf61d0201 0xfa000010
s_atomic_umax_x2 s[8:9], s[2:3], 0x10            0xf69c0201 0xfa000010
s_atomic_umax_x2 s[8:9], s[2:3], 0x10 glc        0xf69d0201 0xfa000010
s_atomic_umin s8, s[2:3], 0x10                   0xf6140201 0xfa000010
s_atomic_umin s8, s[2:3], 0x10 glc               0xf6150201 0xfa000010
s_atomic_umin_x2 s[8:9], s[2:3], 0x10            0xf6940201 0xfa000010
s_atomic_umin_x2 s[8:9], s[2:3], 0x10 glc        0xf6950201 0xfa000010
s_atomic_xor s8, s[2:3], 0x10                    0xf6280201 0xfa000010
s_atomic_xor s8, s[2:3], 0x10 glc                0xf6290201 0xfa000010
s_atomic_xor_x2 s[8:9], s[2:3], 0x10             0xf6a80201 0xfa000010
s_atomic_xor_x2 s[8:9], s[2:3], 0x10 glc         0xf6a90201 0xfa000010
s_buffer_atomic_add s8, s[4:7], 0x10             0xf5080202 0xfa000010
s_buffer_atomic_add s8, s[4:7], 0x10 glc         0xf5090202 0xfa000010
s_buffer_atomic_add_x2 s[8:9], s[4:7], 0x10      0xf5880202 0xfa000010
s_buffer_atomic_add_x2 s[8:9], s[4:7], 0x10 glc  0xf5890202 0xfa000010
s_buffer_atomic_and s8, s[4:7], 0x10             0xf5200202 0xfa000010
s_buffer_atomic_and s8, s[4:7], 0x10 glc         0xf5210202 0xfa000010
s_buffer_atomic_and_x2 s[8:9], s[4:7], 0x10      0xf5a00202 0xfa000010
s_buffer_atomic_and_x2 s[8:9], s[4:7], 0x10 glc  0xf5a10202 0xfa000010
s_buffer_atomic_cmpswap s[8:9], s[4:7], 0x10     0xf5040202 0xfa000010
s_buffer_atomic_cmpswap s[8:9], s[4:7], 0x10 glc 0xf5050202 0xfa000010
s_buffer_atomic_cmpswap_x2 s[8:11], s[4:7], 0x10 0xf5840202 0xfa000010
s_buffer_atomic_cmpswap_x2 s[8:11], s[4:7], 0x10 glc 0xf5850202 0xfa000010
s_buffer_atomic_dec s8, s[4:7], 0x10             0xf5300202 0xfa000010
s_buffer_atomic_dec s8, s[4:7], 0x10 glc         0xf5310202 0xfa000010
s_buffer_atomic_dec_x2 s[8:9], s[4:7], 0x10      0xf5b00202 0xfa000010
s_buffer_atomic_dec_x2 s[8:9], s[4:7], 0x10 glc  0xf5b10202 0xfa000010
s_buffer_atomic_inc s8, s[4:7], 0x10             0xf52c0202 0xfa000010
s_buffer_atomic_inc s8, s[4:7], 0x10 glc         0xf52d0202 0xfa000010
s_buffer_atomic_inc_x2 s[8:9], s[4:7], 0x10      0xf5ac0202 0xfa000010
s_buffer_atomic_inc_x2 s[8:9], s[4:7], 0x10 glc  0xf5ad0202 0xfa000010
s_buffer_atomic_or s8, s[4:7], 0x10              0xf5240202 0xfa000010
s_buffer_atomic_or s8, s[4:7], 0x10 glc          0xf5250202 0xfa000010
s_buffer_atomic_or_x2 s[8:9], s[4:7], 0x10       0xf5a40202 0xfa000010
s_buffer_atomic_or_x2 s[8:9], s[4:7], 0x10 glc   0xf5a50202 0xfa000010
s_buffer_atomic_smax s8, s[4:7], 0x10            0xf5180202 0xfa000010
s_buffer_atomic_smax s8, s[4:7], 0x10 glc        0xf5190202 0xfa000010
s_buffer_atomic_smax_x2 s[8:9], s[4:7], 0x10     0xf5980202 0xfa000010
s_buffer_atomic_smax_x2 s[8:9], s[4:7], 0x10 glc 0xf5990202 0xfa000010
s_buffer_atomic_smin s8, s[4:7], 0x10            0xf5100202 0xfa000010
s_buffer_atomic_smin s8, s[4:7], 0x10 glc        0xf5110202 0xfa000010
s_buffer_atomic_smin_x2 s[8:9], s[4:7], 0x10     0xf5900202 0xfa000010
s_buffer_atomic_smin_x2 s[8:9], s[4:7], 0x10 glc 0xf5910202 0xfa000010
s_buffer_atomic_sub s8, s[4:7], 0x10             0xf50c0202 0xfa000010
s_buffer_atomic_sub s8, s[4:7], 0x10 glc         0xf50d0202 0xfa000010
s_buffer_atomic_sub_x2 s[8:9], s[4:7], 0x10      0xf58c0202 0xfa000010
s_buffer_atomic_sub_x2 s[8:9], s[4:7], 0x10 glc  0xf58d0202 0xfa000010
s_buffer_atomic_swap s8, s[4:7], 0x10            0xf5000202 0xfa000010
s_buffer_atomic_swap s8, s[4:7], 0x10 glc        0xf5010202 0xfa000010
s_buffer_atomic_swap_x2 s[8:9], s[4:7], 0x10     0xf5800202 0xfa000010
s_buffer_atomic_swap_x2 s[8:9], s[4:7], 0x10 glc 0xf5810202 0xfa000010
s_buffer_atomic_umax s8, s[4:7], 0x10            0xf51c0202 0xfa000010
s_buffer_atomic_umax s8, s[4:7], 0x10 glc        0xf51d0202 0xfa000010
s_buffer_atomic_umax_x2 s[8:9], s[4:7], 0x10     0xf59c0202 0xfa000010
s_buffer_atomic_umax_x2 s[8:9], s[4:7], 0x10 glc 0xf59d0202 0xfa000010
s_buffer_atomic_umin s8, s[4:7], 0x10            0xf5140202 0xfa000010
s_buffer_atomic_umin s8, s[4:7], 0x10 glc        0xf5150202 0xfa000010
s_buffer_atomic_umin_x2 s[8:9], s[4:7], 0x10     0xf5940202 0xfa000010
s_buffer_atomic_umin_x2 s[8:9], s[4:7], 0x10 glc 0xf5950202 0xfa000010
s_buffer_atomic_xor s8, s[4:7], 0x10             0xf5280202 0xfa000010
s_buffer_atomic_xor s8, s[4:7], 0x10 glc         0xf5290202 0xfa000010
s_buffer_atomic_xor_x2 s[8:9], s[4:7], 0x10      0xf5a80202 0xfa000010
s_buffer_atomic_xor_x2 s[8:9], s[4:7], 0x10 glc  0xf5a90202 0xfa000010
ds_add_src2_u64 v1 offset:16                     0xdb000010 0x00000001
ds_add_src2_u64 v1 offset:16 gds                 0xdb020010 0x00000001
ds_and_src2_b64 v1 offset:16                     0xdb240010 0x00000001
ds_and_src2_b64 v1 offset:16 gds                 0xdb260010 0x00000001
ds_dec_src2_u64 v1 offset:16                     0xdb100010 0x00000001
ds_dec_src2_u64 v1 offset:16 gds                 0xdb120010 0x00000001
ds_inc_src2_u64 v1 offset:16                     0xdb0c0010 0x00000001
ds_inc_src2_u64 v1 offset:16 gds                 0xdb0e0010 0x00000001
ds_max_src2_f64 v1 offset:16                     0xdb4c0010 0x00000001
ds_max_src2_f64 v1 offset:16 gds                 0xdb4e0010 0x00000001
ds_max_src2_i64 v1 offset:16                     0xdb180010 0x00000001
ds_max_src2_i64 v1 offset:16 gds                 0xdb1a0010 0x00000001
ds_max_src2_u64 v1 offset:16                     0xdb200010 0x00000001
ds_max_src2_u64 v1 offset:16 gds                 0xdb220010 0x00000001
ds_min_src2_f64 v1 offset:16                     0xdb480010 0x00000001
ds_min_src2_f64 v1 offset:16 gds                 0xdb4a0010 0x00000001
ds_min_src2_i64 v1 offset:16                     0xdb140010 0x00000001
ds_min_src2_i64 v1 offset:16 gds                 0xdb160010 0x00000001
ds_min_src2_u64 v1 offset:16                     0xdb1c0010 0x00000001
ds_min_src2_u64 v1 offset:16 gds                 0xdb1e0010 0x00000001
ds_or_src2_b64 v1 offset:16                      0xdb280010 0x00000001
ds_or_src2_b64 v1 offset:16 gds                  0xdb2a0010 0x00000001
ds_rsub_src2_u64 v1 offset:16                    0xdb080010 0x00000001
ds_rsub_src2_u64 v1 offset:16 gds                0xdb0a0010 0x00000001
ds_sub_src2_u64 v1 offset:16                     0xdb040010 0x00000001
ds_sub_src2_u64 v1 offset:16 gds                 0xdb060010 0x00000001
ds_write_src2_b64 v1 offset:16                   0xdb340010 0x00000001
ds_write_src2_b64 v1 offset:16 gds               0xdb360010 0x00000001
ds_xor_src2_b64 v1 offset:16                     0xdb2c0010 0x00000001
ds_xor_src2_b64 v1 offset:16 gds                 0xdb2e0010 0x00000001
Decode harness
#include "RdnaDecoder/RdnaInstructionDecoder.hpp"
#include "RdnaDecoder/RdnaInstruction.hpp"
#include <cstdint>
#include <cstdio>
#include <exception>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>

using namespace ShaderRecompiler;

static std::string Operand(const RdnaOperand& operand) {
    char text[64];
    std::snprintf(text, sizeof(text), "%d:%u/%u", static_cast<int>(operand.kind), operand.reg, operand.value);
    return text;
}

int main(int argc, char** argv) {
    std::ifstream input(argv[1]);
    std::string line;
    while (std::getline(input, line)) {
        std::istringstream fields(line);
        std::string form;
        fields >> form;
        std::vector<std::uint32_t> words;
        std::string word;
        while (fields >> word) words.push_back(static_cast<std::uint32_t>(std::stoul(word, nullptr, 16)));
        words.push_back(0xbf810000u);
        std::printf("%s ", form.c_str());
        try {
            const auto instruction = DecodeRdnaInstruction(0, words, 0);
            std::printf("op=%d id=%u fam=%d words=%u dst=%s s0=%s s1=%s s2=%s n=%u off=%u dd=%u dc=%u glc=%d dlc=%d sec=%d\n", static_cast<int>(instruction.op), instruction.opcodeId,
                        static_cast<int>(instruction.family), instruction.wordCount, Operand(instruction.destination).c_str(), Operand(instruction.source0).c_str(),
                        Operand(instruction.source1).c_str(), Operand(instruction.source2).c_str(), instruction.sourceCount, instruction.memoryOffset,
                        instruction.dataDwordCount, instruction.dataComponents, instruction.glc ? 1 : 0, instruction.dlc ? 1 : 0, static_cast<int>(instruction.secondaryOffset));
        } catch (const std::exception& error) {
            std::printf("THROW %s\n", error.what());
        }
    }
    return 0;
}

Built per PR head: g++ -std=c++20 -I<each recompiler dir>/include -I core/shader/recompiler DecodeHarness.cpp core/shader/recompiler/RdnaDecoder/src/*.cpp.

AI-assisted: yes (Claude Code assembled the words, ran the harness and the tests, and wrote this comment).

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed — no blocking findings

The decoder changes at head 09cc2b658dd5dae26e889f2676b31609cdc425e8 show no verified blocking defect in the inspected hunks; several changed files were not fully read, so approval is not justified. Nothing blocks this; the points below are optional.

What I ran

No commands were run. I read the prepared description, commit summary, manifest, and diff, then inspected RdnaMemoryOpDecoder.cpp and RdnaOpcode.cpp at the pinned head. The author reports passing tests and paired validation in the PR description; I did not independently run those checks.

Results

Check Result Note
Targeted decoder review passed No blocking defect verified in inspected code
Automated checks not run Results are author-reported
Full changed-file review not run Several changed files were not fully read

Findings

Blocking

None verified in the inspected code.

Non-blocking

  • The description discloses overlap with PRs #19452 and #19479, including a direct conflict with #19479. Reconcile the competing implementations before merging this decoder-only alternative.

Not verified

I read review/description.md, review/commits.md, review/manifest.json, and review/diff.patch, plus targeted ranges from core/shader/recompiler/RdnaDecoder/src/RdnaMemoryOpDecoder.cpp and core/shader/recompiler/RdnaDecoder/src/RdnaOpcode.cpp. The manifest marks all seven changed files as included, but their full texts were not all read: DecoderReferenceForms.cpp, agc_decoder_reference_forms_tests.cmake, RdnaOpcode.hpp, the remainder of RdnaMemoryOpDecoder.cpp, the remainder of RdnaOpcode.cpp, feat-shader-gfx1013-memory-decoding.md, and test_shader_scan.py. The test claims, hardware behavior, full operand validation, and overlap report were not independently verified.

To get this to a good state

Nothing is required. Optional: coordinate with the authors of the overlapping PRs and reconcile the conflicting decoder changes.

@doenermitzwiebeln-ship-it

Copy link
Copy Markdown
Contributor

Thanks for the review. Since there are no blocking findings, could a maintainer clarify the preferred path regarding the overlap with #19452 and #19479? Happy to help with further verification if needed.

@Gonic0

Gonic0 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

macOS check of 09cc2b658d. Apple M5 Pro, macOS 27.3, MoltenVK (Vulkan SDK 1.4.363.0, subgroup size 32, shaderSharedInt64Atomics and shaderBufferInt64Atomics both false), x86_64 Release under Rosetta 2. The tree was main b7d463d438 plus #17425 and #11049, which main still needs to build on macOS; this pull request applied without conflicts. ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer; each log shows the loader inserting the layer and none reports it missing.

  • agc_decoder_reference_forms passes with this pull request.
  • Negative control, the new test on main's code: does not build (no member named 'DsAddSrc2U64' in 'ShaderRecompiler::RdnaOpcode'), as the opcodes it decodes do not exist on main.
  • Regression set ctest -R 'lds|agc_decoder|agc_rdna|smem|shader_smem|ds_src2|ds_' (138 tests on main): every test that passes on main passes with this pull request. The only failure is agc_driver_gds_m0_base on both ("64-bit GDS atomics need shaderBufferInt64Atomics", which test(agc): skip the GDS M0 base 64-bit add without shaderBufferInt64Atomics #24072 addresses); the agc_driver_gds_integer_atomics64* tests skip on both for the same reason. VUID- lines are identical on both (4 VUID-VkDeviceCreateInfo-sType-unique, 2 VUID-vkCreateDescriptorSetLayout-support-09582).

Decoder-only change, so this shows the decoding and no regression on macOS, not execution of the new forms. Not tested with a title.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

I'm holding this until there is console evidence for these memory forms. The team's ruling on the instructions RDNA2 dropped is to keep a decode or translate PR only when a captured PS5 shader or a console probe uses one of them. Please post that on this PR (a shader hash from a title, or a probe result per form) and I'll lift the hold and send it to review. Without it, the forms stay unreachable on retail code, so I'd rather not merge them on the reference ISA alone.

@ligmaSec ligmaSec left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I built and ran the exact 09cc2b658d decoder fixture on Linux. All 76 reference forms passed the operand, width, offset, flag, and truncated or reserved encoding checks. The new forms are represented in the decoder and still throw at translation, as the debt fragment records. This is decoder coverage. Execution on gfx1013 is unverified locally.

On Linux lavapipe, agc_decoder_modifiers and agc_driver_gcn_scalar_buffer_base passed against main a9cbd48cb0 and this head. The change-only agc_decoder_reference_forms CTest passed as well. The loader inserted VK_LAYER_KHRONOS_validation 1.4.369 on both GPU runs, with zero missing-layer warnings and zero VUIDs.

AI-assisted: yes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build docs shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants