feat(shader): decode MIMG opcode 0xb8 as image_sample_c_o_a #8015

Merged
fma-rc merged 1 commit from upstream-pr/8015 into main 2026-10-21 00:22:08 +00:00
fma-rc commented 2026-10-19 17:42:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-19T17:42:42Z.


What

Death Stranding 2 (PPSA02015) stops at 61.7 s on main with #5426 and #7978 when it first draws with a shader that uses MIMG opcode 0xb8:

terminate called after throwing an instance of 'std::runtime_error'
  what():  shader 0xc2805e1c00 stage 5: ShaderRecompiler::Recompile: unsupported MIMG opcode 0xb8

This decodes 0xb8 as image_sample_c_o_a. LLVM's gfx1030 disassembler reads the same instruction words with bit 0 clear as image_sample_c_o, and the _a rows already on main (0xa0, 0xa1, 0xa5, 0xa8, 0xb0) are the base opcode plus 0x80 with the adjust flag, so the new row is compare, offset and adjust on the existing sample path.

The title also registers shaders with MIMG 0xc8 and 0xd8. It does not use them before its next stop, so they still throw and are not part of this PR.

Tested

Linux (Arch, GCC 16.2.1) and Windows Server 2025 (WinLibs GCC 15.2, no GPU), on main b6583dd868 with this PR; after the rebase onto e90a1d1802 (no recompiler or AGC changes) the named tests pass again on NVIDIA.

  • image_sample_gather fails on main with this PR's test (unsupported MIMG opcode 0xb8) and passes with the change, 3 of 3 runs each.
  • The 13 tests matching ^image_sample_gather$|^agc_driver_image_sample_|^agc_rdna_ pass on NVIDIA, RADV and lavapipe; the Windows build passes all 1683 tests.
  • Death Stranding 2 on RADV (Radeon 680M, Mesa 26.2.4) with #5426 and #7978 gets past the 0xb8 stop and runs to 133.9 s, where it stops on a guest allocation that stays pinned, a separate bug.

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 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
  • Fixes: none
  • Unblocks: PPSA02015 #5424, with #5426 and #7978 (reaches the next stop)
  • GPUs tested: NVIDIA RTX 5080 (driver 615.78.08), AMD Radeon 610M (RADV Mesa 26.1.4), lavapipe; Arch Linux
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4924978027 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8015). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-19T17:42:42Z. --- ### What Death Stranding 2 (PPSA02015) stops at 61.7 s on `main` with #5426 and #7978 when it first draws with a shader that uses MIMG opcode 0xb8: ``` terminate called after throwing an instance of 'std::runtime_error' what(): shader 0xc2805e1c00 stage 5: ShaderRecompiler::Recompile: unsupported MIMG opcode 0xb8 ``` This decodes 0xb8 as `image_sample_c_o_a`. LLVM's gfx1030 disassembler reads the same instruction words with bit 0 clear as `image_sample_c_o`, and the `_a` rows already on `main` (0xa0, 0xa1, 0xa5, 0xa8, 0xb0) are the base opcode plus 0x80 with the adjust flag, so the new row is compare, offset and adjust on the existing sample path. The title also registers shaders with MIMG 0xc8 and 0xd8. It does not use them before its next stop, so they still throw and are not part of this PR. ### Tested Linux (Arch, GCC 16.2.1) and Windows Server 2025 (WinLibs GCC 15.2, no GPU), on `main` b6583dd868 with this PR; after the rebase onto e90a1d1802 (no recompiler or AGC changes) the named tests pass again on NVIDIA. - `image_sample_gather` fails on `main` with this PR's test (`unsupported MIMG opcode 0xb8`) and passes with the change, 3 of 3 runs each. - The 13 tests matching `^image_sample_gather$|^agc_driver_image_sample_|^agc_rdna_` pass on NVIDIA, RADV and lavapipe; the Windows build passes all 1683 tests. - Death Stranding 2 on RADV (Radeon 680M, Mesa 26.2.4) with #5426 and #7978 gets past the 0xb8 stop and runs to 133.9 s, where it stops on a guest allocation that stays pinned, a separate bug. ### Checklist - [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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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] Fixes: none - [x] Unblocks: PPSA02015 #5424, with #5426 and #7978 (reaches the next stop) - [x] GPUs tested: NVIDIA RTX 5080 (driver 615.78.08), AMD Radeon 610M (RADV Mesa 26.1.4), lavapipe; Arch Linux - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-19 17:57:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T17:57:13Z.


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 6044 core/libs/tests/ImageSampleGather.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6273723545 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8015#issuecomment-6273723545). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T17:57:13Z. --- <!-- pr-overlap --> 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 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/ImageSampleGather.cpp` |
wachi35676 commented 2026-10-19 23:12:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-19T23:12:34Z.


Windows runs with GPUs, since the Windows run in the description had none.

Windows 11 Home 26300, WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON, main 9127ea36d with this head merged. GPUs: RTX 5070 Ti (NVIDIA 617.42) and the AMD Radeon iGPU (RDNA2, 1002:13c0, AMD proprietary driver 2026.04.17, ANYPS5_GPU=AMD). ANYPS5_REQUIRE_VULKAN=1, ctest -j4, failures rerun serially (there were none).

  • image_sample_gather, every agc_driver_image_sample_* test, agc_rdna_* and the image gather tests (15 in all) pass on both GPUs.
  • Negative control: with RdnaImageOpDecoder.cpp back to main, image_sample_gather aborts with unsupported MIMG opcode 0xb8.
  • I decoded the test word 0xf0e00109 by hand: OP (bits 24:18) is 0x38 (image_sample_c_o) and OPM (bit 0) is 1, so it is 0xb8 = 0x38 + 0x80. That fits the existing _a rows (0xa0, 0xa1, 0xa5, 0xa8, 0xb0). DMASK is 1 and DIM is 2D.
  • The new test checks decode and translation only. No execution test samples through _c_o_a.
  • Linux: WSL Ubuntu 24.04, GCC 13.3, llvmpipe (Mesa 25.2.8), main 9127ea36d with #8078, #8046, #8069, #8070, #7668, #8015 and #8026 merged together: 61 of the 62 related tests pass; the other, agc_driver_depth_compare_copy, fails with the guest block is not write-watched after WSL reports asynchronous userfaultfd write protection failed, an environment limit.

AI-assisted: yes (Claude Code); results above were run on this machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6279402617 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8015#issuecomment-6279402617). Originally posted by [wachi35676](https://github.com/wachi35676) on 2026-10-19T23:12:34Z. --- Windows runs with GPUs, since the Windows run in the description had none. Windows 11 Home 26300, WinLibs GCC 15.2.0, Release, `BUILD_TESTING=ON`, `main` `9127ea36d` with this head merged. GPUs: RTX 5070 Ti (NVIDIA 617.42) and the AMD Radeon iGPU (RDNA2, `1002:13c0`, AMD proprietary driver 2026.04.17, `ANYPS5_GPU=AMD`). `ANYPS5_REQUIRE_VULKAN=1`, `ctest -j4`, failures rerun serially (there were none). - `image_sample_gather`, every `agc_driver_image_sample_*` test, `agc_rdna_*` and the image gather tests (15 in all) pass on both GPUs. - Negative control: with `RdnaImageOpDecoder.cpp` back to `main`, `image_sample_gather` aborts with `unsupported MIMG opcode 0xb8`. - I decoded the test word `0xf0e00109` by hand: OP (bits 24:18) is 0x38 (`image_sample_c_o`) and OPM (bit 0) is 1, so it is 0xb8 = 0x38 + 0x80. That fits the existing `_a` rows (0xa0, 0xa1, 0xa5, 0xa8, 0xb0). DMASK is 1 and DIM is 2D. - The new test checks decode and translation only. No execution test samples through `_c_o_a`. - Linux: WSL Ubuntu 24.04, GCC 13.3, llvmpipe (Mesa 25.2.8), `main` `9127ea36d` with #8078, #8046, #8069, #8070, #7668, #8015 and #8026 merged together: 61 of the 62 related tests pass; the other, `agc_driver_depth_compare_copy`, fails with `the guest block is not write-watched` after WSL reports `asynchronous userfaultfd write protection failed`, an environment limit. AI-assisted: yes (Claude Code); results above were run on this machine.
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!8015
No description provided.