Skip to content

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

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
EdouardSence:perf/agc-registration-structurize
Oct 10, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
EdouardSence:perf/agc-registration-structurize

Conversation

@EdouardSence

@EdouardSence EdouardSence commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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.

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

🤖 Generated with Claude Code

@Kikoarl

Kikoarl commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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 f8c2f07 in one build with 9 other PRs that had no Windows run.

No title was run.

🤖 Addressed by Claude Code

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Needs a rebase: ShaderRegistry.cpp conflicts with main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adriadam10
adriadam10 force-pushed the perf/agc-registration-structurize branch from 9bc9729 to d8ae88c Compare October 10, 2026 07:32
@adriadam10

Copy link
Copy Markdown
Collaborator

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.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 10, 2026
@adriadam10
adriadam10 merged commit 2f655b1 into boykopovar:main Oct 10, 2026
14 checks passed
SleglJan added a commit to SleglJan/AnyPS5 that referenced this pull request Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants