Skip to content

perf(agc): check the most recent framebuffer first - #857

Closed
meh7an wants to merge 1 commit into
boykopovar:mainfrom
meh7an:perf/agc-framebuffer-mru-check
Closed

meh7an wants to merge 1 commit into
boykopovar:mainfrom
meh7an:perf/agc-framebuffer-mru-check

Conversation

@meh7an

@meh7an meh7an commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

What

Pipeline::AcquireFramebuffer first pruned its cached framebuffers (a use_count and an expired() per owner of every entry) and then scanned them, on every draw. A hit is rotated to the back, so consecutive draws into the same targets find it there. The back entry is now checked first; the prune and the scan run only on a miss, as before.

#419 changes the same function for multisampled targets. The two don't overlap in purpose: the entry comparison is now one matches lambda used by both the back-entry check and the scan, so whichever lands second only needs #419's owned check moved into that lambda.

Tested

Windows 11, MinGW GCC 15.2, RTX 2080 Ti. This branch builds, and the 165 agc driver, recompiler and execution test targets pass with it stacked on the other changes I'm sending (#849 and the perf PRs opened with this one). I haven't measured this change alone: together with 14 changes of the same kind on my working branch it took Sonic Origins Plus's heaviest menu page (about 1,650 draws per frame) from 48.0 to 43.6 ms per frame (20.8 to 22.9 FPS).

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
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

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
#419 core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp L289-290, L297-302
#1077 core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp L297-302

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thanks. The back-entry check uses the same comparison as the scan, owner identity included, so a hit returns the same framebuffer as before. The only difference is that the prune of expired entries now runs only on a miss. That's fine, since a miss is the only time the list grows.

Two things:

  • Performance PRs need before/after numbers for the change itself (the owner asked for this on perf(shader): cut hot-path overhead in recompile cache lookups #218). The 48.0 to 43.6 ms figure is for 15 changes together. Could you measure main against main plus this PR alone on the same page? The mean frame time over a few runs is enough, or the AcquireFramebuffer share of the profile.
  • The comment about recycled view handles moves into the new lambda. CONVENTIONS only allows comments for technical debt, #endif and namespace ends, so it can go now that the lines are being rewritten anyway.

@meh7an
meh7an force-pushed the perf/agc-framebuffer-mru-check branch from 318868d to e356edb Compare October 7, 2026 17:28
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Closing for now: there are still no numbers for this change on its own. Please reopen with a before/after (frame time or the profiled function) for this change alone.

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.

2 participants