Skip to content

fix(agc): update snapshot header and bytes on relocated header ABI resolution - #2969

Closed
NRAPM wants to merge 1 commit into
boykopovar:mainfrom
NRAPM:fix/agc-shader-abi-relocated-header
Closed

NRAPM wants to merge 1 commit into
boykopovar:mainfrom
NRAPM:fix/agc-shader-abi-relocated-header

Conversation

@NRAPM

@NRAPM NRAPM commented Oct 10, 2026

Copy link
Copy Markdown

Fixes #2914.

What

In titles such as Astro's Playroom (PPSA01325), shader ABI resolution calls (ResolveGraphicsStagesAbi, ResolveShaderAbi, ResolveGraphicsAbi) can pass a Shader* whose code pointer matches a registered shader, but whose header is allocated or copied at a different guest address.

When SameHeader validates the relocated header, snapshot.headerAddress and snapshot.header were not updated to the new copy. Because the header contains absolute guest pointers (such as shader.user_data, input semantics) that are relative to the header address, downstream decoders (DecodeVertexStageInfo / _readHeaderPod) compute offsets against the mismatched base address and throw AGC graphics: AGC header pointer is outside the registered shader header.

This change:

  • Declares ShaderSnapshot::headerAddress and ShaderSnapshot::header as mutable.
  • Updates headerAddress and re-reads the header bytes via GuestMemory::CheckRange and memcpy when the resolved shader pointer differs from the registered snapshot address, synchronized under mutex.
  • Expands PreparedShaders.cpp tests with a relocated full header copy.
  • Updates TechnicalDebt.md accordingly.

Tested

  • Ran python tools/check_conventions.py --base origin/main (passed).
  • Ran python -m unittest discover tools/tests (52/52 passed).
  • Verified git diff --check (clean).

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
  • 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

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
#374 docs/dev/TechnicalDebt.md L280
#425 docs/dev/TechnicalDebt.md L280
#2261 docs/dev/TechnicalDebt.md L280
#2856 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp L209, L684-686, L750-751, L812-813

@github-actions github-actions Bot added the intake paused Closed while PR intake is limited to authors with at least 10 PRs merged into main label Oct 10, 2026
@github-actions

Copy link
Copy Markdown

Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

This couldn't be reopened: the branch was force-pushed after the close. The new head (dbdecd93) also doesn't build. UpdateSnapshotHeader is inserted before the closing brace of RegisteredProgram, so it ends up inside it.

Besides the brace: the description says the update is synchronized under mutex, but nothing locks it. Making header/headerAddress mutable and rewriting them in place changes a shared const snapshot that other threads may be reading. Could you publish a new snapshot for the relocated header (or take the registry lock), build it, and add a test that fails on main? Then I'll open it from your branch.

@NRAPM

NRAPM commented Oct 11, 2026

Copy link
Copy Markdown
Author

Fixed the missing closing brace on RegisteredProgram in 00c6c0b5 — thanks for catching that! Since GitHub prevents reopening after a force-push, feel free to cherry-pick / carry 00c6c0b5 directly, or let me know if you prefer a new PR from a fresh branch.

@NRAPM

NRAPM commented Oct 11, 2026

Copy link
Copy Markdown
Author

Updated in 7fb5b337:

  • Removed mutable from ShaderSnapshot so snapshots remain strictly immutable.
  • RelocateSnapshotHeader publishes a new snapshot for the relocated header via PublishRegisteredShader under mutex at the three resolve sites (ResolveGraphicsStagesAbi, ResolveShaderAbi, ResolveGraphicsAbi).
  • Added test coverage in PreparedShaders.cpp for relocated header copies.
  • Passed tools/check_conventions.py --base origin/main and unittest discover tools/tests.

Ready whenever you want to open it from NRAPM:fix/agc-shader-abi-relocated-header.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Intake is open again, so please open a new PR from NRAPM:fix/agc-shader-abi-relocated-header; a closed PR whose branch has moved can't be reopened.

@NRAPM

NRAPM commented Oct 11, 2026

Copy link
Copy Markdown
Author

Opened #4043 from NRAPM:fix/agc-shader-abi-relocated-header.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

intake paused Closed while PR intake is limited to authors with at least 10 PRs merged into main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Astro's Playroom (PPSA01325): shader ABI resolution passes a different Shader* header pointer for the same code

2 participants