fix(tools): stop counting IMAGE_*_PCK2/PCK4 as decoded instructions #1214

Merged
polysius merged 1 commit from upstream-pr/1214 into main 2026-10-08 05:21:08 +00:00
polysius commented 2026-10-07 18:00:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by polysius on 2026-10-07T18:00:25Z.


What

#942 credited IMAGE_LOAD_PCK2/PCK4, IMAGE_LOAD_MIP_PCK2/PCK4, IMAGE_STORE_PCK2/PCK4 and IMAGE_STORE_MIP_PCK2/PCK4 to the *_PCK opcodes, treating them as the 2- and 4-dword forms selected by dmask. AMD's generated ISA tables list them as separate MIMG opcodes:

Instruction RDNA1/RDNA2 opcode Decoder
IMAGE_LOAD_PCK 2 ImageLoadPck
IMAGE_LOAD_PCK2 / PCK4 112 / 113 none
IMAGE_LOAD_MIP_PCK 4 ImageLoadMipPck
IMAGE_LOAD_MIP_PCK2 / PCK4 115 / 116 none
IMAGE_STORE_PCK 10 ImageStorePck
IMAGE_STORE_PCK2 / PCK4 118 / 119 none
IMAGE_STORE_MIP_PCK 11 ImageStoreMipPck
IMAGE_STORE_MIP_PCK2 / PCK4 121 / 122 none

Sources, both generated from AMD's machine-readable ISA:

RdnaImageOpDecoder.cpp has no entries for 112–122, so a shader that uses them throws unsupported MIMG opcode. The dmask forms of opcodes 2/4/10/11 that #557 and #561 test are IMAGE_*_PCK itself.

This removes the four OPCODE_VARIANTS entries. Shader progress goes from 1139 to 1131 of 1166 (97.68% to 97.0%).

#1049 (IMAGE_*_BY2/BY4 credited to ImageLoad/ImageStore and their MIP forms) and #1053 (IMAGE_GATHER4H_PCK/IMAGE_GATHER8H_PCK credited to ImageGather4h) follow the same approach. The same tables list those as separate opcodes too: LOAD_BY2/BY4 66/67, LOAD_MIP_BY2/BY4 74/75, STORE_BY2/BY4 82/83, STORE_MIP_BY2/BY4 90/91, GATHER4H_PCK 98, GATHER8H_PCK 99.

Tested

python tools/progress.py out before and after: shaders 1139/1166 → 1131/1166, libraries unchanged. No C++ change.

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
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • 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
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4776487704 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1214). Originally posted by [polysius](https://github.com/polysius) on 2026-10-07T18:00:25Z. --- ### What #942 credited `IMAGE_LOAD_PCK2/PCK4`, `IMAGE_LOAD_MIP_PCK2/PCK4`, `IMAGE_STORE_PCK2/PCK4` and `IMAGE_STORE_MIP_PCK2/PCK4` to the `*_PCK` opcodes, treating them as the 2- and 4-dword forms selected by `dmask`. AMD's generated ISA tables list them as separate MIMG opcodes: | Instruction | RDNA1/RDNA2 opcode | Decoder | |---|---|---| | `IMAGE_LOAD_PCK` | 2 | `ImageLoadPck` | | `IMAGE_LOAD_PCK2` / `PCK4` | 112 / 113 | none | | `IMAGE_LOAD_MIP_PCK` | 4 | `ImageLoadMipPck` | | `IMAGE_LOAD_MIP_PCK2` / `PCK4` | 115 / 116 | none | | `IMAGE_STORE_PCK` | 10 | `ImageStorePck` | | `IMAGE_STORE_PCK2` / `PCK4` | 118 / 119 | none | | `IMAGE_STORE_MIP_PCK` | 11 | `ImageStoreMipPck` | | `IMAGE_STORE_MIP_PCK2` / `PCK4` | 121 / 122 | none | Sources, both generated from AMD's machine-readable ISA: - GPUOpen [isa_spec_manager `source/isa_decoder/isa_decoder.cpp`](https://github.com/GPUOpen-Tools/isa_spec_manager/blob/main/source/isa_decoder/isa_decoder.cpp), RDNA1 load/store tables: `table[112] = lsa_table; // IMAGE_LOAD_PCK2`, `table[113] ... // IMAGE_LOAD_PCK4`, `table[115]`/`[116]` (MIP), `table[118]`/`[119]` (store) and `table[121]`/`[122]` (MIP store). - ROCm [rocjitsu `generated/rdna2/opcodes.h`](https://github.com/ROCm/rocm-systems/blob/develop/emulation/rocjitsu/lib/rocjitsu/src/rocjitsu/isa/arch/amdgpu/generated/rdna2/opcodes.h): `kImageLoadPck2Mimg = 112` through `kImageStoreMipPck4Mimg = 122`. `RdnaImageOpDecoder.cpp` has no entries for 112–122, so a shader that uses them throws `unsupported MIMG opcode`. The `dmask` forms of opcodes 2/4/10/11 that #557 and #561 test are `IMAGE_*_PCK` itself. This removes the four `OPCODE_VARIANTS` entries. Shader progress goes from 1139 to 1131 of 1166 (97.68% to 97.0%). #1049 (`IMAGE_*_BY2`/`BY4` credited to `ImageLoad`/`ImageStore` and their MIP forms) and #1053 (`IMAGE_GATHER4H_PCK`/`IMAGE_GATHER8H_PCK` credited to `ImageGather4h`) follow the same approach. The same tables list those as separate opcodes too: `LOAD_BY2`/`BY4` 66/67, `LOAD_MIP_BY2`/`BY4` 74/75, `STORE_BY2`/`BY4` 82/83, `STORE_MIP_BY2`/`BY4` 90/91, `GATHER4H_PCK` 98, `GATHER8H_PCK` 99. ### Tested `python tools/progress.py out` before and after: shaders 1139/1166 → 1131/1166, libraries unchanged. No C++ change. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Dextroid17 commented 2026-10-07 21:22:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-07T21:22:06Z.


Confirmed — and the pr-overlap warning here is worth acting on, because three open PRs edit the same five lines on opposite premises.

The change itself checks out. rdna_isa.txt lists the names separately, which is the author's stated basis:

371  IMAGE_LOAD_PCK    MIMG
372  IMAGE_LOAD_PCK2   MIMG
373  IMAGE_LOAD_PCK4   MIMG

and the decoder binds only the first, so nothing decodes the other two:

{0x00u, ImageLoad}   {0x01u, ImageLoadMip}   {0x02u, ImageLoadPck}   {0x03u, ImageLoadPckSgn}
{0x04u, ImageLoadMipPck}  {0x05u, ImageLoadMipPckSgn}
{0x08u, ImageStore}  {0x09u, ImageStoreMip}  {0x0au, ImageStorePck}  {0x0bu, ImageStoreMipPck}

No entry corresponds to PCK2/PCK4, and no source in the tree contains those mnemonics at all. Measured effect of the change, driving progress.py --root <repo> with both versions and diffing the output directory:

before after
shaders 1139/1166 (97.68%) 1131/1166 (97.0%)
MIMG 120/130 (92%) 112/130 (86%)

Exactly eight — the four families × two sizes — which is what the alias map claimed. Note this corrects the published badge (badge-shaders.svg), not just an internal number.

What I did not verify: the opcode numbers. The body cites them as 112/113 from AMD's generated tables; in-tree I have the mnemonics but not their numbers, so I confirmed "these are separate mnemonics the decoder lacks a binding for", not "112/113" itself.

The collision. tools/progress.py:55-59 is also edited by #1049 and #1053, and the three rest on different premises about when an alias is legitimate:

  • #1049 adds ImageLoad → IMAGE_LOAD_BY2/BY4, describing them as the same instruction transferring 2 or 4 components via dmask. That is the same mechanism, used the other way. It looks right: the decoder has no BY2/BY4 opcode either, but if they are dmask-selected they share image_load's encoding and the alias is honest.
  • #1053 adds ImageGather4h → IMAGE_GATHER4H_PCK/GATHER8H_PCK. Same question.
  • #1214 removes four such pairings.

These cannot all be right unless the rule is stated. The rule that makes them consistent, and the one this PR is implicitly applying: an alias is honest when the variant shares the base instruction's opcode and differs only in dmask or suffix; it is not honest when the ISA gives the variant its own opcode, because then nothing in the decoder executes it. PCK2/PCK4 are the second case — which is why this PR removes them.

Suggested order, since they conflict textually: land #1214 first (it is the one that removes a wrong count), then rebase #1049 and #1053 onto it and state the opcode for each added pairing. If IMAGE_GATHER4H_PCK has its own opcode, #1053 has the same defect this PR corrects.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6047109923 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1214#issuecomment-6047109923). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-07T21:22:06Z. --- Confirmed — and the pr-overlap warning here is worth acting on, because three open PRs edit the same five lines on **opposite** premises. **The change itself checks out.** `rdna_isa.txt` lists the names separately, which is the author's stated basis: ``` 371 IMAGE_LOAD_PCK MIMG 372 IMAGE_LOAD_PCK2 MIMG 373 IMAGE_LOAD_PCK4 MIMG ``` and the decoder binds only the first, so nothing decodes the other two: ``` {0x00u, ImageLoad} {0x01u, ImageLoadMip} {0x02u, ImageLoadPck} {0x03u, ImageLoadPckSgn} {0x04u, ImageLoadMipPck} {0x05u, ImageLoadMipPckSgn} {0x08u, ImageStore} {0x09u, ImageStoreMip} {0x0au, ImageStorePck} {0x0bu, ImageStoreMipPck} ``` No entry corresponds to `PCK2`/`PCK4`, and no source in the tree contains those mnemonics at all. Measured effect of the change, driving `progress.py --root <repo>` with both versions and diffing the output directory: | | before | after | | --- | --- | --- | | shaders | `1139/1166` (97.68%) | `1131/1166` (**97.0%**) | | MIMG | `120/130` (92%) | `112/130` (**86%**) | Exactly **eight** — the four families × two sizes — which is what the alias map claimed. Note this corrects the **published badge** (`badge-shaders.svg`), not just an internal number. **What I did not verify:** the opcode numbers. The body cites them as 112/113 from AMD's generated tables; in-tree I have the mnemonics but not their numbers, so I confirmed "these are separate mnemonics the decoder lacks a binding for", not "112/113" itself. **The collision.** `tools/progress.py:55-59` is also edited by #1049 and #1053, and the three rest on different premises about when an alias is legitimate: - **#1049** *adds* `ImageLoad → IMAGE_LOAD_BY2/BY4`, describing them as the same instruction transferring 2 or 4 components via `dmask`. That is the same mechanism, used the other way. It looks right: the decoder has no `BY2`/`BY4` opcode either, but if they are `dmask`-selected they share `image_load`'s encoding and the alias is honest. - **#1053** *adds* `ImageGather4h → IMAGE_GATHER4H_PCK/GATHER8H_PCK`. Same question. - **#1214** *removes* four such pairings. These cannot all be right unless the rule is stated. The rule that makes them consistent, and the one this PR is implicitly applying: **an alias is honest when the variant shares the base instruction's opcode and differs only in `dmask` or suffix; it is not honest when the ISA gives the variant its own opcode**, because then nothing in the decoder executes it. `PCK2`/`PCK4` are the second case — which is why this PR removes them. Suggested order, since they conflict textually: land #1214 first (it is the one that *removes* a wrong count), then rebase #1049 and #1053 onto it and state the opcode for each added pairing. If `IMAGE_GATHER4H_PCK` has its own opcode, #1053 has the same defect this PR corrects.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!1214
No description provided.