feat(shader): follow pointer chains from image-table records to the T# #6232
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6232"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by ANONYMOUSZED-beep on 2026-10-15T05:59:51Z.
What
Part of #6191: the Guardians of the Galaxy chain (constant buffer → pointer → pointer → T#). The Ratchet & Clank chain (record → pointer → V# → T# at a second
readfirstlaneindex) needs a second key and is not covered here.#4475 plans an image-table record that holds a pointer to the T#. When the pointer itself is loaded through another pointer, the column was refused:
TryMakeIndirectColumnwanted both pointer dwords to be scalar buffer reads, so the stop isGetImageResource dword 0 is not a valid runtime valuewith the chainLoadAddressU32(GetAddressResource(LoadAddressU32(GetAddressResource(ReadConstBuffer …)))).GetAddressResourcewhile both of its dwords are consecutiveLoadAddressU32reads (offsetnandn + 4, immediate offset, same or equivalent pointer). Each step is onePointerHop {offset, immediate}. The record at the end of the chain is matched as before. Any depth is accepted; a chain that does not end in a keyed record read is refused as before.column.pointerHopsin order. A hop that is unaligned, wraps, or reaches an unmapped page makes the recordUnmappedpoison, like an unreadable T#. Each link's 8 bytes are added to the table's ranges, so a changed link rebuilds the table.TableColumngainspointerHops; the plan encoder and decoder carry it, and theShaderDiskCachelayout asserts are updated. A column with no hops is planned and encoded as before.Tested
Amazon Linux 2023 (x86-64, GCC 14.2.1, Release),
maind92a8dad3. I have no GPU and no game, so I could not run Guardians or Ratchet.agc_shader_bindless: newverifyPointerChainImageTable. A compute shader reads a record pointer withs_buffer_load_dwordx2atkey * 16 + 8, loads a second pointer withs_load_dwordx2at+0x10, and the T# withs_load_dwordx8at+0x20. It checks the column (indirect, stride 16, offset 8,pointerHops == {{0, 0x10}}), that every scalar address load is planning-only and the shader does not use BDA, that two chains to the same T# share one element and a different T# gets its own, that records whose chain hits a null pointer areUnmappedpoison, that the links are in the captured regions and snapshot ranges, and that moving one record's second pointer changes its T#.GetImageResource dword 0 is not a valid runtime value; chain: LoadAddressU32@pc=0x4c(GetAddressResource(LoadAddressU32@pc=0x44(GetAddressResource(ReadConstBuffer@pc=0x3c(…, the same shape as the Guardians report.agc_shader_disk_cache. The hand-built plan now has two pointer hops. It passes, and it fails ("the decoded hand-built plan differs…") when the hop encoding is removed.agc_driver_image_table: newRunPointerChainRecordTests(PointerChainRecordCode, which isIndirectRecordCodeplus ones_load_dwordx2). It checks texels per record, one element per distinct T#, and that moving record 1's second pointer changes what it samples. It passes on lavapipe (Mesa 24.2.6, CPU only, no hardware GPU). On the unchanged tracker it fails with the sameGetImageResource dword 0chain.agc_driver_image_tablebehaves the same with and without this change.RunAnisoOverrideTestsfails ("a direct pair changed its texels"), andRunGraphicsTestsdid not finish within 15 minutes. Each group was run on its own: the other groups pass, includingRunPointerRecordTests,RunSplitRecordTestsandRunPointerStorageWriteTests. I could not run the full suite on real hardware.agc_shader_memory,agc_shader_bindless,agc_shader_srt_read_patching,agc_shader_frontend_pair(_off),agc_shader_quad_mask_no_demote,agc_shader_layout_pair(_off)andagc_shader_disk_cachepass.python3 tools/check_conventions.py --base origin/mainreports no findings for the code.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file (none added).mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T07:33:07Z.
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.
main)core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppL2517, L6166, L6219core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cppL281-282, L1218core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hppL51core/shader/recompiler/Optimization/src/ResourceMaterializer.cppL821core/shader/recompiler/Optimization/src/ResourceTracker.cppL690-692, L699, L734-735core/shader/recompiler/ShaderDiskCache.cppL152Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cppcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/ShaderDiskCache.cppImported from boykopovar/AnyPS5. Originally posted by Neithennn on 2026-10-15T15:14:56Z.
Windows NVIDIA run, since the description lists lavapipe only.
Windows 11 Pro 26200, NVIDIA GeForce RTX 4080 (driver 617.42), AMD Ryzen 7 5800X, WinLibs GCC 15.2.0 r7, Ninja, Release, bundled dependencies,
BUILD_TESTING=ON,ANYPS5_NO_SHADER_CACHE=1. Head6b662dd8bmerged onto mainff23657f3; full build succeeds.ANYPS5_REQUIRE_VULKAN=1:agc_shader_bindless,agc_shader_memory,agc_shader_disk_cache,agc_driver_bindless_images,agc_driver_image_table,agc_driver_image_table_cache,agc_driver_image_table_cache_bounds,agc_driver_image_table_reuse: 8/8 pass.verifyPointerChainImageTableruns in bothagc_shader_bindlessandagc_shader_memory.ctest -R "agc_|shader|recompiler|spirv|video_out" -j 8: 622/623, same as unchanged main on this machine; the one failure isagc_driver_store_over_untracked(#6347/#6383), also failing on main.As far as I can tell from the source,
verifyPointerChainImageTablecompiles and materializes on the host and does not dispatch on the GPU, so this mainly shows the change does not regress the GPU-dispatching image-table tests on NVIDIA/Windows. No title run.AI-assisted: yes (runs done with Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-15T18:45:17Z.
Title run on Guardians of the Galaxy (PPSA01748), the title this PR targets from #6191. Head
6b662dd8bmerged ontomain03c4cb5e7, with a control on thatmainalone. Both use the same relinked executable and no local patches.main03c4cb5e70x3b94a7500stage 5,GetImageResource dword 0 is not a valid runtime value,LoadAddressU32@pc=0x84(GetAddressResource(LoadAddressU32@pc=0x70(GetAddressResource(ReadConstBuffer@pc=0x30(…ReadFirstLane(GetInterpolationParameter…So the constant buffer → pointer → pointer → T# half of #6191 is covered on the title. Menu frame rate with a warm shader cache is the same on both builds, about 11–14 FPS.
The next stop is in the draw path, not in this PR's code. A
DRAW_INDEX_INDIRECT_MULTI(opcode0x38, 144 records, stride 20) is issued afterINDEX_BUFFER_SIZEis set to0x10000000with 16-bit indices. For indirect indexed draws the driver binds that whole declared range (Pm4.cpp, "the declared range is the hardware's view of the index buffer"), so it asks for 512 MiB at0x383240000. Only about 54 MiB of it is mapped:The stack, from a local print added for this run only:
Driver::draw→Pm4::ResolveDraw(indirect path) →GuestMemory::CheckRange. I'll open a separate issue for it.Details
--to-intelby the relinker at03c4cb5e7.0x3865a0000in one run and0x386590000in the others. With a warm cache the stop comes before the shield screen is drawn, though music has already started.0x3b91c3e00-family shaders, which use the pc0x4378/0x4380key read throughImageRead. They are deferred at registration and don't stop the load.Tested and written by Claude (AI assistant) on a contributor's machine.