fix(agc): bind a V# past the range limit by the memory behind it #5778
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5778"
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 meh7an on 2026-10-14T10:17:59Z.
What
A buffer V# whose size (
num_records * stride) is pastmaxStorageBufferRangestopped the draw withshader buffer exceeds descriptor range limit, and on currentmaina failed draw ends the title. Titles leave such words in descriptor slots their shaders do not reach on the path taken. Following the review of #3202,ShaderResources::addGuestBuffernow binds such a V# by the guest memory behind it:A V# inside the limit is unchanged. The console's behaviour for an access past the bound range is not known; it is recorded under Unknown function info in
docs/dev/debt/libSceAgcDriver.md.Prince of Persia: The Lost Crown (PPSA10528) binds
c8010002 2c6bec20 c0053c00 04000013while it loads a save: base0xec20c8010002, above the user address space, about 33 TB.Tested
Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0, Release, this branch on
main872f52320.agc_driver_graphicspasses. The newoversizedDescriptorTestschecks the three cases: an oversized V# 8 KiB before the end of a 64 KiB registered block is bound as those 8 KiB with their bytes; one at the block's start (64 KiB, past the mock 16 KiB limit) still throws; one over unregistered memory binds the placeholder. The two existing oversized cases over unregistered test memory are now accepted. Nothing in the test is Windows-only.shader buffer exceeds descriptor range limit. With it, the save loads and the first level renders. That run was onmainea53213fdwith this change plus local versions of #3295 and #5049, which the title needs to get that far.Checklist
main; no other open PR implements the same functions (#3202 did and is closed; this follows its review)NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.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-14T16:30:54Z.
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)docs/dev/debt/libSceAgcDriver.mdL21Some 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/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppImported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-14T16:58:12Z.
Kena: Bridge of Spirits (PPSA01746) stops on the throw this PR changes, with a V# of this kind. A local print in front of the
Require(byteSize <= maxStorageBufferRange ...)inaddGuestBuffer(not part of any PR; #5761's head25cc5e6d2, fragment shader, binding 63, element 1 of 2, read only) gavewords 00000000 00fff000 06f00000 00000000 byteSize 29679943680 limit 4294967295 stride 255 records 116391936 base f00000000000(PPSA01746_rX/run_170224.errline 119,what(): AGC graphics: shader buffer exceeds descriptor range limitat line 122; the same words inrun_171822.errline 116).By the code: that base (
0xf000_0000_0000) is not in the registered allocations, soRegisteredReadableEnd(GuestBufferMemory.cpp:2365) returns 0, the new branch setsbyteSize = 0, and the slot gets the empty placeholder buffer instead of the throw. I did not run Kena with this PR, so I do not know whether the title then gets past this draw; it stopped at other places in other runs on the same head (buffer descriptor uses an unsupported typeatResourceMaterializer.cpp:590, andVulkan result -4).AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-14T18:09:30Z.
Tested on head
e9c98900e(the current head of this pull request on GitHub, same SHA).Kena: Bridge of Spirits (PPSA01746) gets past the
shader buffer exceeds descriptor range limitthrow that this change targets (one run).main278765a07+ this head (clean merge, tree65dc50edc), no other changes. In the run (PPSA01746_rK5/run_200250.err, 805 lines, 240 s limit) there is no line withexceeds descriptor range(0 of 805). The run ends at line 121 with a different error:what(): AGC graphics: guest sampler descriptor uses unnormalized coordinates with anisotropic filtering, which is not implemented(line 119[videoout] presentation failed: …, line 122FATAL: abort()); that is a sampler gap, not related to this pull request.PPSA01746_rX/run_170224.errline 122,what(): AGC graphics: shader buffer exceeds descriptor range limit). I did not runmain278765a07without this pull request, so the comparison is with those earlier runs, not with the samemain.Test conditions
ninja -C build -j4 relinkerplus all 126core/libs/libs/*.prxof the merged tree, finished 20:01:54 local time (libSceAgcDriver.prx20:01:45,relinker.exe20:01:54).relink_title_trace.ps1 -Id PPSA01746 -Repo <that tree>=relinker.exe --windows --registry --trace-importsfrom the converted inputs of the earlierPPSA01746_rXrun (no-ModuleDir). Run:run_title.ps1 -Seconds 240,APS5_TRACE_CALLS=all.Limits
One title, one run. Whether the draw behind the old throw is rendered correctly, I did not look at. This pull request's own tests were not run.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-15T10:35:13Z.
Teardown (PPSA15246) stops on the same throw class as Kena here, and with this PR it moves on to the next check instead of passing.
Without this PR (session B,
maind92a8dad390af1807cc91622b924252141816a5a,PPSA15246_rR/run_110418.errlines 23-27):[gpu] driver failure: compute shader 0x1409cd300: AGC graphics: shader buffer exceeds descriptor range limit(the check inShaderResources::addGuestBuffer), thenFATAL: abort() (SIGABRT).With this PR (head
e9c98900e7c6c466381a3d99ed8d558b6d9f053f) onmaine49ec591dc93c9e4dfaad8b6dbc0b995dd7830a0(merge tree76ee4db26da038be8c6ff1864f164ca44a9cf492), same title executable (PPSA15246_rR/app.exe, relinked 2026-10-15 09:54:01, hardlinked asPPSA15246_rY5/app.exe), same key plan as B (run_menu.log), 240 s requested: theaddGuestBufferthrow is gone, and the same shader stops one check later, at line 31 and 33 ofPPSA15246_rY5/run_122959.err(60 lines):(line 33 repeats it as
what()).That text comes from
GuestBufferMemory::Descriptor(GuestBufferMemory.cpp:4061on thatmain:Require(range <= context.limits.maxStorageBufferRange, ...)), which runs on the view thataddGuestBuffernow hands out. So for this title the PR does not remove the stop; it only passes its own check. I did not print the V# or the sizes, so I do not know why the view is still past the limit; one possibility, not checked, is that the bound size ends within the view adjustment of the limit (ViewBytesadds the alignment adjustment to the size).The window title shows the run was at
FPS: 59.94 (804)before it stalled (FPS: 0.27 (842)to the end;send_keys_td5778.log).Tested. Windows 10 (19045), MinGW-w64 GCC 15.2, Release, NVIDIA GeForce RTX 4080 SUPER.
ninja -j 8 libsexit 0 (script times 12:19:10 to 12:28:13),run_title.ps1, one game at a time, script times 12:29:20 to 12:32:35 (includes the wait for the run mutex), one run, no local changes. Relinker commit and command for the executable are not recorded in my notes (made by session B). Not tested: Linux, other GPUs, a picture.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T12:54:52Z.
Checked on Linux (RADV):
agc_driver_graphicspasses with the change and fails without it, the rest of the libSceAgcDriver ctest scope is green apart fromagc_driver_tessellation(RADV segfault, also on main). Both partial-allocation and unregistered cases are pinned, and the allocation-reaching-the-limit case still throws. Merging once the full Build is green.Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-15T20:47:33Z.
Title evidence on
mainafter this PR: Kena: Bridge of Spirits (PPSA01802).On
mainaa1927872(2026-10-14) Kena stopped before its first scene withAGC graphics: shader buffer exceeds descriptor range limit(a read-only V# with an unmapped base, see #5428). On plainmaince991f1ec(includes this PR, no other changes, relinked with that build's relinker), one 150 s run:timeout, no throw, no crash, no GPU reset).unsupportedlines are 6 ofShader … has unsupported registered shader type 8; it is not prepared at registration.Setup: Linux (Arch, kernel 7.2.9), GCC, Release, RX 9070 XT (RADV, Mesa 26.2.4). Diagnostics only:
APS5_TRACE_SKIPS=1 APS5_DUMP_FRAMES=40 APS5_DUMP_FRAMES_EVERY=100.AI-assisted (Claude Code).