Skip to content

perf(shader): avoid copying SRT read uses - #3726

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
NFSS10:perf/srt-plan-use-replacement
Oct 11, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
NFSS10:perf/srt-plan-use-replacement

Conversation

@NFSS10

@NFSS10 NFSS10 commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

What

Replace the temporary copy of each patched instruction’s operand-use list with the existing IrValue::ReplaceAllUsesWith helper.

This avoids allocating and copying a temporary use list for every patched SRT read. The change is intentionally small and targets shader-planning work where reads have multiple consumers.

Tested

  • Windows, MinGW GCC 15.2.0, Release build
  • agc_shader_srt_read_patching passed
  • agc_shader_bindless passed
  • python tools/check_conventions.py --base upstream/main passed
  • git diff --check passed
  • Temporary synthetic SrtWalker::BuildPlan A/B benchmark with 12 alternating baseline/optimized runs per case. IR construction was excluded from timing; each run used fresh programs and discarded a warm-up batch:
    • 256 reads, one use each: 3.103 ms baseline vs 3.087 ms optimized (0.51% faster)
    • 1,024 reads, one use each: 47.922 ms baseline vs 47.901 ms optimized (0.04% faster)
    • 16 reads, 64 uses each: 185.938 µs baseline vs 174.288 µs optimized (6.27% faster)
  • Dreaming Sarah: 14 captured graphics shader requests replayed successfully. These requests did not contain planned SRT reads, so they served as a replay check rather than a benchmark of this change.

The benchmark shows a small workload-dependent reduction in SRT planning time, with the clearest improvement when reads have many consumers. It is not intended to claim a general game FPS or end-to-end compilation gain.

Checklist

  • Based on current main; no other open PR implements the same functions. I checked for SrtPlanBuilder and found no matching PR. Open PR perf(shader): compile reusable SRT expression plans #1341 is related SRT performance work, but changes compiled runtime evaluation rather than this use-replacement code.
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; silent stubs are listed in TechnicalDebt
  • No notes, investigation files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked: ReplaceAllUsesWith loops until the use list is empty, same result as the old copy-and-replace; the new agc_shader_srt_read_patching test pins the replacement (repeated operand, second user, remaining ReferenceU32), and libSceAgc/libSceAgcDriver ctest is green. Merging once CI is green.

@adriadam10
adriadam10 merged commit c4d3b3a into boykopovar:main Oct 11, 2026
13 checks passed
@NFSS10
NFSS10 deleted the perf/srt-plan-use-replacement branch October 12, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants