fix(agc): bind a read-only V# over the cached address space through the region that holds it #5815
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5815"
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 EagleBearerYS on 2026-10-14T12:03:31Z.
What
Resident Evil Village (PPSA01556) stops in a G-buffer draw at the title, and, with that case fixed, again during the first scene load:
Since #5428, the cached address space survives a read-only V# that only partly overlaps its base regions (
readsOverBase). The V# gets a region of its own, so a build's own regions can now overlap base regions. Two overlapping read-only V#s that each cross an import edge are merged byUploadPrepareinto one own region, which can begin before the base region that holds the second V#'s first byte.GuestBufferMemory::owner()takes the region with the greatest begin at or below the address from the build's own regions and from the space's base. It returned the base one when that began later, which was right while the two never overlapped. Here it returned the base region of one 64 KiB mapping, with its own 64 KiB import, for a 1.7 MB view.Descriptorthen refused the view.The second stop takes another path to the same lookup. When an import was retired after the space was built,
UploadFinishdissolves the space afterUploadPrepare. That merges the base regions into the build's sorted list on the assumption that the two never overlap. The space is then gone, soowner()searched only the merged list, where the region with the greatest begin was again a base region of one mapping.The commits:
fix(agc):owner()takes the end of the range it is asked about and returns the candidate that holds the whole range. It keeps the previous rule when both or neither do.Descriptorpasses the view's end, and the write-back paths pass the end of each written range they already loop over.fix(agc): a dissolve afterUploadPreparenotes when the merged list overlaps, andowner()then looks back for a region that holds the range. The usual disjoint list keeps the single binary search.fix(agc): the GPU side of the same lists. A build's BDA table (AddressRanges,CachedAddressTable) still listed its own regions next to the space's base regions they overlap, and the shader's lookup takes the last range whose begin is at or below the address (SpirvBdaLookup.cpp). So a BDA store into a writable import could resolve to the read-only copy of a V# across it. The table is now disjoint:UploadPrepare, the former base regions first, and the copies clipped against them;test(agc): BDA stores under a read-only V# across imports reach the writable import.test(agc): the merged read-only V# test proves the paths it takes, with the address-space counters. The first build must be a space hit with no overlap dissolve, and the second must dissolve on imports. One crossed piece is registered writable, so a join of the run can't take the test's coverage away. It also checks access across the edge.test(agc): a store through a written V# merged with a read-only V# past an import, which goes through the write-back paths commit 1 changed.Scope: read-only V#s that cross imports aren't joined into one region here, which would avoid the overlap in the first place; #5372 and #6197 work on joins. This PR keeps the overlap that #5428 allows and makes the CPU lookup and the BDA table agree on it, so it holds with or without those joins.
Related: #5428, and #5169 (the Village bring-up discussion).
Tested
On GitHub's runners from my fork, on
mainat872f52320:-DANYPS5_ENABLE_SPIRV_TOOLS=ON.spaceReadsAcrossImportsMergedTestsintests/BdaResources.cpp(run byagc_driver_graphics) maps six 64 KiB ranges in a 128 KiB import window, so the space's base has three two-range imports. It then binds two overlapping read-only V#s, one across the first edge and one from inside the second import across the second edge, in three address-based builds with the space cache on. The third build retires the imports betweenUploadPrepareandUploadFinish, so the space dissolves after the regions were prepared.main'sGuestBufferMemory.cppit fails on Linux and Windows with the title's message,guest buffer view ... exceeds its GPU owner ... (buffer 0, direct 1, mirror 0)(run).agc_driver_graphicsand the other tests of its executable pass 20 runs in a row on Linux and Windows, and so does every test undercore/libs/prx/libcandcore/libs/prx/libkernel(70 and 133 on Linux, 91 and 137 on Windows).Commits 3-6, on Linux (Ubuntu 24.04, GCC 13.3, CI's configure flags, lavapipe), on
mainatd92a8dad39:AGC graphics: the BDA table of a build with a read-only V# across imports has overlapping rangesandAGC graphics: a BDA store into a writable import resolves to the read-only copy of a V# across it. They pass with commit 3.mainwithout this PR, with the title's message (guest buffer view 0x564c68a80200+0x100 exceeds its GPU owner 0x564c68a70000-0x564c68a80000 (buffer 0, direct 1, mirror 0)), and passes with it.agc_driver_graphicsandagc_sparse_buffer_holespass. At the head, the full suite runs 1117 tests, and 5 fail: the IPv6 socket tests (guest_datagram_*andguest_tcp), which fail on that VM without this PR too.maind92a8dad39: 1253 of 1253 tests pass (run).ANYPS5_REQUIRE_VULKAN=1and only the NVIDIA driver visible:agc_driver_graphics,agc_driver_bda_device,agc_driver_bda_span_readsandagc_sparse_buffer_holespass 5 of 5 each (--repeat until-fail:5). The head was merged with #6146's latest commits for one combined run.tools/check_conventions.py --base origin/mainpasses.Resident Evil Village (PPSA01556, 01.210.000) on Windows 11 Home 10.0.26300, RTX 3070 Laptop (driver 617.42), Ryzen 9 5900HS, 15.4 GB RAM:
mainthe title doesn't reach this point on this PC by itself. Preparing every shader at registration gives a black screen with private memory heading for the commit limit, and several earlier stops come first. So both runs aremainat23be5a02bwith #5688 (the 419 MiB copy stop at boot) and #5703, plus local test commits that aren't part of this PR:APS5_RE8_LAZY_PREPARE=1, withAPS5_NO_GPL=1);[videoout] presentation failed: AGC graphics: guest buffer view 0x1f0494592c+0x1b2190 exceeds its GPU owner 0x1f04940000-0x1f04950000 (buffer 0, direct 1, mirror 0), then an abort. That's the same address as in our own stack's runs.Ghost of Yōtei (PPSA26344), run by Pipodi on Windows 11 with an RTX 4090 (driver 617.42) (comment), on
main9a3e2ac4dwith #4450, #4475 and #5851. The only difference between the two runs is this PR's two commits:guest buffer view 0x912f8c088c+0x27918 exceeds its GPU owner 0x912f8c0000-0x912f8e0000 (buffer 0, direct 1, mirror 0)after 1,124 s, at the same view and owner on every run.Celegans12 hit the same abort on Ghost of Yōtei 1.008 after syncing with
maine34c47921, on Windows 11 with an RTX 3080 Laptop GPU (driver 610.62) (comment):guest buffer view 0x9093082f64+0x1dab8 exceeds its GPU owner 0x9093080000-0x90930a0000 (buffer 0, direct 1, mirror 0)at the loading screen, 979 s and 1,859 s in.[address]showsdissolved: overlap 0.teepean hit the same abort on Ghost of Yōtei 02.002.000 on Linux (CachyOS, RTX 3090, NVIDIA 615.78.08), on
mainf785b88a6with local workarounds for four earlier stops (report):guest buffer view 0x918017088c+0x27918 exceeds its GPU owner 0x9180170000-0x9180180000 (buffer 0, direct 1, mirror 0), about 6 minutes in.registered program refers to an incompatible shader binary type).simonbronk hit the same abort on a second RE Engine title, Onimusha: Way of the Sword (PPSA27836), on Windows 11 with an RTX 5070 (driver 617.42) (comment), on
main0afa6a607with the title's PRs (#5907, #5776, #5770, #5703, #5841, #5884, #5915) and local sample-count changes:guest buffer view 0x1d08ee1bc0+0x28b320 exceeds its GPU owner 0x1d08e00000-0x1d09000000 (buffer 0, direct 1, mirror 0)during the New Game scene load.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.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-14T17:56:54Z.
Tested on Ghost of Yōtei (PPSA26344), where the same abort stopped every build since #5596 at the same spot:
It fired during presentation about 18 minutes in (around present 833), with the same view and owner on every run.
Setup: Windows 11, RTX 4090 (NVIDIA 617.42), i9-13900K. Our tree is
main9a3e2ac4dplus the PRs Ghost of Yōtei needs (#4450, #4475 and #5851). The only change between the two runs is this PR's two commits (d4709592e,c54854b2b), cherry-picked cleanly.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-14T18:00:47Z.
Thanks for running it on Ghost of Yōtei. A second title with the same abort, and the same view-against-owner shape, is good to have. I've added it to the description.
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-14T21:50:14Z.
I hit this on Ghost of Yōtei (PPSA26344 v1.008) after syncing our game branch with
maine34c479210, and your two commits fix it here too. Without them the loading screen aborted on the same view every time:guest buffer view 0x9093082f64+0x1dab8 exceeds its GPU owner 0x9093080000-0x90930a0000 (buffer 0, direct 1, mirror 0), at 1,859 s in one run and 979 s in another. Withd4709592e7andc54854b2bdcherry-picked on the same build, the run went the full 3,000 s with no abort, and the[address]lines showdissolved: overlap 0, so the space stays kept.Details
maine34c479210merged with our local Yōtei stack, plus #5815's two commits cherry-picked. The stack doesn't changeGuestBufferMemory's owner lookup, and the abort reproduced without the cherry-picks.agc_driver_graphicswith yourspaceReadsAcrossImportsMergedTests,agc_driver_address_space_teardown,agc_sparse_buffer_holesand theagc_host_import*tests.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-14T21:56:10Z.
Thanks for running it on your Yōtei build. Two setups now hit the same abort and pass with the two commits, so I've added your run to the description.
Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-15T10:05:27Z.
Tested on a second RE Engine title: Onimusha: Way of the Sword (PPSA27836). Windows 11, RTX 5070 (NVIDIA 617.42).
Base:
main0afa6a607with the title's PRs (#5907, #5776, #5770, #5703, #5841, #5884, #5915) and local sample-count changes. During the New Game scene load, the title stops with the same message as Village:With this PR merged (no conflicts), that stop is gone, and the load reaches later draws. It stops further on, at an unrelated sample-count check.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-15T10:12:07Z.
Thanks for testing it on Onimusha! I've added your run to the description.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:09:56Z.
Some 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/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T13:15:01Z.
Checked on the PR merged onto main: build and ctest for libSceAgcDriver (
agc_driver_graphics,agc_driver_bda_device,agc_driver_bda_span_reads,agc_sparse_buffer_holespass). With the two source files reverted to main,agc_driver_graphicsfails, so the new tests pin the fix.owner()now picks the region that holds the whole range, and the BDA table is made disjoint to match; the runs on Village, Ghost of Yōtei and Onimusha reported in the thread cover the real-title case.agc_driver_tessellation(segfault on local RADV) andagc_driver_store_over_untracked(intermittent, also seen with main's code) are unrelated to this change. Merging.