feat(shader): translate s_swappc_b64 fetch-shader calls at vertex entry #1217

Merged
ebosido444-ai merged 2 commits from upstream-pr/1217 into main 2026-10-08 18:15:56 +00:00
ebosido444-ai commented 2026-10-07 18:02:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ebosido444-ai on 2026-10-07T18:02:33Z.


What

Main decodes s_swappc_b64 null as s_setpc_b64 (RdnaScalarOpDecoder.cpp:334) and the merged long-branch and dword-jump-table shapes leave a real destination — a call — throwing. A real destination is the GNM fetch-shader call: at a VS/ES/LS entry GNM swaps the PC to the fetch-shader region and the shader returns through s_setpc_b64 on its link pair. This PR translates that call, so shaders entering through a fetch-shader call recompile instead of throwing.

  • Decode: SOP1 0x21 with a real B64 SDST pair decodes as SSwappcB64; scalarDestinationDwordCount accounts the pair.
  • Semantics: D.u64 = PC + 4; PC = S0.u64, the link-register reading of the RDNA2 ISA (amdgpu_isa_rdna2.xml, SOP1 s_swapPC_b64 pseudo-code), matching KytyPS5's DecodeSop1 handling and shadPS4's fetch-shader call treatment (EmitFetch). Unverified on hardware — recorded as such in docs/dev/TechnicalDebt.md per the #843 provenance rule.
  • Translation: the vertex-entry fetch-shader call shape (link pair holding pc + 4) is recognized and the called region is translated inline with the paired s_setpc_b64 acting as its return; static in-shader call regions lift through the same return path. Link arithmetic beyond the true pc + 4 constant throws.
  • Throws (exact-or-throw): computed/data-dependent targets, link values that escape the constant-offset model (compared, hashed or stored), unclosable call/return pairing, recursion. Every behavioural assumption sits in docs/dev/TechnicalDebt.md.
  • s_call_b64 and s_rfe_b64 are untouched in every form — decode, tests, and docs (final diff greps clean; #895 implements s_call_b64 for real).

Tested

Windows 11, winlibs GCC 15.2 + Ninja.

Scoped ctest (CMake, -DANYPS5_ENABLE_SPIRV_TOOLS=ON -DBUILD_TESTING=ON, FFmpeg pre-seeded):

cmake --build build-test --parallel 8 --target agc_shader_control_flow_tests   # BUILD_OK, 398 objects
ctest --test-dir build-test -R agc_shader_control_flow --output-on-failure     # 1/1 Passed, 0.25s

The s_swappc_b64 with a return address case in ControlFlow.cpp pinned the old bare unsupported SOP1 opcode 33 refusal; it now pins the new unclosable s_swappc_b64 call/return pairing refusal.

Standalone decode+translate closure (no cmake):

g++ -std=c++20 -O1 -static -Icore/shader/recompiler/{Translation,RdnaDecoder,IntermediateRepresentation,ControlFlow,Optimization}/include -Icore/shader/recompiler -Icore/libs core/libs/tests/ScalarSwappc.cpp <closure> -o out_fix.exe   # BUILD_EXIT=0
./out_fix.exe   # RUN_EXIT=0

All Require assertions green: static call-region lifting, fetch-call-at-entry recognition (hasFetchCall, fetchCallProgramCounter), dest accounting, and the throw cases (link escape from the constant-offset call/return model, call region shared with another call, recursion). Fails-on-main proof: the test cannot build on main — RdnaOpcode::SSwappcB64 does not exist there and the call shapes hit the documented real-dest refusal.

Checklist

  • Based on current main; no other open PR implements the same functions (#895 implements s_call_b64 — untouched here; #1124 is the fused-half validator's terminator acceptance, consumer-side)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (computed targets, link escapes, unclosable pairing, recursion)
  • No notes, investigation .md files or images added to the repository (TechnicalDebt.md entry only)
  • New third-party code is a submodule built from source (n/a)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4776511928 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1217). Originally posted by [ebosido444-ai](https://github.com/ebosido444-ai) on 2026-10-07T18:02:33Z. --- ### What Main decodes `s_swappc_b64 null` as `s_setpc_b64` (`RdnaScalarOpDecoder.cpp:334`) and the merged long-branch and dword-jump-table shapes leave a real destination — a call — throwing. A real destination is the GNM fetch-shader call: at a VS/ES/LS entry GNM swaps the PC to the fetch-shader region and the shader returns through `s_setpc_b64` on its link pair. This PR translates that call, so shaders entering through a fetch-shader call recompile instead of throwing. - Decode: SOP1 `0x21` with a real B64 SDST pair decodes as `SSwappcB64`; `scalarDestinationDwordCount` accounts the pair. - Semantics: `D.u64 = PC + 4; PC = S0.u64`, the link-register reading of the RDNA2 ISA (`amdgpu_isa_rdna2.xml`, SOP1 `s_swapPC_b64` pseudo-code), matching KytyPS5's `DecodeSop1` handling and shadPS4's fetch-shader call treatment (`EmitFetch`). Unverified on hardware — recorded as such in `docs/dev/TechnicalDebt.md` per the #843 provenance rule. - Translation: the vertex-entry fetch-shader call shape (link pair holding `pc + 4`) is recognized and the called region is translated inline with the paired `s_setpc_b64` acting as its return; static in-shader call regions lift through the same return path. Link arithmetic beyond the true `pc + 4` constant throws. - Throws (exact-or-throw): computed/data-dependent targets, link values that escape the constant-offset model (compared, hashed or stored), unclosable call/return pairing, recursion. Every behavioural assumption sits in `docs/dev/TechnicalDebt.md`. - `s_call_b64` and `s_rfe_b64` are untouched in every form — decode, tests, and docs (final diff greps clean; #895 implements `s_call_b64` for real). ### Tested Windows 11, winlibs GCC 15.2 + Ninja. Scoped ctest (CMake, `-DANYPS5_ENABLE_SPIRV_TOOLS=ON -DBUILD_TESTING=ON`, FFmpeg pre-seeded): ``` cmake --build build-test --parallel 8 --target agc_shader_control_flow_tests # BUILD_OK, 398 objects ctest --test-dir build-test -R agc_shader_control_flow --output-on-failure # 1/1 Passed, 0.25s ``` The `s_swappc_b64 with a return address` case in `ControlFlow.cpp` pinned the old bare `unsupported SOP1 opcode 33` refusal; it now pins the new `unclosable s_swappc_b64 call/return pairing` refusal. Standalone decode+translate closure (no cmake): ``` g++ -std=c++20 -O1 -static -Icore/shader/recompiler/{Translation,RdnaDecoder,IntermediateRepresentation,ControlFlow,Optimization}/include -Icore/shader/recompiler -Icore/libs core/libs/tests/ScalarSwappc.cpp <closure> -o out_fix.exe # BUILD_EXIT=0 ./out_fix.exe # RUN_EXIT=0 ``` All `Require` assertions green: static call-region lifting, fetch-call-at-entry recognition (`hasFetchCall`, `fetchCallProgramCounter`), dest accounting, and the throw cases (link escape from the constant-offset call/return model, call region shared with another call, recursion). Fails-on-main proof: the test cannot build on `main` — `RdnaOpcode::SSwappcB64` does not exist there and the call shapes hit the documented real-dest refusal. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions (#895 implements `s_call_b64` — untouched here; #1124 is the fused-half validator's terminator acceptance, consumer-side) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (computed targets, link escapes, unclosable pairing, recursion) - [x] No notes, investigation `.md` files or images added to the repository (`TechnicalDebt.md` entry only) - [x] New third-party code is a submodule built from source (n/a) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-07 23:00:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-07T23:00:51Z.


Progress report (6b56175 → c3e16af)

📈 GPU shader instructions: 98.2% (+0.09%, +1 implemented instructions)

✅ 1 implemented
Encoding Name
SOP1 S_SWAPPC_B64
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6048588130 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1217#issuecomment-6048588130). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-07T23:00:51Z. --- <!-- progress-report --> ### Progress report (6b56175 → c3e16af) 📈 **GPU shader instructions**: 98.2% (+0.09%, +1 implemented instructions) <details> <summary>✅ 1 implemented</summary> | Encoding | Name | | - | - | | SOP1 | `S_SWAPPC_B64` | </details>
adriadam10 commented 2026-10-08 09:07:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T09:07:36Z.

Review: CHANGES_REQUESTED


Thanks for this. Findings:

  • CI is red on both jobs: agc_shader_control_flow fails with s_swappc_b64 with a return address: expected a refusal with 'unsupported SOP1 opcode 33', got 'unclosable s_swappc_b64 call/return pairing ...'. That test pins the old behaviour; update it for the new one and rerun ctest (the Tested section only has a standalone Windows build, no ctest run).
  • The description doesn't match the diff: #754 is closed, not merged (main only has the s_swappc_b64 null → s_setpc_b64 alias, RdnaScalarOpDecoder.cpp:334), and s_call_b64/s_rfe_b64 are said to be untouched, but RdnaScalarOpDecoder.cpp:43 and :184 change their decode to throw. That overlaps #895 (s_call_b64) and is not part of this topic; drop both lines and the matching test checks (ScalarSwappc.cpp:70-71) and TechnicalDebt line 311.
  • docs/dev/TechnicalDebt.md:307 duplicates the existing "Font writing lines" entry (also at 312); remove the stray one.
  • Tests pin IR shape, not values: CheckLinkModelsNextInstructionAddress compares two IR dumps, and nothing exercises translateExternalFetch (InstructionTranslator.cpp:105) or the inlined attribute loads. Add an execution/translation test that checks the fetched values.
  • Minor: the newline at the end of GraphBuilder.hpp and ScalarSwappc.cpp was dropped.

For reference, on hardware (gfx1035) s_swappc_b64 sdst, ssrc writes the address of the next instruction (PC+4 for the 4-byte SOP1), which matches the pc + 4 model here. The fetch-shader inline itself I could not measure.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5454263258 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1217#pullrequestreview-5454263258). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T09:07:36Z. **Review:** CHANGES_REQUESTED --- Thanks for this. Findings: - CI is red on both jobs: `agc_shader_control_flow` fails with `s_swappc_b64 with a return address: expected a refusal with 'unsupported SOP1 opcode 33', got 'unclosable s_swappc_b64 call/return pairing ...'`. That test pins the old behaviour; update it for the new one and rerun ctest (the Tested section only has a standalone Windows build, no ctest run). - The description doesn't match the diff: #754 is closed, not merged (`main` only has the `s_swappc_b64 null` → `s_setpc_b64` alias, `RdnaScalarOpDecoder.cpp:334`), and `s_call_b64`/`s_rfe_b64` are said to be untouched, but `RdnaScalarOpDecoder.cpp:43` and `:184` change their decode to throw. That overlaps #895 (`s_call_b64`) and is not part of this topic; drop both lines and the matching test checks (`ScalarSwappc.cpp:70-71`) and TechnicalDebt line 311. - `docs/dev/TechnicalDebt.md:307` duplicates the existing "Font writing lines" entry (also at 312); remove the stray one. - Tests pin IR shape, not values: `CheckLinkModelsNextInstructionAddress` compares two IR dumps, and nothing exercises `translateExternalFetch` (`InstructionTranslator.cpp:105`) or the inlined attribute loads. Add an execution/translation test that checks the fetched values. - Minor: the newline at the end of `GraphBuilder.hpp` and `ScalarSwappc.cpp` was dropped. For reference, on hardware (gfx1035) `s_swappc_b64 sdst, ssrc` writes the address of the next instruction (PC+4 for the 4-byte SOP1), which matches the `pc + 4` model here. The fetch-shader inline itself I could not measure.
ebosido444-ai commented 2026-10-08 09:31:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ebosido444-ai on 2026-10-08T09:31:39Z.


All four findings handled on f2b3780f (remote == PR head, verified):

  1. CI red / test pin / ctest — ControlFlow.cpp's s_swappc_b64 with a return address case pinned the old bare refusal; it now expects the new unclosable s_swappc_b64 call/return pairing refusal. ctest run (winlibs GCC 15.2 + Ninja, -DANYPS5_ENABLE_SPIRV_TOOLS=ON -DBUILD_TESTING=ON, cmake --build --target agc_shader_control_flow_tests, ctest -R agc_shader_control_flow): 1/1 Passed, 0.25s (full 398-object link of shader_recompiler_agc_driver + the test). The standalone ScalarSwappc.cpp closure also rebuilt and ran exit-0 after the edits.
  2. s_call_b64/s_rfe_b64 creep — you're right and it shouldn't have been there given the PR text. Both decode rows (RdnaScalarOpDecoder.cpp:43, :184) removed, the two matching ExpectThrow checks in ScalarSwappc.cpp:70-71 removed, and the TechnicalDebt line (was :311) removed. The final diff greps clean of s_call/s_rfe entirely, so the description and diff now agree and #895 has zero overlap.
  3. TechnicalDebt duplicate (was :307) — the doubled "Font writing lines" bullet is gone (the second copy). If you meant the s_swappc_b64 link-pair entry overlapping the existing s_getpc_b64 mode entry instead, say the word and I'll fold it into that entry.
  4. One factual aside to square away: #754 reads state=MERGED, mergedAt=2026-10-05T23:11:57Z via gh pr view --json state,mergedAt, and its s_swappc_b64 null → s_setpc_b64 alias sits at RdnaScalarOpDecoder.cpp:334 on main as you cite — so I believe the merged/closed status reversed there; the What section's gap-quote is from its body. Wording nonetheless made robust to the reading ("the merged null/long-branch/jump-table shapes leave a real-dest call throwing") rather than asserting the quote. Correct me if GitHub is lying to me.

Description drift is the embarrassing class of these — the body now re-derives from the final diff instead of the intent.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6056935575 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1217#issuecomment-6056935575). Originally posted by [ebosido444-ai](https://github.com/ebosido444-ai) on 2026-10-08T09:31:39Z. --- All four findings handled on `f2b3780f` (remote == PR head, verified): 1. **CI red / test pin / ctest** — `ControlFlow.cpp`'s `s_swappc_b64 with a return address` case pinned the old bare refusal; it now expects the new `unclosable s_swappc_b64 call/return pairing` refusal. ctest run (winlibs GCC 15.2 + Ninja, `-DANYPS5_ENABLE_SPIRV_TOOLS=ON -DBUILD_TESTING=ON`, `cmake --build --target agc_shader_control_flow_tests`, `ctest -R agc_shader_control_flow`): **1/1 Passed, 0.25s** (full 398-object link of `shader_recompiler_agc_driver` + the test). The standalone `ScalarSwappc.cpp` closure also rebuilt and ran exit-0 after the edits. 2. **`s_call_b64`/`s_rfe_b64` creep** — you're right and it shouldn't have been there given the PR text. Both decode rows (`RdnaScalarOpDecoder.cpp:43`, `:184`) removed, the two matching `ExpectThrow` checks in `ScalarSwappc.cpp:70-71` removed, and the TechnicalDebt line (was :311) removed. The final diff greps clean of `s_call`/`s_rfe` entirely, so the description and diff now agree and #895 has zero overlap. 3. **TechnicalDebt duplicate (was :307)** — the doubled "Font writing lines" bullet is gone (the second copy). If you meant the `s_swappc_b64` link-pair entry overlapping the existing `s_getpc_b64` mode entry instead, say the word and I'll fold it into that entry. 4. **One factual aside to square away**: #754 reads `state=MERGED`, `mergedAt=2026-10-05T23:11:57Z` via `gh pr view --json state,mergedAt`, and its `s_swappc_b64 null` → `s_setpc_b64` alias sits at `RdnaScalarOpDecoder.cpp:334` on main as you cite — so I believe the merged/closed status reversed there; the What section's gap-quote is from its body. Wording nonetheless made robust to the reading ("the merged `null`/long-branch/jump-table shapes leave a real-dest call throwing") rather than asserting the quote. Correct me if GitHub is lying to me. Description drift is the embarrassing class of these — the body now re-derives from the final diff instead of the intent.
adriadam10 commented 2026-10-08 09:43:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T09:43:27Z.

Review: CHANGES_REQUESTED


Thanks for the update; the earlier findings are addressed (test updated, s_call_b64/s_rfe_b64 decode changes dropped, duplicate TechnicalDebt line gone, body fixed). Build and ctest on the merge with main are green (431/431, including agc_shader_control_flow, agc_driver_scalar_swappc and scalar_swappc). What's left:

  • No test pins values for the new translation path: translateExternalFetch (InstructionTranslator.cpp:105, called at :505) and the inlined attribute loads are not exercised by anything. CheckLinkModelsNextInstructionAddress (ScalarSwappc.cpp:87) only compares two IR dumps, which pins IR shape. Add an execution or translation test that runs a vertex entry with a fetch-shader call and checks the fetched attribute values (including dst_sel and the 'more than four registers' throw).
  • Minor: GraphBuilder.hpp and ScalarSwappc.cpp still lack the final newline.

Not measured by us: the fetch-shader inline itself (the pc + 4 link semantics of s_swappc_b64 match what we measured on gfx1035).

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5454654146 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1217#pullrequestreview-5454654146). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T09:43:27Z. **Review:** CHANGES_REQUESTED --- Thanks for the update; the earlier findings are addressed (test updated, `s_call_b64`/`s_rfe_b64` decode changes dropped, duplicate TechnicalDebt line gone, body fixed). Build and ctest on the merge with main are green (431/431, including `agc_shader_control_flow`, `agc_driver_scalar_swappc` and `scalar_swappc`). What's left: - No test pins values for the new translation path: `translateExternalFetch` (`InstructionTranslator.cpp:105`, called at `:505`) and the inlined attribute loads are not exercised by anything. `CheckLinkModelsNextInstructionAddress` (`ScalarSwappc.cpp:87`) only compares two IR dumps, which pins IR shape. Add an execution or translation test that runs a vertex entry with a fetch-shader call and checks the fetched attribute values (including `dst_sel` and the 'more than four registers' throw). - Minor: `GraphBuilder.hpp` and `ScalarSwappc.cpp` still lack the final newline. Not measured by us: the fetch-shader inline itself (the `pc + 4` link semantics of `s_swappc_b64` match what we measured on gfx1035).
github-actions[bot] commented 2026-10-08 11:34:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T11:34:34Z.


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
#1523 core/shader/recompiler/ControlFlow/include/ControlFlow/GraphBuilder.hpp L5, L15-16
core/shader/recompiler/ControlFlow/src/GraphBuilder.cpp L475, L553, L639, L641-642
#1524 core/libs/prx/libSceAgcDriver/CMakeLists.txt L878
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6058960455 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1217#issuecomment-6058960455). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-08T11:34:34Z. --- <!-- pr-overlap --> 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 | |---|---|---|---| | #1523 | `core/shader/recompiler/ControlFlow/include/ControlFlow/GraphBuilder.hpp` [L5](https://github.com/boykopovar/AnyPS5/blob/ede7ead47314454e1335b2b77bf193e80ff72bb7/core/shader/recompiler/ControlFlow/include/ControlFlow/GraphBuilder.hpp#L5), [L15-16](https://github.com/boykopovar/AnyPS5/blob/ede7ead47314454e1335b2b77bf193e80ff72bb7/core/shader/recompiler/ControlFlow/include/ControlFlow/GraphBuilder.hpp#L15-L16)<br>`core/shader/recompiler/ControlFlow/src/GraphBuilder.cpp` [L475](https://github.com/boykopovar/AnyPS5/blob/ede7ead47314454e1335b2b77bf193e80ff72bb7/core/shader/recompiler/ControlFlow/src/GraphBuilder.cpp#L475), [L553](https://github.com/boykopovar/AnyPS5/blob/ede7ead47314454e1335b2b77bf193e80ff72bb7/core/shader/recompiler/ControlFlow/src/GraphBuilder.cpp#L553), [L639](https://github.com/boykopovar/AnyPS5/blob/ede7ead47314454e1335b2b77bf193e80ff72bb7/core/shader/recompiler/ControlFlow/src/GraphBuilder.cpp#L639), [L641-642](https://github.com/boykopovar/AnyPS5/blob/ede7ead47314454e1335b2b77bf193e80ff72bb7/core/shader/recompiler/ControlFlow/src/GraphBuilder.cpp#L641-L642) | | | | #1524 | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` [L878](https://github.com/boykopovar/AnyPS5/blob/ede7ead47314454e1335b2b77bf193e80ff72bb7/core/libs/prx/libSceAgcDriver/CMakeLists.txt#L878) | | |
adriadam10 commented 2026-10-08 12:27:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T12:27:38Z.

Review: CHANGES_REQUESTED


Rechecked the current head (8e63be9, only a merge with main since the last review): build and ctest on the merge are green (451/451, including agc_shader_control_flow, agc_driver_scalar_swappc, scalar_swappc). The two points from the previous review are still open:

  • No test pins values for the new translation path: translateExternalFetch (InstructionTranslator.cpp:105, called at :505) and the inlined attribute loads are not exercised. CheckLinkModelsNextInstructionAddress (ScalarSwappc.cpp:87) compares two IR dumps, which pins IR shape. Add a translation/execution test that runs a vertex entry with a fetch-shader call and checks the fetched attribute values, including dst_sel and the "more than four registers" throw.
  • GraphBuilder.hpp and ScalarSwappc.cpp still lack the final newline.
  • New: #1523 touches the same lines of GraphBuilder.hpp/GraphBuilder.cpp. If one builds on the other, list it in Depends on; otherwise expect a conflict for whichever lands second.

Not measured by us: the fetch-shader inline itself (the pc + 4 link semantics match what we measured on gfx1035).

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5456535345 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1217#pullrequestreview-5456535345). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T12:27:38Z. **Review:** CHANGES_REQUESTED --- Rechecked the current head (8e63be9, only a merge with `main` since the last review): build and ctest on the merge are green (451/451, including `agc_shader_control_flow`, `agc_driver_scalar_swappc`, `scalar_swappc`). The two points from the previous review are still open: - No test pins values for the new translation path: `translateExternalFetch` (`InstructionTranslator.cpp:105`, called at `:505`) and the inlined attribute loads are not exercised. `CheckLinkModelsNextInstructionAddress` (`ScalarSwappc.cpp:87`) compares two IR dumps, which pins IR shape. Add a translation/execution test that runs a vertex entry with a fetch-shader call and checks the fetched attribute values, including `dst_sel` and the "more than four registers" throw. - `GraphBuilder.hpp` and `ScalarSwappc.cpp` still lack the final newline. - New: #1523 touches the same lines of `GraphBuilder.hpp`/`GraphBuilder.cpp`. If one builds on the other, list it in **Depends on**; otherwise expect a conflict for whichever lands second. Not measured by us: the fetch-shader inline itself (the `pc + 4` link semantics match what we measured on gfx1035).
adriadam10 commented 2026-10-08 18:06:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T18:06:32Z.


Thanks. #639 landed and conflicted with this PR, so I rebased it and finished the open points from my review. Your commit is kept, adapted to #639, and ours is on top:

  • Rebased on main after #639 with no merge commits. translateExternalFetch now uses #639's TranslateEmbeddedFetch(instruction, attribute, components), which emits GetAttribute per component, and drops the helpers #639 removed.
  • #639 builds the CFG at registration (PrepareRegistered, ShaderRegistry.cpp) without SwappcInfo, so any vertex shader with a fetch-shader call would have failed when the title registered it. It now passes the same SwappcInfo as Recompiler.cpp.
  • New execution test agc_driver_scalar_swappc_fetch. It draws with a vertex shader whose first instruction is s_swappc_b64 to a fetch shader at a user-data address, then stores the fetched v8:v11 per vertex and checks them bit for bit, with identity dst_sel and with dst_sel reversed (WZYX). It also checks that five destination registers throw ("the inline model supports one to four").
  • Added the final newlines in GraphBuilder.hpp and ScalarSwappc.cpp.

Tested on the merge with main: the new test passes on RADV (gfx1035) and CI's lavapipe, and the full ctest passes (484/484). Negative check: shifting the inlined fetch's destination register by one fails at vertex 0 v8.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6066068975 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1217#issuecomment-6066068975). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T18:06:32Z. --- Thanks. #639 landed and conflicted with this PR, so I rebased it and finished the open points from my review. Your commit is kept, adapted to #639, and ours is on top: - Rebased on `main` after #639 with no merge commits. `translateExternalFetch` now uses #639's `TranslateEmbeddedFetch(instruction, attribute, components)`, which emits `GetAttribute` per component, and drops the helpers #639 removed. - #639 builds the CFG at registration (`PrepareRegistered`, `ShaderRegistry.cpp`) without `SwappcInfo`, so any vertex shader with a fetch-shader call would have failed when the title registered it. It now passes the same `SwappcInfo` as `Recompiler.cpp`. - New execution test `agc_driver_scalar_swappc_fetch`. It draws with a vertex shader whose first instruction is `s_swappc_b64` to a fetch shader at a user-data address, then stores the fetched v8:v11 per vertex and checks them bit for bit, with identity `dst_sel` and with `dst_sel` reversed (WZYX). It also checks that five destination registers throw ("the inline model supports one to four"). - Added the final newlines in `GraphBuilder.hpp` and `ScalarSwappc.cpp`. Tested on the merge with `main`: the new test passes on RADV (gfx1035) and CI's lavapipe, and the full ctest passes (484/484). Negative check: shifting the inlined fetch's destination register by one fails at `vertex 0 v8`.
adriadam10 commented 2026-10-08 18:15:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T18:15:52Z.

Review: APPROVED


Requested changes done in the commit on top; CI green on the rebased head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5461025117 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1217#pullrequestreview-5461025117). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T18:15:52Z. **Review:** APPROVED --- Requested changes done in the commit on top; CI green on the rebased head.
ebosido444-ai commented 2026-10-09 00:14:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ebosido444-ai on 2026-10-09T00:14:12Z.


Thank you for the rebase and the #639 adaptation — that is far beyond what I expected when I sent it, and the TranslateEmbeddedFetch port is neater than my original helpers. Glad the fetch-shader call rides the recomp refactor in one piece. Nothing further from me.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6071592997 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1217#issuecomment-6071592997). Originally posted by [ebosido444-ai](https://github.com/ebosido444-ai) on 2026-10-09T00:14:12Z. --- Thank you for the rebase and the #639 adaptation — that is far beyond what I expected when I sent it, and the `TranslateEmbeddedFetch` port is neater than my original helpers. Glad the fetch-shader call rides the recomp refactor in one piece. Nothing further from me.
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!1217
No description provided.