fix(shader): decode GFX10 scratch offsets as one dword #5426

Merged
Prophet069 merged 3 commits from upstream-pr/5426 into main 2026-10-23 22:57:41 +00:00
Prophet069 commented 2026-10-13 19:27:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Prophet069 on 2026-10-13T19:27:53Z.


What

GFX10 scratch SV addresses contain one32-bit VGPR offset, not the VGPR pair used for ordinary FLAT addressing. VGPR255 was therefore incorrectly rejected. Decode SV/SS/ST address components independently and make the scratch IR consume the offset components; retain the FLAT/global VGPR-pair and unsupported-scalar checks. Source: LLVM FLATInstructions.td for the operand widths and SV/SS/ST pseudos, and GFX10 encoding for null/EXEC_HI sentinels. #1190 changes flat-aperture SPIR-V routing and does not modify these decoder/IR units.

Replaces the obsolete base of closed #2965, which was automatically closed for intake pause. Targeted current GitHub search found no other open PR implementing this exact export/decoder correction. Related #5005 is a scalar-aperture change, not the one-dword scratch decoder fix.

Tested

Windows 10 Pro 22H2 x64 (build 19045), MinGW GCC 15.2.0: fresh production decoder, IR, translation and control-flow sources compiled on this candidate; all 14 valid/invalid scratch/FLAT decoder and IR cases passed (0.06 s). The standalone test uses the existing Windows .eh_frame to .ehfram configuration and the freshly built libc import library. No Vulkan or PS5 hardware scratch-address result is claimed. The instruction dc304000 027d00ff was originally captured from Death Stranding 2: On the Beach, PS5 title ID PPSA02015, in an earlier experimental integration. This is not a claim that this isolated PR renders or boots the game.

Based on main dacd78525e537a779682032c0ace7f7af120af05; candidate cc1dc3f1c6f88cd03665f933e0b7590e5717b0fe. No dumps, runtime packages, investigation reports or images are included. No speed improvement is claimed.

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; no silent success stub added
  • No notes, investigation .md files or images added to the repository
  • New third-party code: none
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: PPSA02015 #5424 (captured decoder stop; no game rendering or hardware scratch-address claim)
  • GPUs tested: not tested on refreshed candidate; prior decoder/IR tests are CPU tests (Windows)
  • AI-assisted: yes; prepared with Codex; the submitting author is responsible for every line
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4848374361 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5426). Originally posted by [Prophet069](https://github.com/Prophet069) on 2026-10-13T19:27:53Z. --- ### What GFX10 scratch SV addresses contain one32-bit VGPR offset, not the VGPR pair used for ordinary FLAT addressing. VGPR255 was therefore incorrectly rejected. Decode SV/SS/ST address components independently and make the scratch IR consume the offset components; retain the FLAT/global VGPR-pair and unsupported-scalar checks. Source: [LLVM FLATInstructions.td](https://raw.githubusercontent.com/llvm/llvm-project/3eb867f9b63ae2881bbe3c25d3c12842f2bdc55e/llvm/lib/Target/AMDGPU/FLATInstructions.td#L557-L630) for the operand widths and SV/SS/ST pseudos, and [GFX10 encoding](https://raw.githubusercontent.com/llvm/llvm-project/3eb867f9b63ae2881bbe3c25d3c12842f2bdc55e/llvm/lib/Target/AMDGPU/FLATInstructions.td#L2973-L3038) for null/EXEC_HI sentinels. #1190 changes flat-aperture SPIR-V routing and does not modify these decoder/IR units. Replaces the obsolete base of closed #2965, which was automatically closed for intake pause. Targeted current GitHub search found no other open PR implementing this exact export/decoder correction. Related #5005 is a scalar-aperture change, not the one-dword scratch decoder fix. ### Tested Windows 10 Pro 22H2 x64 (build 19045), MinGW GCC 15.2.0: fresh production decoder, IR, translation and control-flow sources compiled on this candidate; all 14 valid/invalid scratch/FLAT decoder and IR cases passed (0.06 s). The standalone test uses the existing Windows `.eh_frame` to `.ehfram` configuration and the freshly built libc import library. No Vulkan or PS5 hardware scratch-address result is claimed. The instruction `dc304000 027d00ff` was originally captured from Death Stranding 2: On the Beach, PS5 title ID PPSA02015, in an earlier experimental integration. This is not a claim that this isolated PR renders or boots the game. Based on main `dacd78525e537a779682032c0ace7f7af120af05`; candidate `cc1dc3f1c6f88cd03665f933e0b7590e5717b0fe`. No dumps, runtime packages, investigation reports or images are included. No speed improvement is claimed. ### 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 - [x] Unimplemented paths throw; no silent success stub added - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code: none - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: PPSA02015 #5424 (captured decoder stop; no game rendering or hardware scratch-address claim) - [x] GPUs tested: not tested on refreshed candidate; prior decoder/IR tests are CPU tests (Windows) - [x] AI-assisted: yes; prepared with Codex; the submitting author is responsible for every line
KauaSantos702 commented 2026-10-14 13:44:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by KauaSantos702 on 2026-10-14T13:44:59Z.


NVIDIA run at this head (cc1dc3f1c), adding a vendor to the AMD results in the body: no agc_* test fails.

  • NVIDIA GeForce RTX 5070 (Blackwell), driver 32.0.16.1714, Windows 11
  • WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON
  • ctest -R '^agc_' -j2: 484 tests, 483 passed, 0 failed, 1 skipped. The skipped test is agc_driver_stencil_ref_export, because the device lacks VK_EXT_shader_stencil_export; it is also skipped on main.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6169819691 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5426#issuecomment-6169819691). Originally posted by [KauaSantos702](https://github.com/KauaSantos702) on 2026-10-14T13:44:59Z. --- NVIDIA run at this head (`cc1dc3f1c`), adding a vendor to the AMD results in the body: no `agc_*` test fails. - NVIDIA GeForce RTX 5070 (Blackwell), driver 32.0.16.1714, Windows 11 - WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON` - `ctest -R '^agc_' -j2`: 484 tests, 483 passed, 0 failed, 1 skipped. The skipped test is `agc_driver_stencil_ref_export`, because the device lacks `VK_EXT_shader_stencil_export`; it is also skipped on `main`.
adriadam10 commented 2026-10-14 19:27:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T19:27:33Z.

Review: DISMISSED


Checked the decoder/IR change on a Linux build merged onto current main: agc_flat_scratch passes and fails without the fix, so the logic looks right. Two things before it can merge:

  • The PR conflicts with main in docs/dev/debt/shader.md (TechnicalDebt adjacency) and "Allow edits from maintainers" is off, so we can't rebase it for you. Please rebase on current main, and put the new ### GFX10 scratch address operands entry away from the end of the file, where other PRs append.
  • core/libs/prx/libSceAgcDriver/tests/FlatScratch.cpp is not formatted like the other tests (no spaces around operators, several statements per line, Scratch/Reject helpers on one line); please run clang-format on it and drop the doubled blank line before the new block in libSceAgcDriver/CMakeLists.txt (line 2241-2242).

Not covered: the real-hardware result of a scratch access with a VGPR offset; the TechnicalDebt entry already says so.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5523499854 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5426#pullrequestreview-5523499854). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T19:27:33Z. **Review:** DISMISSED --- Checked the decoder/IR change on a Linux build merged onto current `main`: `agc_flat_scratch` passes and fails without the fix, so the logic looks right. Two things before it can merge: - The PR conflicts with `main` in `docs/dev/debt/shader.md` (TechnicalDebt adjacency) and "Allow edits from maintainers" is off, so we can't rebase it for you. Please rebase on current `main`, and put the new `### GFX10 scratch address operands` entry away from the end of the file, where other PRs append. - `core/libs/prx/libSceAgcDriver/tests/FlatScratch.cpp` is not formatted like the other tests (no spaces around operators, several statements per line, `Scratch`/`Reject` helpers on one line); please run clang-format on it and drop the doubled blank line before the new block in `libSceAgcDriver/CMakeLists.txt` (line 2241-2242). Not covered: the real-hardware result of a scratch access with a VGPR offset; the TechnicalDebt entry already says so.
fma-rc commented 2026-10-15 06:30:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-15T06:30:08Z.


A title reaches this: Death Stranding 2 (PPSA02015, 01.015.000) on Linux. It only gets this far with a local fix to the AMM address range (on current main it stops at 1 s on that, PR to follow), and then it registers a shader with

scratch_load_dword v2, v255, off   // dc304000 027d00ff

in its spill code (word 0x553 of a 0xd70-word program, well before s_endpgm; LLVM gfx1030 decodes it the same). Without this PR it stops at 39.5 s with FLAT address register range overflow. With cc1dc3f1c cherry-picked on top, that throw is gone and it runs to 45 s, where it stops on something unrelated. agc_flat_scratch passes in that build.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6185992835 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5426#issuecomment-6185992835). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-15T06:30:08Z. --- A title reaches this: Death Stranding 2 (PPSA02015, 01.015.000) on Linux. It only gets this far with a local fix to the AMM address range (on current `main` it stops at 1 s on that, PR to follow), and then it registers a shader with ``` scratch_load_dword v2, v255, off // dc304000 027d00ff ``` in its spill code (word 0x553 of a 0xd70-word program, well before `s_endpgm`; LLVM gfx1030 decodes it the same). Without this PR it stops at 39.5 s with `FLAT address register range overflow`. With cc1dc3f1c cherry-picked on top, that throw is gone and it runs to 45 s, where it stops on something unrelated. `agc_flat_scratch` passes in that build.
oneandonlydean commented 2026-10-20 15:22:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T15:22:49Z.


@Prophet069 a friendly nudge on this one. The maintainer's 14 Oct review says the logic looks right (agc_flat_scratch passes with the fix and fails without it). What's left is a rebase onto current main, where the only conflict is the adjacent entry in the shader debt doc, and a clang-format pass. Once those are pushed, the change request can be re-reviewed and the PR can go through CI.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6294410301 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5426#issuecomment-6294410301). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T15:22:49Z. --- @Prophet069 a friendly nudge on this one. The maintainer's 14 Oct review says the logic looks right (`agc_flat_scratch` passes with the fix and fails without it). What's left is a rebase onto current `main`, where the only conflict is the adjacent entry in the shader debt doc, and a clang-format pass. Once those are pushed, the change request can be re-reviewed and the PR can go through CI.
Prophet069 commented 2026-10-20 17:56:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Prophet069 on 2026-10-20T17:56:48Z.


@oneandonlydean thank you for the reminder. My ai setup doesnt run currently (swtching to qwen from codex because of slow progression and fast plan usage. Can you rebase it for me? I alllowed edits to be made. Sorry i'm not that knowledgeble with all the github stuff. Just wanted to help without understanding much of it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6297543099 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5426#issuecomment-6297543099). Originally posted by [Prophet069](https://github.com/Prophet069) on 2026-10-20T17:56:48Z. --- @oneandonlydean thank you for the reminder. My ai setup doesnt run currently (swtching to qwen from codex because of slow progression and fast plan usage. Can you rebase it for me? I alllowed edits to be made. Sorry i'm not that knowledgeble with all the github stuff. Just wanted to help without understanding much of it.
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!5426
No description provided.