perf(agc): drop the redundant structurize pre-check at registration #2327

Merged
EdouardSence merged 1 commit from upstream-pr/2327 into main 2026-10-10 07:34:37 +00:00
EdouardSence commented 2026-10-09 15:34:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-09T15:34:27Z.


What

PrepareRegistered decodes the shader, builds its control-flow graph and structurizes it, then throws the graph away. Next, ShaderRecompiler::PrepareShader → PrepareResourceProgram decodes, builds and structurizes the same code again with the same SwappcInfo. Every registered shader therefore goes through GraphBuilder::Build + Structurizer::Structurize once more than needed. mrk1987 counted three Structurize passes per shader on #2105; this removes one of them.

The removed pass only did one thing: throw early. Any exception it raised is raised again from PrepareShader for the same code, so a shader that failed registration before still fails it, with the same message.

No title stops on this; it is a load-time cost. On main the registration path runs for every shader a title registers, so I measured it on a title that registers many.

Tested

Linux (CachyOS, GCC, Release), Ryzen 7 7800X3D, RX 9070 XT, RADV / Mesa 26.2.4.

  • ctest on this branch (rebased on main d70b8998): 512 of 513 pass. The failure is import_audit (source_commit is None because my build tree is a git worktree), unrelated to this change.
  • Rise of the Ronin (PPSA04540), cold shader cache (shader_cache deleted before each run), headless gamescope at 1920×1080. Ronin does not get far on main alone, so these runs use a local stack of open PRs on main 43972e69 (#1836's first version, #1837, #1902, #1928, #2105 and others). The only difference between A and B is this commit. Both runs stop at the same later point, prepared shader artifact is missing for the requested static ABI … stage=1, which is unrelated to this PR. I time from launch to that stop:
Run Before (A) After (B)
1 146 s 105 s
2 144 s 105 s

The shaders compiled are the same in both: 804–809 cache misses in the first 10 s, about 850 in total.

Overlap

#1836 adds its deferral check in PrepareRegistered right before the removed GraphBuilder::Build line. Whichever merges second needs a small rebase. Nothing else changes.

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 (overlaps #1836 and #2257 in PrepareRegistered, see Overlap)
  • AI-assisted: yes. The investigation, code, measurements and this description were written by Claude (Claude Code) on my machine.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4802550973 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2327). Originally posted by [EdouardSence](https://github.com/EdouardSence) on 2026-10-09T15:34:27Z. --- ### What `PrepareRegistered` decodes the shader, builds its control-flow graph and structurizes it, then throws the graph away. Next, `ShaderRecompiler::PrepareShader` → `PrepareResourceProgram` decodes, builds and structurizes the same code again with the same `SwappcInfo`. Every registered shader therefore goes through `GraphBuilder::Build` + `Structurizer::Structurize` once more than needed. mrk1987 counted three `Structurize` passes per shader on #2105; this removes one of them. The removed pass only did one thing: throw early. Any exception it raised is raised again from `PrepareShader` for the same code, so a shader that failed registration before still fails it, with the same message. No title stops on this; it is a load-time cost. On `main` the registration path runs for every shader a title registers, so I measured it on a title that registers many. ### Tested Linux (CachyOS, GCC, Release), Ryzen 7 7800X3D, RX 9070 XT, RADV / Mesa 26.2.4. - `ctest` on this branch (rebased on `main` d70b8998): 512 of 513 pass. The failure is `import_audit` (`source_commit` is `None` because my build tree is a git worktree), unrelated to this change. - **Rise of the Ronin (PPSA04540)**, cold shader cache (`shader_cache` deleted before each run), headless gamescope at 1920×1080. Ronin does not get far on `main` alone, so these runs use a local stack of open PRs on `main` 43972e69 (#1836's first version, #1837, #1902, #1928, #2105 and others). The only difference between A and B is this commit. Both runs stop at the same later point, `prepared shader artifact is missing for the requested static ABI … stage=1`, which is unrelated to this PR. I time from launch to that stop: | Run | Before (A) | After (B) | |---|---|---| | 1 | 146 s | 105 s | | 2 | 144 s | 105 s | The shaders compiled are the same in both: 804–809 cache misses in the first 10 s, about 850 in total. ### Overlap #1836 adds its deferral check in `PrepareRegistered` right before the removed `GraphBuilder::Build` line. Whichever merges second needs a small rebase. Nothing else changes. ### 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 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 (overlaps #1836 and #2257 in `PrepareRegistered`, see Overlap) - [x] AI-assisted: yes. The investigation, code, measurements and this description were written by Claude (Claude Code) on my machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Kikoarl commented 2026-10-09 17:53:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-09T17:53:05Z.


Tested on Linux (CachyOS x86_64, Intel RPL-S iGPU / Mesa 26.3.0-devel / Vulkan 1.4.363, GCC 16.2.1) at 9bc97292:

  • Build: Built cleanly in RAM (/tmp/anyps5_build) with zero warnings/errors.
  • Conventions: python3 tools/check_conventions.py --base origin/main --head HEAD -> PASS (0 errors).
  • Verification: Verified elimination of redundant structurize pre-check in ShaderRegistry.cpp. Trims shader registration overhead cleanly.

LGTM!

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6086312432 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2327#issuecomment-6086312432). Originally posted by [Kikoarl](https://github.com/Kikoarl) on 2026-10-09T17:53:05Z. --- Tested on Linux (CachyOS x86_64, Intel RPL-S iGPU / Mesa 26.3.0-devel / Vulkan 1.4.363, GCC 16.2.1) at `9bc97292`: - **Build**: Built cleanly in RAM (`/tmp/anyps5_build`) with zero warnings/errors. - **Conventions**: `python3 tools/check_conventions.py --base origin/main --head HEAD` -> **PASS (0 errors)**. - **Verification**: Verified elimination of redundant structurize pre-check in `ShaderRegistry.cpp`. Trims shader registration overhead cleanly. LGTM!
popcoder565 commented 2026-10-09 19:03:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T19:03:57Z.


Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head 9bc97292, merged onto main f8c2f072 in one build with 9 other PRs that had no Windows run.

  • This PR has no test of its own. It builds, and the suite passes apart from the failure below.
  • Full ctest in that build: 512 of 513. The one failure is agc_driver_depth_fast_clear_submit from #2325, which fails intermittently on its own too. The test comes from #425, where I reported it.

No title was run.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6087421902 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2327#issuecomment-6087421902). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T19:03:57Z. --- Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head `9bc97292`, merged onto `main` f8c2f072 in one build with 9 other PRs that had no Windows run. - This PR has no test of its own. It builds, and the suite passes apart from the failure below. - Full ctest in that build: 512 of 513. The one failure is `agc_driver_depth_fast_clear_submit` from #2325, which fails intermittently on its own too. The test comes from #425, where I reported it. No title was run. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
oneandonlydean commented 2026-10-10 05:18:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T05:18:46Z.


Needs a rebase: ShaderRegistry.cpp conflicts with main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094144356 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2327#issuecomment-6094144356). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-10T05:18:46Z. --- Needs a rebase: `ShaderRegistry.cpp` conflicts with main.
adriadam10 commented 2026-10-10 07:32:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:32:13Z.


Rebased onto current main as requested. The conflict was with #1836: main now decodes the shader before the deferral check (UnresolvableSwappcTarget), so the decode stays. The rebased change only drops the redundant GraphBuilder::Build + Structurize pre-check and the Structurizer.hpp include (GraphBuilder.hpp stays, it declares SwappcInfo). PrepareResourceProgram (Recompiler.cpp:100-117) repeats both with the same SwappcInfo, so the exceptions are unchanged.

Build + ctest of libSceAgcDriver on the rebased head: 304/304. The Ronin timing in the description was taken with the decode also removed, so the saving on main will be somewhat smaller.

Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6095148745 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2327#issuecomment-6095148745). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T07:32:13Z. --- Rebased onto current `main` as requested. The conflict was with #1836: `main` now decodes the shader before the deferral check (`UnresolvableSwappcTarget`), so the decode stays. The rebased change only drops the redundant `GraphBuilder::Build` + `Structurize` pre-check and the `Structurizer.hpp` include (`GraphBuilder.hpp` stays, it declares `SwappcInfo`). `PrepareResourceProgram` (`Recompiler.cpp:100-117`) repeats both with the same `SwappcInfo`, so the exceptions are unchanged. Build + ctest of libSceAgcDriver on the rebased head: 304/304. The Ronin timing in the description was taken with the decode also removed, so the saving on `main` will be somewhat smaller. Merging once CI is green.
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!2327
No description provided.