Skip to content

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

Open
Thimo188 wants to merge 38 commits into
mainfrom
upstream-pr/28483
Open

Thimo188 wants to merge 38 commits into
mainfrom
upstream-pr/28483

Conversation

@Thimo188

@Thimo188 Thimo188 commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner

Imported from boykopovar/AnyPS5#28483, originally opened by mrfelek.

Source commit: 478c70f7f859bc05e4bae43be2464a6e584a3ec6. 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

This carries boykopovar#9457 by EagleBearerYS, which has had no activity from its author since Nov 26 and conflicts with main. Two stacks are waiting on it: boykopovar#16472 → boykopovar#16631 and boykopovar#16812 → boykopovar#16814. The branch is boykopovar#9457's head a3617bb255 with today's main merged in. All of boykopovar#9457's commits keep their authors (EagleBearerYS, and hugodearaujo for the fixed-offset change). The only changes to them are in the merge commit:

The full description of the two shapes, with their chains, is in boykopovar#9457. In short:

  1. Pointer hops after a pointer-keyed record pointer (Gran Turismo 7 (PPSA01317), from Recompiler: a T# reached through two loads after a dynamically indexed read (pointer → pointer → T#, pointer → V# → buffer → T#) stops Ratchet & Clank (PPSA01474) and Guardians of the Galaxy (PPSA01748) boykopovar/AnyPS5#6191). TryMakeIndirectColumn refused every hop once the record pointer was merged. It 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), from fix(shader): take lane-mask arms and a merged high word in a pointer-keyed record pointer boykopovar/AnyPS5#8939). 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.

The open reviews on boykopovar#9457:

boykopovar#9633, boykopovar#9749, boykopovar#9790 and boykopovar#9969 (also EagleBearerYS's) are carried the same way by boykopovar#16472 and boykopovar#16812, which now depend on this PR only.

Tested

Release builds.

Focused tests: ^(agc_driver_(image_table|nested|pointer)|agc_shader_(disk_cache|memory|nested_sampler)) with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -V, on main 93d64f2d1e and on this head 478c70f7f8. The loader log shows the validation layer loaded in every build, and no log has a VUID- line. On Windows the tests ran as a normal user, so the loader takes the layer from VK_ADD_LAYER_PATH; the skipped test on the Intel GPU is agc_driver_image_table_vouched_lookups, which skips there on main too.

GPU main this head
NVIDIA RTX 3080 Ti, 615.71.09, Linux 7.3 50/50 53/53, twice in a row
AMD Radeon 780M, RADV Mesa 26.0.8, Linux 7.0 50/50 53/53
NVIDIA RTX A2000 Laptop GPU, 610.60, Windows 11 26200, WinLibs GCC 52/52 55/55
Intel UHD Graphics 0x9a60, 32.0.101.7092, Windows 11 26200, WinLibs GCC 52/52 (1 skipped) 55/55 (1 skipped)

Checklist

Supersedes boykopovar#9457.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EqZu9J6tUMvmRP7RkxVCQr

Summary by CodeRabbit

  • Improvements
    • Improved shader resource handling for pointer-based texture descriptors, including pointer hops and fixed-offset descriptors.
  • Tests
    • Added GPU execution coverage for pointer-hop and fixed-offset texture sampling, including checks for updated sampled data when pointers move.

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.
EagleBearerYS and others added 8 commits November 14, 2026 00:30
Moves this branch's FormatVersion to 95, above boykopovar#8939's 94.
Moves this branch's FormatVersion from 95 to 98, above boykopovar#8939's 97.
Resolve the fixed-offset case in ResourceTracker.cpp against main's
SplitImmediateAddend (boykopovar#23778): keep the fixed-offset branch and split
the immediate addend before the masked-offset match. FormatVersion
moves to 99, the next after main's 98.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqZu9J6tUMvmRP7RkxVCQr
@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Pointer-Based Image Tables

Layer / File(s) Summary
Resource tracking and cache version
core/shader/recompiler/Optimization/src/ResourceTracker.cpp, core/shader/recompiler/ShaderDiskCache.hpp
TryMakeTableColumn recognizes fixed immediate offsets for non-address, non-buffer handles. TryMakeIndirectColumn allows pointer hops for merged non-buffer handles while retaining the buffer-handle rejection. FormatVersion changes from 98 to 99.
Pointer sampling execution tests
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp, core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_image_table_tests.cmake
GPU tests cover pointer-hop sampling and fixed-offset T# reads through pointer-loaded V# descriptors. New command-line modes run the tests, and the CMake test configuration applies shared properties to the new cases.

Suggested reviewers: eaglebearerys, celegans12, alfarojo

Change: Bug fix

Merge Risk: Minimal · up to 478c7

This change adds shader resource tracking for pointer-hop and fixed-offset V# image reads, and bumps the shader cache format version so older caches are rebuilt. The reviewed paths show no concrete defect, and the reported tests cover the new behavior. The main visible effect is a one-time shader cache regeneration after upgrade.

Security architecture risk: Minimal · up to 478c7

The ShaderRecompiler handles more image and sampler descriptor patterns through its existing guest-memory read controls. Version-98 shader caches will no longer be reused by the new build. Shaders can be recompiled without a manual migration; prebuilt packs need to be regenerated to preserve cache hits.

Security review details

Security Blast Radius

  • inferred — The newly reachable production behavior is guest descriptor materialization for eligible non-buffer shader handles. The inspected path uses the same runtime memory interface as existing indirect descriptor reads; the new test selectors do not add production callers.

Trust Boundaries and Controls

  • observed — Materialization bounds the initial pointer pair by the source buffer. Subsequent hops may leave that buffer by design; the materializer checks address calculation, alignment, and adjacency, then uses the runtime accessibility callback when supplied. A hop that fails these checks is marked unmapped and is not followed.

Rollout and rollback

  • inferred — The running build's ShaderDiskCache decides which format it accepts; no new operator approval or migration step is introduced. Upgrade misses fall through to normal cache lookup and recompilation. Operators who distribute prebuilt packs need matching version-99 packs to preserve prebuilt hits. Rolling back to version 98 does not require converting version-99 entries: the older build uses version-98 keys and rejects version-99 headers.
Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

  • Mode: Continue automatically
  • Reviewed files: 4
  • Waived: $1.00 (charged $0.00)
  • View usage details

Note

This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 64454d48-0000-4403-97ca-b8c8b86960b1
Commits

Reviewing files that changed from the base of the PR and between 4131f51 and 478c70f.

Files selected for processing: 4

  • core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_image_table_tests.cmake
  • core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
  • core/shader/recompiler/Optimization/src/ResourceTracker.cpp
  • core/shader/recompiler/ShaderDiskCache.hpp

@github-actions github-actions Bot added unblocks title Names a title ID on the Unblocks line agc libSceAgc* shader core/shader build CMake, submodules, 3rdparty labels Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build CMake, submodules, 3rdparty shader core/shader unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants