Skip to content

fix(shader): follow pointer hops and fixed-offset V# reads behind a record pointer - #105

Open
Thimo188 wants to merge 37 commits into
mainfrom
upstream-pr/9457
Open

Thimo188 wants to merge 37 commits into
mainfrom
upstream-pr/9457

Conversation

@Thimo188

@Thimo188 Thimo188 commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Imported from boykopovar/AnyPS5#9457, originally opened by EagleBearerYS.

Source commit: a3617bb2555c5f5a39bafa0f792951b8e40dc11e. The import branch preserves this fetched upstream PR snapshot. The description and validation below are copied from upstream; no new code changes or test runs were made for this import. Original reviews, discussions, and attachments remain at the linked upstream PR.


What

Two shapes from boykopovar#6191's family that the planner still refuses on boykopovar#8939. Each gets its own commit and test.

1. Pointer hops after a pointer-keyed record pointer (Gran Turismo 7 (PPSA01317), frankea on boykopovar#6191, comment).

  • The chain: 28 of the World Map's 29 refused compute shaders read a record (an SRT V#, a readfirstlane key in a waterfall loop) whose dwords 2-3 are a pointer P1. P1's words are a Phi of the record read under several keys and a Ballot lane-mask word. Then P2 = [P1 + 0] and the T# at [P2 + 0x340]:

    GetImageResource dword 0 is not a valid runtime value; chain: LoadAddressU32@pc=0x00002404(GetAddressResource(LoadAddressU32@pc=0x000020ec(GetAddressResource(Phi(Phi(ReadConstBuffer@pc=0x00000160(...), CompositeExtractU32x4(Ballot(LogicalAnd), Immediate)), ReadConstBuffer@pc=0x00000160(...)), ...
    
  • Why it refuses: TryMakeIndirectColumn refuses any pointer hop once the record pointer is merged: if (!hops.empty() && (buffer || merged)) return false;.

  • What the steps after it already do for a pointer-keyed column: the snapshot stores each record's pointer before it applies pointerHops. The shader looks the T# up by the record-level pointer (parentPointer). ShaderDiskCache already serializes and accepts hops on such columns.

  • The change: the guard now refuses hops only for buffer columns.

2. A T# at a fixed offset of a pointer-loaded V# (Marvel's Spider-Man 2 (PPSA03016), hugodearaujo on boykopovar#8939, comment).

  • The chain: a record keyed by readfirstlane << 4, dwords 2-3 a pointer, a V# loaded at that pointer plus an immediate, and the T# read at a fixed offset of that V#'s buffer, with no second key:

    GetImageResource dword 0 is not a valid runtime value; chain: ReadConstBuffer@pc=0x8560(GetBufferResource(LoadAddressU32@pc=0x854c(GetAddressResource(ReadConstBuffer@pc=0x1fc4, ...
    
  • Why it refuses: TryMakeTableColumn refused it, because MatchAffineOffset fails on an immediate offset.

  • The change: hugodearaujo's change, kept as their commit. A fixed offset under a pointer-loaded V# becomes a one-key child of the nested path: key 0, stride the descriptor size, addend the immediate. A fixed offset under a runtime V# still refuses, as before.

Not in this PR:

Overlap:

Tested

Checklist

Related: boykopovar#6191

EagleBearerYS and others added 30 commits October 21, 2026 21:36
TryMakeIndirectColumn refused every pointer hop once the record's
pointer words were merged, so a T# read through a pointer loaded from a
pointer-keyed record pointer stayed unplanned (Gran Turismo 7's World
Map compute shaders, issue boykopovar#6191). Only buffer handles still refuse hops:
the materializer keys the records by the innermost pointer before it
follows the hops, and the plan's parent pointer is that innermost one.
…one-key child

From hugodearaujo's change on boykopovar#8939 (Marvel's Spider-Man 2, PPSA03016).
Spider-Man 2's shape: a record keyed by a first-lane read, its dwords
2-3 a pointer, a V# loaded at that pointer plus 0xa0, and the T# read at
offset 0 or 0x40 of that V#'s buffer with no second key. Two records
point at V#s of different T#s; a moved record pointer and a moved V#
must change the result without recompiling.
# Conflicts:
#	core/libs/prx/libSceAgcDriver/CMakeLists.txt
…at, 53

The format ladder along the stack is boykopovar#8939 51 and this PR 53, so a cache
written by boykopovar#8939's recompiler is not read as this one's.
# Conflicts:
#	core/shader/recompiler/Optimization/src/ResourceTracker.cpp
…at, 67

boykopovar#8939 now takes 66, and no open pull request uses a number above it, so this PR takes 67.
4769d4a is boykopovar#8939 with boykopovar#7395's merge of main after boykopovar#7223. The one
conflict is this branch's FormatVersion 67.
Takes boykopovar#8939's FormatVersion 80, which is above this branch's 67; the next commit gives this branch its own number.
…at, 81

boykopovar#8939 now takes 80, above this PR's 67, so this PR takes 81, the lowest number above it that no open PR uses, and a cache written by another branch's recompiler is not read as this one's.
@github-actions github-actions Bot added unblocks title Names a title ID on the Unblocks line needs rebase Conflicts with main, rebase needed labels Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with main, rebase needed unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants