fix(agc): accept bound copies of a registered shader header that differ only in user_data #1837
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1837"
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 EdouardSence on 2026-10-08T21:09:06Z.
What
The static, graphics and rectangle ABI resolvers look up the registered shader by its code address. #639 made them require the bound
Shaderheader to be at the registered header's address, and otherwise throw... refers to a replaced shader header.Astro Bot (PPSA21567) registers a vertex shader with its header at 0x50000e500, then binds it for a draw through a copy at 0x307ae3920. The copy's 96 fixed
Shaderbytes match the registered header exceptuser_data: 0x50000e668 in the registered header, null in the copy. Thecx_registers,sh_registers,specialsand semantic pointers still point into the registered header. The bytes after the fixed fields are unrelated memory, so onlysizeof(Shader)is compared.SameHeadernow accepts a bound header when it is at the registered address, or when its fixed fields equal the registered header's withuser_dataignored. Any other difference still throws. The registered header's metadata is used, as before. This is recorded in TechnicalDebt, because whether the console reads the copy'suser_datais unknown.Tested
Linux (CachyOS, GCC), RX 9070 XT, Mesa 26.2.4 RADV.
agc_driver_prepared_shadersnow also resolves the static ABI through a copy of the registered compute header:user_data, it is accepted;target, it still throwsreplaced shader header;ctest: 484/485. The failing test isimport_audit, a Python tool test that fails the same way onmainwith Python 3.14 here.tools/check_conventions.pypasses.main4b6ab6bbwith #1836, scripted and headless:rectangle ABI refers to a replaced shader header;shader image heap capacity exceeded(#1789). No frame is presented yet.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-09T00:46:50Z.
Tested on Stray (PPSA02100 v1.05, Unreal Engine 4). It hits the same
rectangle ABI refers to a replaced shader header(fromsceAgcCreateInterpolantMapping->ResolveGraphicsAbi), but this PR alone doesn't get it through.Setup: Linux (Nobara 44, kernel 7.2), RTX 5070 Ti, NVIDIA 595.91.07. Base is
main1be6f9f1+ #861 + #1836 + #1893 + #1902 + #1904.Stray binds a copy of a registered vertex shader header (registered at +0x0, copy at +0x250). I dumped both 96-byte
Shaderstructs at the failing compare. They differ in only two places:Byte 93 is padding:
num_sh_registersis at offset 92 andsizeof(Shader)is 96. The game's copy zeroes it and the registered header has 0x7f there, so thememcmpoversizeof(Shader)still fails.Comparing only up to the end of the last field fixes it:
With that one change on top of this PR, Stray gets past the interpolant mapping and stops later on an unrelated
prepared rectangle artifacts are missing. Without it, it aborts at the same point every run (runs 8 to 11).The test in this PR doesn't catch it because
Shader copy = header.shader;copies the padding too. Writing a nonzero byte at offset 93 of the registered header (or zeroing the copy's padding) before the compare would cover it. Happy to send the change and a test as a suggestion on this PR if that helps.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by NahuelGenchi on 2026-10-09T05:15:12Z.
Sonic Origins (PPSA05324) hits the static ABI variant of this,
static ABI refers to a replaced shader header, onmainf1451396+ #2004 once #1789 is worked around locally.In one run, 14 shaders (header type 1) are bound 46 times through a copy of their registered header 0x78 bytes below it. All 96 fixed bytes of the copy equal the registered header,
user_dataincluded, so the comparison in this PR would accept them. Accepting byte-identical copies locally gets the title past this stop.Bring-up thread: #2021
Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-09T06:49:42Z.
Tested on a second title: Disney Epic Mickey: Rebrushed (PPSA15657, UE4) stops on the same
rectangle ABI refers to a replaced shader header. With this PR it still stops there, because the comparison also covers the struct's tail padding.I logged the 96-byte comparison in
SameHeaderlocally. Every field matches,user_dataincluded, and the only difference is in the last 8 bytes:At +0x58 the fields are
special_sizes_bytes= 0x0030,type= 2,num_cx_registers= 10 andnum_sh_registers= 11. They end at +0x5d. Bytes +0x5d..+0x5f are padding, and the title's copy has a leftover0x7dthere.std::memcmp(&used, ®istered, sizeof(Shader))therefore rejects a copy whose fields all match.Comparing up to the end of the last field fixes it here:
A field-by-field comparison would also work. With that change, the title gets past this point and stops at an unrelated stub.
Measured on RX 7600 (gfx1102), Linux, with
mainf1451396plus a local stack of open PRs including #1836.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-09T07:34:21Z.
@johnmaia thanks, you're right.
Shaderends at +0x5d, so the last 3 bytes are padding, andmemcmpoversizeof(Shader)compared them. 8d9bcb7a compares up to the end ofnum_sh_registersinstead. The struct has no interior padding, so this covers every field and nothing else.The test in
Registration()now also binds a copy with0x7din its last padding byte. It fails before the change and passes after.Rebased onto
maina8b032b2.ctest -j8: 494 of 495 pass. The one failure isimport_audit, which can't read the commit hash in my worktree and is unrelated.@NahuelGenchi thanks for the Sonic Origins data. The static ABI path uses the same comparison.
AI-assisted: the fix, the test and this reply were written by Claude (Claude Code) on my machine.
Imported from boykopovar/AnyPS5. Originally posted by orbz22 on 2026-10-09T12:44:45Z.
Astro's Playroom (PPSA01325) hits this on Windows with NVIDIA, right after #1836.
On
main745b775e+ #1836 it stops withAGC driver: rectangle ABI refers to a replaced shader header. With this PR on top (8d9bcb7a) it gets past it. The next stop is theDB_RENDER_CONTROLdepth clear draws that #1395 recognises.Setup: Windows 11, RTX 3060 Laptop (NVIDIA 616.92), WinLibs GCC 15.2.
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-09T16:04:40Z.
PPSA26344 (Ghost of Yōtei) binds copies of registered headers that this still rejects with "replaced shader header". The title copies the whole header (
header_size376) to another address and relocates every pointer that points into the header.codestays the same:user_datacodecx_registerssh_registersspecialsinput_semantics/output_semanticsEvery changed pointer moved by the same 0x2b0b8 as the header. The other fixed fields are identical.
A small extension on top of this PR treats a register, specials or semantics pointer as equal when it points into the registered header (
[headerAddress, headerAddress + header_size)) and the copy's value is that pointer plus the distance between the two headers. Anything else still fails, including pointers moved by any other distance. With an earlier prototype of this check, the title got past every such copy in my runs and reached its first presented frames. It's on a branch stacked on this one, with aPreparedShaderscase: a wholeHeadercopied with its pointers relocated resolves, and one pointer off by one element is refused. I also extended your TechnicalDebt line.Would you rather pick that up here, or should I open it as a separate PR on top of this one?
Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-09T19:04:04Z.
Thanks, that table settles it: the copy is the whole header with every pointer into it moved by the header's own distance. That is the same thing this PR is about, bound copies of a registered header, so I'd rather take it here than stack a second PR. There is also a practical reason. Since
pr-intake.ymllanded today, a new PR from an author with fewer than 20 merged PRs is closed automatically, so a stacked PR from either of us would be closed on opening.Could you link the branch? I'll pull your commit in as it is, keeping you as author, and update the description with your Yōtei result. Ghost of Yōtei is one of the titles I run, so I'll also check that it gets past the "replaced shader header" copies here. That run won't happen right away; the machine is busy for now.
Written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-09T19:24:19Z.
Thanks, happy for it to go in here. The branch is https://github.com/Pipodi/AnyPS5/tree/fix/relocated-shader-header-copies
It's one commit,
56b154a3, directly on your current head8d9bcb7a, so it should fast-forward:ShaderRegistry.cpp: a pointer field also matches when the registered one points into the registered header and the copy moved it by exactly the distance between the two headers. Any other difference still refuses the header.PreparedShaders.cpp: a wholeHeadercopied to another address with its register and specials pointers relocated now resolves. The same copy withspecialsone element past its relocated address is still refused. Without the change the relocated copy fails with "static ABI refers to a replaced shader header".TechnicalDebt.md: the one-line update for the widened check.Tested on Windows 11, MinGW-w64 GCC 15.2.0, RTX 4090: full ctest 489/489. On Yōtei (PPSA26344 v1.008), with an earlier prototype of this check on our integration branch, the "replaced shader header" stops are gone and the title reaches its first frames.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T05:16:57Z.
This conflicts with main in
ShaderRegistry.cppsince #1836 merged; could you rebase? It passed testing at 8d9bcb7a. If Pipodi's relocation commit comes in with the rebase, it gets tested again before merging.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:11:36Z.
Rebased onto current
mainas requested: the only conflict was two adjacent includes inShaderRegistry.cpp(<cstdio>from main,<cstddef>from this PR), both kept. The diff is otherwise unchanged. Partial build and ctest (libSceAgcDriver, libs, libkernel) pass 380/380. Pipodi's relocation commit is not included. Merging once CI is green.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T07:14:11Z.
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/Execution/src/Driver/Shaders/ShaderRegistry.cppL14docs/dev/TechnicalDebt.mdL247Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-10T07:45:56Z.
Thanks for merging. The relocation extension discussed above isn't part of this merge: whole-header copies whose pointers into the header all move by the header's own distance, which PPSA26344 binds and which still fail with "static ABI refers to a replaced shader header".
It's rebased onto current
mainas one commit,44a80d4f, on https://github.com/Pipodi/AnyPS5/tree/fix/relocated-shader-header-copies. It touchesShaderRegistry.cpp, adds aPreparedShaderscase, and updates the TechnicalDebt line. All sevenagc_driver_prepared_shadersmodes pass. WithShaderRegistry.cppfrommain, the new case fails with that error.pr-intakewould close a new PR from me, and @EdouardSence is in the same position. How would you like us to carry it on?Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-10T12:00:25Z.
Data for Pipodi's relocation commit (
44a80d4f, https://github.com/Pipodi/AnyPS5/tree/fix/relocated-shader-header-copies), from Ghost of Yōtei (PPSA26344) on Linux.Setup: CachyOS (kernel 7.2.9), RX 9070 XT (RADV), Release, headless gamescope with scripted input. Main
b5f5362d3+ #1940 (needed to get past operand 235, #1920).Without
44a80d4f: the title stops about 21 s in on the graphics path:A local print (not pushed) of the words that differ between the bound header and the registered snapshot:
Every pointer is at the same distance from its own header (
+0xc0,+0x90,+0x60, ...), so this is the whole-header copy the commit describes, on the graphics ABI and not only the static one.With
44a80d4fcherry-picked: that stop is gone. The title runs on to about 26 s and stops on an unrelated recompiler refusal (compute shader 0x80003aa700: GetImageResource dword 0 is not a valid runtime value, an image descriptor read from a buffer at a computed index).Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-10T12:57:26Z.
Thanks @EdouardSence, and @Dextroid17 in #675 on lavapipe:
44a80d4fclears the replaced-header stop on RADV and llvmpipe too, on the graphics ABI as well as the static one. The commit is unchanged on https://github.com/Pipodi/AnyPS5/tree/fix/relocated-shader-header-copies whenever the maintainers decide how they'd like it carried.